https://sourceware.org/bugzilla/show_bug.cgi?id=19446
--- Comment #10 from Nick Clifton <nickc at redhat dot com> --- Hi Xinliangli, > However I do think ld's behavior is > not correct here. Should linker first decide if some sections are 'root' > sections that should not be throw away and then decide if other sections > should > be GCed? Here linker first prunes the references and then is forced to discard > section not because it should do so, but to make the link succeed. Yes, but... the linker has not been told that the UNREF section is a root section. If the test had used a linker script that specified that the UNREF section should be kept[1] then the linker would have acted differently. It would keep the UNREF section and g0 variable and everything would have worked as expected. Since however the UNREF section is an orphan section, the linker has more latitude in what it can do. The LD linker decides that since the section has relocations against it, and since these relocations refers to symbols which are otherwise unused, then it makes sense to discard the section. You disagree with this decision. I don't. But since there are several available workarounds, and, as far as I know, it is not breaking real programs, I do not plan to make any changes to the linker. Cheers Nick [1] ie: UNREF : { KEEP (*(UNREF)) } -- 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