Skip to content

Commit 2ea4e76

Browse files
18202781743deepin-bot[bot]
authored andcommitted
fix: enhance build security hardening
1. Added security hardening compiler flags in debian/rules including stack protection and RELRO 2. Removed redundant linker flag from dtkgui.cmake that was already set in debian/rules 3. Consolidated security-related build flags in debian/rules for better maintainability 4. The changes improve binary security against common exploits while maintaining compatibility fix: 增强构建安全加固 1. 在debian/rules中添加了安全加固编译标志,包括栈保护和RELRO 2. 从dtkgui.cmake中移除了已在debian/rules中设置的冗余链接器标志 3. 将安全相关的构建标志整合到debian/rules中以提高可维护性 4. 这些改动提高了二进制文件对常见漏洞攻击的防护能力,同时保持兼容性
1 parent 18388f2 commit 2ea4e76

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

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
VERSION = $(DEB_VERSION_UPSTREAM)

dtkgui.cmake

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ set(CONFIG_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}/cmake/Dtk${DTK_VERSION_MAJOR}Gui
4343
set(PKGCONFIG_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
4444

4545
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -Wall -Wextra -fopenmp")
46-
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--as-needed")
4746
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pie")
4847
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
4948
set(BUILD_TESTING ON)

0 commit comments

Comments
 (0)