Skip to content

Commit 290b84e

Browse files
committed
fix: add security hardening flags and optimize build settings
1. Added security hardening compilation flags in debian/rules including: - Stack protection (-fstack-protector-all) - Relocation hardening (-Wl,-z,relro/now/noexecstack) - Warning flags (-Wall) 2. Simplified dtkwidget.cmake by removing redundant linker flags 3. Maintained essential security flags while cleaning up build configuration 4. These changes improve binary security while keeping build process efficient fix: 添加安全加固标志并优化构建设置 1. 在debian/rules中添加安全加固编译标志包括: - 栈保护 (-fstack-protector-all) - 重定位加固 (-Wl,-z,relro/now/noexecstack) - 警告标志 (-Wall) 2. 简化dtkwidget.cmake,移除冗余链接器标志 3. 在保持基本安全标志的同时清理构建配置 4. 这些改动在保持构建效率的同时提高了二进制安全性
1 parent f20be8b commit 290b84e

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

debian/rules

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@ DPKG_EXPORT_BUILDFLAGS = 1
33
include /usr/share/dpkg/default.mk
44
export QT_SELECT = qt5
55

6+
# 安全编译参数
7+
export DEB_BUILD_MAINT_OPTIONS = hardening=+all
8+
export DEB_CFLAGS_MAINT_APPEND = -Wall
9+
export DEB_CXXFLAGS_MAINT_APPEND = -Wall
10+
export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed -Wl,-z,relro -Wl,-z,now -Wl,-z,noexecstack -Wl,-E
11+
612
DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)
713

814
DEB_BUILD_ARCH ?= $(shell dpkg-architecture -qDEB_BUILD_ARCH)

dtkwidget.cmake

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,7 @@ if (NOT CMAKE_BUILD_TYPE)
8989
endif()
9090

9191
if(NOT MSVC)
92-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -Wall -Wextra")
93-
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--as-needed")
92+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -Wextra")
9493
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--as-needed -pie")
9594
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
9695
set(BUILD_TESTING ON)

0 commit comments

Comments
 (0)