[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug ld/30354] New: Debug info is lost for functions only called from fu
From: |
torbjorn.svensson at foss dot st.com |
Subject: |
[Bug ld/30354] New: Debug info is lost for functions only called from functions marked with cmse_nonsecure_entry |
Date: |
Fri, 14 Apr 2023 14:09:59 +0000 |
https://sourceware.org/bugzilla/show_bug.cgi?id=30354
Bug ID: 30354
Summary: Debug info is lost for functions only called from
functions marked with cmse_nonsecure_entry
Product: binutils
Version: unspecified
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: ld
Assignee: unassigned at sourceware dot org
Reporter: torbjorn.svensson at foss dot st.com
Target Milestone: ---
Created attachment 14826
--> https://sourceware.org/bugzilla/attachment.cgi?id=14826&action=edit
Demo
In order to generate an implib containing the addresses required to jump from a
non-secure function to a secure function, the secure function needs to use the
attribute cmse_nonsecure_entry. With this attribute, a certain .gnu.sgstubs
section in the ELF file is produced that contains these "secure callable
functions".
If the function with the attribute cmse_nonsecure_entry is calling some other
function that happens to be in a compile unit that does not have any other
function that is called from the main() function, then the debug information
for this compile unit is GCed if the application is linked with --gc-sections.
Attached is a small demonstration of what's happening.
The linker script in the attached example is the default one with one addition:
.gnu.sgstubs : { *(.gnu.sgstubs*) }
I suppose this is an overlook and that this section should be added to the
default linker script for Arm targets in order to not force the user to define
there own linker script.
The output when building the demonstration is this:
$ make
arm-none-eabi-gcc -mcpu=cortex-m33 -std=gnu11 -g3 -mcmse -ffunction-sections
-fdata-sections -c -o bar.o bar.c
arm-none-eabi-gcc -mcpu=cortex-m33 -std=gnu11 -g3 -mcmse -ffunction-sections
-fdata-sections -c -o main.o main.c
arm-none-eabi-gcc -mcpu=cortex-m33 -std=gnu11 -g3 -mcmse -ffunction-sections
-fdata-sections -c -o foo.o foo.c
arm-none-eabi-gcc -mcpu=cortex-m33 -T link.ld -static -Wl,--gc-sections
-Wl,--print-gc-sections -Wl,--cmse-implib -Wl,--out-implib=./secure_nsclib.o -o
test.elf bar.o main.o foo.o 2>&1 | grep -E 'removing unused section .* in file
.[a-z]+\.o.'
c:\toolchain\arm-none-eabi\bin\ld.exe: removing unused section '.group' in file
'bar.o'
c:\toolchain\arm-none-eabi\bin\ld.exe: removing unused section '.debug_info' in
file 'bar.o'
c:\toolchain\arm-none-eabi\bin\ld.exe: removing unused section '.debug_abbrev'
in file 'bar.o'
c:\toolchain\arm-none-eabi\bin\ld.exe: removing unused section '.debug_aranges'
in file 'bar.o'
c:\toolchain\arm-none-eabi\bin\ld.exe: removing unused section '.debug_ranges'
in file 'bar.o'
c:\toolchain\arm-none-eabi\bin\ld.exe: removing unused section '.debug_macro'
in file 'bar.o'
c:\toolchain\arm-none-eabi\bin\ld.exe: removing unused section
'.debug_macro[wm4.0.c063f11b96416a377bbfa49196ca6eec]' in file 'bar.o'
c:\toolchain\arm-none-eabi\bin\ld.exe: removing unused section '.debug_line' in
file 'bar.o'
c:\toolchain\arm-none-eabi\bin\ld.exe: removing unused section '.debug_str' in
file 'bar.o'
c:\toolchain\arm-none-eabi\bin\ld.exe: removing unused section '.comment' in
file 'bar.o'
c:\toolchain\arm-none-eabi\bin\ld.exe: removing unused section '.debug_frame'
in file 'bar.o'
c:\toolchain\arm-none-eabi\bin\ld.exe: removing unused section '.comment' in
file 'foo.o'
I've verified that the bug still exists with
acdf60711d44d20608873bec0376688c9a80e281 and it's not limited to Windows
although the output above was produced on Windows.
--
You are receiving this mail because:
You are on the CC list for the bug.
- [Bug ld/30354] New: Debug info is lost for functions only called from functions marked with cmse_nonsecure_entry,
torbjorn.svensson at foss dot st.com <=
- [Bug ld/30354] Debug info is lost for functions only called from functions marked with cmse_nonsecure_entry, nickc at redhat dot com, 2023/04/17
- [Bug ld/30354] Debug info is lost for functions only called from functions marked with cmse_nonsecure_entry, cvs-commit at gcc dot gnu.org, 2023/04/17
- [Bug ld/30354] Debug info is lost for functions only called from functions marked with cmse_nonsecure_entry, torbjorn.svensson at foss dot st.com, 2023/04/21
- [Bug ld/30354] Debug info is lost for functions only called from functions marked with cmse_nonsecure_entry, nickc at redhat dot com, 2023/04/26
- [Bug ld/30354] Debug info is lost for functions only called from functions marked with cmse_nonsecure_entry, nickc at redhat dot com, 2023/04/26