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/bl1/bl1_1/bl1_1_shared_symbols.txt b/bl1/bl1_1/bl1_1_shared_symbols.txt
index 690fb79..e2988db 100644
--- a/bl1/bl1_1/bl1_1_shared_symbols.txt
+++ b/bl1/bl1_1/bl1_1_shared_symbols.txt
@@ -1,38 +1,20 @@
+Driver_FLASH0
+SystemInit
+bl1_aes_256_ctr_decrypt
+bl1_derive_key
+bl1_otp_read_key
bl1_sha256_compute
+bl1_sha256_finish
bl1_sha256_init
bl1_sha256_update
-bl1_sha256_finish
-bl1_aes_256_ctr_decrypt
-bl1_otp_read_key
-bl1_derive_key
bl1_trng_generate_random
-
-tfm_plat_otp_get_size
-tfm_plat_otp_write
-tfm_plat_otp_read
-
-bl_secure_memeql
bl_secure_memcpy
-
-cc3xx_finish
-
-fih_delay_random_uchar
-_fih_cfi_ctr
-FIH_FAILURE
-FIH_SUCCESS
-_fih_mask
-fih_cfi_decrement
-fih_cfi_get_and_increment
-fih_cfi_validate
-fih_panic_loop
-
computed_bl1_2_hash
-
-ATU_DEV_S
-KMU_DEV_S
-SPI_STRATAFLASHJ3_DEV
-
+pq_crypto_verify
stdio_init
-stdio_uninit
stdio_output_string
-tfm_log_printf
+stdio_uninit
+tfm_plat_init_nv_counter
+tfm_plat_otp_read
+tfm_plat_read_nv_counter
+tfm_plat_set_nv_counter
diff --git a/toolchain_ARMCLANG.cmake b/toolchain_ARMCLANG.cmake
index 2d7a042..877c827 100644
--- a/toolchain_ARMCLANG.cmake
+++ b/toolchain_ARMCLANG.cmake
@@ -367,9 +367,8 @@
VERBATIM
COMMAND python3 -c "from sys import argv; import re; f = open(argv[1], 'rt'); p = [x.replace('*', '.*') for x in argv[2:]]; l = [x for x in f.readlines() if re.search(r'(?=('+'$|'.join(p + ['SYMDEFS']) + r'))', x)]; f.close(); f = open(argv[1], 'wt'); f.writelines(l); f.close();" $<TARGET_FILE_DIR:${target}>/${target}_shared_symbols.txt ${KEEP_SYMBOL_LIST})
- # Force the target to not remove the symbols if they're unused. Not
- # currently possible on GNU, has to be part of the linker script.
- list(TRANSFORM KEEP_SYMBOL_LIST PREPEND --keep=)
+ # Force the target to not remove the symbols if they're unused.
+ list(TRANSFORM KEEP_SYMBOL_LIST PREPEND --undefined=)
target_link_options(${target}
PRIVATE
${KEEP_SYMBOL_LIST}
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()