From 0181e8f10bdf3789fdf59f320b1a89fa5505a410 Mon Sep 17 00:00:00 2001 From: weizhixinag Date: Mon, 25 Oct 2021 13:38:56 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E5=AE=89=E5=85=A8?= =?UTF-8?q?=E7=BC=96=E8=AF=91=E9=80=89=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 增加gcc/g++安全编译选项,提高编译阶段安全性 Log: 增加安全编译选项 Task: https://pms.uniontech.com/zentao/story-view-13331.html Influence: 编译安全性 Change-Id: I324b36ddc0214af27cba65b4687c841c696b0b13 --- CMakeLists.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index fdced06d7..07d193e6f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,6 +13,9 @@ set(CMAKE_AUTOMOC ON) set(CMAKE_AUTORCC ON) set(CMAKE_CXX_FLAGS "-g -Wall") +# 增加安全编译参数 +ADD_DEFINITIONS("-fstack-protector-strong -D_FORTITY_SOURCE=1 -z noexecstack -pie -fPIC -z lazy") + if (${CMAKE_SYSTEM_PROCESSOR} MATCHES "mips64") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -ftree-vectorize -march=loongson3a -mhard-float -mno-micromips -mno-mips16 -flax-vector-conversions -mloongson-ext2 -mloongson-mmi -fPIE") set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pie")