[PATCH][BINUTILS][ARM]: Mark debug sections of file containing cmse entry functions.

Srinath Parvathaneni Srinath.Parvathaneni@arm.com
Mon Jul 1 15:45:00 GMT 2019


Hi All,

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.

Example:
$ cat main.c
int main (void)
{
    return 0;
}

$ cat sec.c
void __attribute__((cmse_nonsecure_entry))
SecureLED_On ()
{
}

Generate the object files "main.o" and "sec.o" for above test, using 
below command.

1. $ arm-none-eabi-gcc -march=armv8-m.main -mfloat-abi=hard 
-mfpu=fpv5-sp-d16 -mcmse
-static --specs=rdimon.specs -ffunction-sections -fdata-sections main.c 
sec.c -g -c

Using linker, generate the executable for above generated object files.

2.$ arm-none-eabi-ld --section-start .gnu.sgstubs=0x190000 --gc-sections
main.o sec.o -e0 -o main_sec.out

Check for "SecureLED_On" in dwarf information generated for executable 
"main_sec.out".

3. $ arm-none-eabi-objdump --dwarf=info main_sec.out |grep "SecureLED_On"

There is no match for the function "SecureLED_On" in .dwarf_info.

After applying this patch and performing above steps 2 and 3, the output is:
       <8f>   DW_AT_name        : (indirect string, offset: 0x9d): 
SecureLED_On

This patch fixes the linker by marking all the debug sections (setting 
gc_mark to 1)
when .text section containing secure entry functions is marked.

Regression testsuite when run for arm-none-eabi shows no regression.

Ok for master? If ok, please commit on my behalf, I don't have the 
commit rights.

bfd/ChangeLog:

2019-07-01  Srinath Parvathaneni  <srinath.parvathaneni@arm.com>

	* elf32-arm.c (elf32_arm_gc_mark_extra_sections): Mark debug
	sections when .text section contain secure entry functions
	is marked.

ld/ChangeLog:

2019-07-01  Srinath Parvathaneni  <srinath.parvathaneni@arm.com>

	* testsuite/ld-arm/arm-elf.exp: Add tests.
	* testsuite/ld-arm/cmse_main.s: New test.
	* testsuite/ld-arm/cmse_main_sec_debug.d: Likewise.
	* testsuite/ld-arm/cmse_sec_debug.s: Likewise.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: rb11389.diff
Type: text/x-patch
Size: 7312 bytes
Desc: rb11389.diff
URL: <https://sourceware.org/pipermail/binutils/attachments/20190701/4b22efc6/attachment.bin>


More information about the Binutils mailing list