Skip to content

Commit 88727c8

Browse files
wangrong1069deepin-bot[bot]
authored andcommitted
fix: Fix sw64 gcc not support pie by default
Add the -fPIE parameter via CMAKE_POSITION_INDEPENDENT_CODE. Add the -pie parameter via target_link_options. Log: Update compiler flags for security enhancements Bug: https://pms.uniontech.com/bug-view-339563.html
1 parent 09d5e7e commit 88727c8

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

CMakeLists.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd.
1+
# SPDX-FileCopyrightText: 2022 - 2026 UnionTech Software Technology Co., Ltd.
22
#
33
# SPDX-License-Identifier: CC0-1.0
44

@@ -7,5 +7,8 @@ project(deepin-ocr)
77

88
option(DOTEST "option for test" OFF)
99

10+
# 启用位置无关代码,提高安全性(ASLR)
11+
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
12+
1013
#deepin-ocr
1114
add_subdirectory(src)

src/CMakeLists.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd.
1+
# SPDX-FileCopyrightText: 2022 - 2026 UnionTech Software Technology Co., Ltd.
22
#
33
# SPDX-License-Identifier: CC0-1.0
44

@@ -202,6 +202,9 @@ if(DOTEST)
202202
)
203203
endif()
204204

205+
# 启用位置无关可执行文件,提高安全性
206+
target_link_options(${PROJECT_NAME} PRIVATE -pie)
207+
205208
# dde项目,期望CMAKE_INSTALL_PREFIX为/usr
206209
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
207210
set(CMAKE_INSTALL_PREFIX /usr)

0 commit comments

Comments
 (0)