From c4fefc076767f1a67fcbe814dd67e5f182a22c72 Mon Sep 17 00:00:00 2001 From: Patryk Duda Date: Tue, 16 Apr 2024 12:44:32 +0200 Subject: [PATCH] cortex_m: linker: lld: Handle symtab/strtab/shstrtab to fix warnings LLD produces warnings about orphaned sections if there are no matching rules in the linker script: ld.lld: warning: :(.symtab) is being placed in '.symtab' ld.lld: warning: :(.shstrtab) is being placed in '.shstrtab' ld.lld: warning: :(.strtab) is being placed in '.strtab' Handle these sections when building with LLD to prevent the warnings. Signed-off-by: Patryk Duda --- include/zephyr/arch/arm/cortex_m/scripts/linker.ld | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/include/zephyr/arch/arm/cortex_m/scripts/linker.ld b/include/zephyr/arch/arm/cortex_m/scripts/linker.ld index d061468d2ac..da802647db1 100644 --- a/include/zephyr/arch/arm/cortex_m/scripts/linker.ld +++ b/include/zephyr/arch/arm/cortex_m/scripts/linker.ld @@ -469,6 +469,15 @@ GROUP_END(DTCM) KEEP(*(.gnu.attributes)) } +/* Output section descriptions are needed for these sections to suppress + * warnings when "--orphan-handling=warn" is set for lld. + */ +#if defined(CONFIG_LLVM_USE_LLD) + SECTION_PROLOGUE(.symtab, 0,) { *(.symtab) } + SECTION_PROLOGUE(.strtab, 0,) { *(.strtab) } + SECTION_PROLOGUE(.shstrtab, 0,) { *(.shstrtab) } +#endif + /* Sections generated from 'zephyr,memory-region' nodes */ LINKER_DT_SECTIONS()