From: Igor Kotrasinski Date: Wed, 16 Aug 2017 08:21:26 +0000 (+0200) Subject: Force PIE compilation flags in CMakeLists X-Git-Tag: accepted/tizen/4.0/unified/20170829.020247^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F24%2F144324%2F4;p=platform%2Fcore%2Fsecurity%2Fkey-manager.git Force PIE compilation flags in CMakeLists Fixes ckm_tool executable not being PIE. Change-Id: I5bfd915171cb0f9a9b6a17cc8fbec921c4bfb127 Signed-off-by: Igor Kotrasinski --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 1ade756..a5b7320 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -37,11 +37,9 @@ SET(CMAKE_CXX_FLAGS_RELEASE "-g -std=c++0x -O2") SET(CMAKE_C_FLAGS_CCOV "-g -O2 --coverage") SET(CMAKE_CXX_FLAGS_CCOV "-g -std=c++0x -O2 --coverage") -# If supported for the target machine, emit position-independent code,suitable -# for dynamic linking and avoiding any limit on the size of the global offset -# table. This option makes a difference on the m68k, PowerPC and SPARC. -# (BJ: our ARM too?) -ADD_DEFINITIONS("-fPIC") +# Force PIE +SET(CMAKE_POSITION_INDEPENDENT_CODE "True") +SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pie") # Set compiler warning flags ADD_DEFINITIONS("-Werror") # Make all warnings into errors. diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a784d15..2e7291c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -80,11 +80,10 @@ SET(KEY_MANAGER_SOURCES ${CYNARA_WRAPPER_PATH} ) -# -fPIE and -pie flag is added for ASLR SET_SOURCE_FILES_PROPERTIES( ${KEY_MANAGER_SOURCES} PROPERTIES - COMPILE_FLAGS "-D_GNU_SOURCE -fvisibility=hidden -fPIE") + COMPILE_FLAGS "-D_GNU_SOURCE -fvisibility=hidden") INCLUDE_DIRECTORIES(SYSTEM ${KEY_MANAGER_DEP_INCLUDE_DIRS} @@ -107,12 +106,11 @@ LINK_DIRECTORIES(${KEY_MANAGER_DEP_LIBRARY_DIRS}) ADD_EXECUTABLE(${TARGET_KEY_MANAGER} ${KEY_MANAGER_SOURCES}) -# pie flag is added for ASLR TARGET_LINK_LIBRARIES(${TARGET_KEY_MANAGER} ${CMAKE_THREAD_LIBS_INIT} ${KEY_MANAGER_DEP_LIBRARIES} ${TARGET_KEY_MANAGER_COMMON} - -ldl -pie + -ldl ) ################################################################################ @@ -156,7 +154,7 @@ ADD_LIBRARY(${TARGET_KEY_MANAGER_CLIENT} SHARED ${KEY_MANAGER_CLIENT_SOURCES}) SET_TARGET_PROPERTIES( ${TARGET_KEY_MANAGER_CLIENT} PROPERTIES - COMPILE_FLAGS "-D_GNU_SOURCE -fPIC -fvisibility=hidden -Wno-deprecated-declarations" + COMPILE_FLAGS "-D_GNU_SOURCE -fvisibility=hidden -Wno-deprecated-declarations" SOVERSION ${KEY_MANAGER_CLIENT_VERSION_MAJOR} VERSION ${KEY_MANAGER_CLIENT_VERSION} ) @@ -194,7 +192,7 @@ ADD_LIBRARY(${TARGET_KEY_MANAGER_CONTROL_CLIENT} SHARED ${KEY_MANAGER_CONTROL_CL SET_TARGET_PROPERTIES( ${TARGET_KEY_MANAGER_CONTROL_CLIENT} PROPERTIES - COMPILE_FLAGS "-D_GNU_SOURCE -fPIC -fvisibility=hidden -Wno-deprecated-declarations" + COMPILE_FLAGS "-D_GNU_SOURCE -fvisibility=hidden -Wno-deprecated-declarations" SOVERSION ${KEY_MANAGER_CONTROL_CLIENT_VERSION_MAJOR} VERSION ${KEY_MANAGER_CONTROL_CLIENT_VERSION} ) diff --git a/src/manager/CMakeLists.txt b/src/manager/CMakeLists.txt index f0770e1..d07b817 100644 --- a/src/manager/CMakeLists.txt +++ b/src/manager/CMakeLists.txt @@ -59,7 +59,7 @@ ADD_LIBRARY(${TARGET_KEY_MANAGER_COMMON} SHARED ${COMMON_SOURCES}) SET_TARGET_PROPERTIES( ${TARGET_KEY_MANAGER_COMMON} PROPERTIES - COMPILE_FLAGS "-D_GNU_SOURCE -fPIC -fvisibility=hidden" + COMPILE_FLAGS "-D_GNU_SOURCE -fvisibility=hidden" SOVERSION ${KEY_MANAGER_COMMON_VERSION_MAJOR} VERSION ${KEY_MANAGER_COMMON_VERSION} )