https://sourceware.org/bugzilla/show_bug.cgi?id=33370
--- Comment #4 from Fangrui Song <i at maskray dot me> ---
(In reply to Indu Bhagat from comment #3)
> I think the core issue is that SFrame sections (section type SHT_GNU_SFRAME)
> need to be merged and not concatenated by the linker. An abiding linker
> should also then remove SFrame data corresponding to a discarded symbol.
A design that permits concatenated components would be a more robust approach
and fits into the ELF spirit well.
Modern metadata sections should move beyond the .eh_frame style hack.
When a.o:inl and b.o:inl are COMDAT groups with the same signature, and a.o:inl
is the prevailing copy, does GNU ld discard the '.sframe' element that
describes b.o:inl?
This is a crucial in cases of ODR (One Definition Rule) violation, where it's
essential to retain the metadata for the prevailing copy.
---
In the following example, does linker garbage collection properly discard the
.sframe element that describes `unused`?
% cat a.cc
[[gnu::noinline]] inline int inl() { return 0; }
int unused() { return 1; }
extern "C" void _start() {
inl();
}
% $HOME/Dev/binutils-gdb/out/debug/bin/ld --version | head -n 1
GNU ld (GNU Binutils) 2.45.50.20250905
% ~/opt/gcc-15/bin/g++ -B$HOME/Dev/binutils-gdb/out/debug/bin
-ffunction-sections -Wa,--gsframe -c a.cc
% ~/Dev/binutils-gdb/out/debug/ld/ld-new a.o --gc-sections --print-gc-sections
/home/ray/Dev/binutils-gdb/out/debug/ld/ld-new: removing unused section
'.sframe' in file 'a.o'
This seems worse than I thought. .sframe is just entirely discarded.
If the .sframe element for `unused` is in a separate section (a la
__patchable_function_entries), and it has SHF_LINK_ORDER flag, the default
linker garbage collection will discard it.
In a generic linker design, section content finalization occurs after COMDAT
section deduplication and section based garbage collection.
This allows for smart, linker-generated content to function correctly alongside
standard ELF features. We could further reduce .sframe content if the linker
wants to implement such features.
--
You are receiving this mail because:
You are on the CC list for the bug.