gold patch committed: Change handling for globals in discarded sections
Ian Lance Taylor
iant@google.com
Sat Jan 9 00:20:00 GMT 2010
The GNU linker has special handling for symbols defined in discarded
sections. If the reference is from a debugging section, the GNU
linker does not warn. I believe that this was initially introduced
for comdat aka linkonce sections, where one can assume that there will
be another definition somewhere. However, it turns out that it also
applies to sections explicitly discarded by the linker script.
The Linux kernel build currently relies on this behaviour. The kernel
build defines a bunch of per-cpu symbols in a section which is later
discarded. This is fine except that references to the symbols remain
in the debug info. The GNU linker said nothing about this, but gold
gave errors.
I've committed this patch to gold to make it act like the GNU linker
with regard to not warning about references from debugging sections to
global symbols defined in discarded sections. This should fix the
kernel build.
When I worked on this I also took the opportunity to eliminate a flag
from the Symbol structure, making it 4 bytes smaller on a 32-bit host.
Ian
2010-01-08 Ian Lance Taylor <iant@google.com>
PR 11108
* symtab.h (class Symbol): Remove fields is_target_special_ and
has_plt_offset_. Add field is_defined_in_discarded_section_.
(Symbol::is_defined_in_discarded_section): New function.
(Symbol::set_is_defined_in_discarded_section): New function.
(Symbol::has_plt_offset): Rewrite.
(Symbol::set_plt_offset): Verify that new offset is not -1U.
* symtab.cc (Symbol::init_fields): Initialize plt_offset_ to -1U.
Don't initialize is_target_special_ or has_plt_offset_.
Initialize is_defined_in_discarded_section_.
(Symbol_table::add_from_relobj): If appropriate, set
is_defined_in_discarded_section.
* resolve.cc (Symbol::override_base_with_special): Don't test
is_target_special_. Change has_plt_offset_ to has_plt_offset().
* target-reloc.h (relocate_section): Do special handling for
symbols defined in discarded sections for global symbols as well
as local symbols.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: foo.patch
Type: text/x-diff
Size: 12825 bytes
Desc: discarded
URL: <https://sourceware.org/pipermail/binutils/attachments/20100109/9ea143a9/attachment.bin>
More information about the Binutils
mailing list