gold patch committed: Only relocate to comdat sections if same size
Ian Lance Taylor
iant@google.com
Fri Jul 17 05:36:00 GMT 2009
PR 10400 is about a case where gold is generating bogus debug info for
discarded comdat/linkonce sections. When the GNU linker sees a
relocation against a discarded section from a debugging section, it acts
as though the relocation were against the section that it kept, but only
if the kept section and the discarded section are the same size. gold
was doing the same, but it was not checking that the sections are the
same size.
This patch implements the same size check. It does it by only recording
the mapping from the discarded section to the kept section if the two
sections ar the same size. Since I was looking at the code, I cleaned
up a bunch of minor stuff along the way. I clarified the distinction
between whether the signature was added for a group (which can happen
for a linkonce section as well) and whether the section was itself a
group. I changed the mapping from section names to kept sections in a
group from a hash table to a std::map, since generally there will be
only one section in a comdat group. I changed Kept_section from a
struct to a class and added accessors and so forth. I changed the
interface to get_kept_comdat_section to use variables rather than
passing around a struct.
Ian
2009-07-16 Ian Lance Taylor <iant@google.com>
PR 10400
* layout.h: #include <map>.
(class Kept_section): Change from struct to class. Add accessors
and setters. Add section size to Comdat_group mapping. Change
Comdat_group to std::map. Add is_comdat_ field. Add
linkonce_size field in union.
(class Layout): Update declaration of find_or_add_kept_section.
Don't declare find_kept_object.
* layout.cc (Layout::find_or_add_kept_section): Remove candidate
parameter. Add object, shndx, is_comdat, and is_group_name
parameters. Change all callers. Adjust for new Kept_section.
(Layout::find_kept_object): Remove.
* object.cc (Sized_relobj::include_section_group): Update use of
Kept_section. Rename secnum to shndx. Only record
Kept_comdat_section if sections are the same size.
(Sized_relobj::include_linkonce_section): Update use of
Kept_section. Only record Kept_comdat_section if sections are the
same size. Set size of linkonce section.
(Sized_relobj::map_to_kept_section): Update call to
get_kept_comdat_section.
* object.h (class Sized_relobj): Rename fields in
Kept_comdat_section to drop trailing underscores; change object
field to Relobj*. Change Kept_comdat_section_table to store
struct rather than pointer.
(Sized_relobj::set_kept_comdat_section): Remove kept parameter.
Add kept_object and kept_shndx parameters. Change all callers.
(Sized_relobj::get_kept_comdat_section): Change return type to
bool. Add kept_object and kept_shndx parameters. Change all
callers.
* plugin.cc (Pluginobj::include_comdat_group): Update call to
Layout::find_or_add_kept_section.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: foo.patch
Type: text/x-patch
Size: 25974 bytes
Desc: Check section sizes for pretending relocs
URL: <https://sourceware.org/pipermail/binutils/attachments/20090717/6ab22ad5/attachment.bin>
More information about the Binutils
mailing list