Skip to content

Commit 94dc4a0

Browse files
committed
cmake: Make linking compatible with newer toolchains
We also have to provide the search path to the linker to our dummy files libssp and libssp_nonshared. The actual implementation of the stack protector functions are in common_main.c.
1 parent 8c6ce6a commit 94dc4a0

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,12 @@ string(APPEND CMAKE_C_FLAGS " -Wno-cast-function-type")
328328

329329
# Hardening
330330
string(APPEND CMAKE_C_FLAGS " -fstack-protector-all")
331+
if(CMAKE_CROSSCOMPILING)
332+
# Path to empty dummy libssp and libssp_shared. '-llibssp -llibssp_shared' is automatically added
333+
# with '-fstack-protector-all', but we don't need them as we have our own custom
334+
# `__stack_chk_fail`. See https://wiki.osdev.org/Stack_Smashing_Protector.
335+
set(CMAKE_C_LINK_FLAGS "${CMAKE_C_LINK_FLAGS} -L${CMAKE_CURRENT_SOURCE_DIR}/external/lib/ssp")
336+
endif()
331337

332338
# Disallow duplicate definitions, which is the default since GCC
333339
# 10. It was not default in gcc-arm-none-eabi-8-2018-q4.

0 commit comments

Comments
 (0)