https://sourceware.org/bugzilla/show_bug.cgi?id=33370

--- Comment #5 from Indu Bhagat <indu.bhagat at oracle dot com> ---
(In reply to Fangrui Song from comment #4)
> (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.
> 

Yes, I tested a bit. GNU ld will discard SFrame FDE for the respective
discarded symbol.

> ---
> 
> 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.
> 

Yes, the --gc-sections issue is tracked here
https://sourceware.org/bugzilla/show_bug.cgi?id=33370. I plan to fix it before
2.46 release.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

Reply via email to