From bb32413ff7247f5ac3685ca9075b3432bca69a82 Mon Sep 17 00:00:00 2001 From: Srinath Parvathaneni Date: Tue, 2 Jul 2019 12:43:59 +0100 Subject: Ensure that debug information is retained for ARMv8-M security functions. Consider a file containing only Armv8-M secure entry functions. This file is compiled and linked with "-march=armv8-m.main -mfloat-abi=hard -mfpu=fpv5-sp-d16 -mcmse -static --specs=rdimon.specs -Wl,--section-start,.gnu.sgstubs=0x190000 -ffunction-sections -fdata-sections -Wl,--gc-sections -g" options to generate an executable. The executable generated does not contain any debug information of these secure entry functions even though it contains secure entry functions in the .text section. This patch fixes this problem. --- bfd/elf32-arm.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'bfd/elf32-arm.c') diff --git a/bfd/elf32-arm.c b/bfd/elf32-arm.c index bcace92..fc7a41c 100644 --- a/bfd/elf32-arm.c +++ b/bfd/elf32-arm.c @@ -15903,6 +15903,8 @@ elf32_arm_gc_mark_extra_sections (struct bfd_link_info *info, struct elf_link_hash_entry **sym_hashes; struct elf32_arm_link_hash_entry *cmse_hash; bfd_boolean again, is_v8m, first_bfd_browse = TRUE; + bfd_boolean debug_sec_need_to_be_marked = FALSE; + asection *isec; _bfd_elf_gc_mark_extra_sections (info, gc_mark_hook); @@ -15964,8 +15966,25 @@ elf32_arm_gc_mark_extra_sections (struct bfd_link_info *info, if (!cmse_sec->gc_mark && !_bfd_elf_gc_mark (info, cmse_sec, gc_mark_hook)) return FALSE; + /* The debug sections related to these secure entry + functions are marked on enabling below flag. */ + debug_sec_need_to_be_marked = TRUE; } } + + if (debug_sec_need_to_be_marked) + { + /* Looping over all the sections of the object file containing + Armv8-M secure entry functions and marking all the debug + sections. */ + for (isec = sub->sections; isec != NULL; isec = isec->next) + { + /* If not a debug sections, skip it. */ + if (!isec->gc_mark && (isec->flags & SEC_DEBUGGING)) + isec->gc_mark = 1 ; + } + debug_sec_need_to_be_marked = FALSE; + } } } first_bfd_browse = FALSE; -- cgit v1.1