https://sourceware.org/bugzilla/show_bug.cgi?id=22677
Nick Clifton <nickc at redhat dot com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |nickc at redhat dot com --- Comment #2 from Nick Clifton <nickc at redhat dot com> --- (In reply to David Leonard from comment #0) Hi David, > "ld -r --gc-collect" drops the .init_array/.fini_array sections, although it > preserves .init, .fini and the .preinit_array sections. It should probably > KEEP() the .init_array/.fini_array sections too? (And others?) Indeed it should. > There doesn't seem to be a clean indirect way to make --gc-collect keep the > .{init,fini}_array sections. A (noisy) workaround is to add this linker > script as an argument: > > SECTIONS { > .init_array : { KEEP (*(.init_array)) } > .fini_array : { KEEP (*(.fini_array)) } > } This appears to be an artifact of the linker that you are using. If you build an x86_64 linker using the FSF sources and run "ld --verbose" you should see this as part of the output: .init_array : { PROVIDE_HIDDEN (__init_array_start = .); KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*))) KEEP (*(.init_array EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .ctors)) PROVIDE_HIDDEN (__init_array_end = .); } So the input sections should survive garbage collection. I think however that the ubuntu version of the linker that you are using may have its own, different built-in linker script, without the KEEP statements. Please could you check ? If I am right, then you need to complain to Ubuntu and not us... Cheers Nick -- You are receiving this mail because: You are on the CC list for the bug. _______________________________________________ bug-binutils mailing list bug-binutils@gnu.org https://lists.gnu.org/mailman/listinfo/bug-binutils