[PATCH,plugins,head+2.21] Handle COMDAT groups on ELF.
Sat May 7 15:06:00 GMT 2011
On Sat, May 7, 2011 at 7:52 AM, Dave Korn <firstname.lastname@example.org> wrote:
> Hi again,
> One of the advantages of the two-stage-link tear-down-and-rebuild approach
> was that we got COMDAT group selection correct for free, as a consequence of
> resetting the already-linked table. Since we're not doing that now, we have
> to handle COMDAT in the linker plugin code by creating synthetic .group
> sections in the dummy IR BFD, but making sure that these sections don't
> actually win in group selection decisions.
> That's what this patch implements, and on x86_64-linux, with this, we now
> get a completely clean GCC testrun (entire c-family and fortran), which brings
> ld.bfd into parity with ld.gold. :-)
> 2011-05-07 Dave Korn <dave.korn.cygwin@...
> * elflink.c (elf_link_add_object_symbols): Don't mark symbols undef
> when the kept section comes from a plugin BFD that we expect to be
> replaced later.
> (_bfd_elf_section_already_linked): When there is a duplicate section,
> but the initial kept section comes from a plugin BFD and the newer
> duplicate section does not, keep the newer one and discard the initial
> kept section.
> * plugin.c (struct group_sec_hash_table): New derived hash table type.
> (struct group_sec_hash_entry): Derived entry type for the above.
> (group_sec_hash_newfunc): Derived ctor for the table entries creates
> an ELF comdat group section with the given signature.
> (init_group_sec_hash_table): Derived ctor for the table.
> (group_sec_hash_lookup): Derived lookup function.
> (group_sec_hash_traverse): Derived traverse function.
> (group_sec_hash_table_free): Derived dtor.
> (struct add_syms_info): Helper struct to wrap args to callback.
> (get_elf_comdat_section): New helper function for ELF targets.
> (get_comdat_section): Likewise for all targets.
> (asymbol_from_plugin_symbol): Take an add_syms_info rather than a
> bfd pointer argument and adjust usage accordingly. Generate comdat
> sections or groups for defined symbols with non-NULL comdat_key.
> (add_symbols): Wrap parameters to pass down in an add_syms_info, and
> handle ELF comdat group section creation.
> Tested on x86_64-unknown-linux-gnu as mentioned. I'm going to start running
> a GCC testsuite on i686-pc-cygwin, but that could take a couple of days for
> the final results to come in. If this patch is OK, I'll wait until that's got
> far enough to be sure it's working before I commit.
> Any comments on the implementation, while we're waiting? Or OK as it is?
Do you have a testcase to show it fails without your change?
More information about the Binutils