Build: Improve BL1 code-sharing
Force symbols to be kept if they are needed in BL1_2, but are not used
in Bl1_1
Change-Id: I5af6f3be552f0f97df704051f03a6994c79c76d5
Signed-off-by: Raef Coles <raef.coles@arm.com>
diff --git a/toolchain_GNUARM.cmake b/toolchain_GNUARM.cmake
index 7989718..dfb2f2e 100644
--- a/toolchain_GNUARM.cmake
+++ b/toolchain_GNUARM.cmake
@@ -319,15 +319,22 @@
FILE(STRINGS ${symbol_name_file} KEEP_SYMBOL_LIST
LENGTH_MINIMUM 1
)
+ set(STRIP_SYMBOL_KEEP_LIST ${KEEP_SYMBOL_LIST})
+ # Force the target to not remove the symbols if they're unused.
+ list(TRANSFORM KEEP_SYMBOL_LIST PREPEND "-Wl,--undefined=")
+ target_link_options(${target}
+ PRIVATE
+ ${KEEP_SYMBOL_LIST}
+ )
- list(TRANSFORM KEEP_SYMBOL_LIST PREPEND --keep-symbol=)
+ list(TRANSFORM STRIP_SYMBOL_KEEP_LIST PREPEND --keep-symbol=)
# strip all the symbols except those proveded as arguments
add_custom_command(
TARGET ${target}
POST_BUILD
COMMAND ${CROSS_COMPILE}-objcopy
- ARGS $<TARGET_FILE:${target}> --wildcard ${KEEP_SYMBOL_LIST} --strip-all $<TARGET_FILE_DIR:${target}>/${target}_shared_symbols.axf
+ ARGS $<TARGET_FILE:${target}> --wildcard ${STRIP_SYMBOL_KEEP_LIST} --strip-all $<TARGET_FILE_DIR:${target}>/${target}_shared_symbols.axf
)
endmacro()