This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [GOLD] override get_comdat_behavior
- From: Ian Lance Taylor <iant at google dot com>
- To: binutils at sourceware dot org
- Date: Wed, 17 Oct 2012 11:33:55 -0700
- Subject: Re: [GOLD] override get_comdat_behavior
- References: <20121017150249.GL4541@bubble.grove.modra.org>
On Wed, Oct 17, 2012 at 8:02 AM, Alan Modra <amodra@gmail.com> wrote:
> Powerpc use of .got2 section in -fPIC code can lead to "relocation
> refers to discarded section" warnings in testcases like gcc's
> g++.old-deja/g++.other/comdat5.C when comdat group sections for a
> function are dropped but not the function's .got2 entries. This type
> of problem shows up in other sections shared between functions on
> powerpc64, eg. .opd and .toc. Fixed by suppressing the warning the
> same way bfd ld does. OK to apply?
>
> * target-reloc.h (relocate_section): Call get_comdat_behavior
> from class Relocate.
> * arm.cc (Relocate::get_comdat_behavior): New.
> * i386.cc (Relocate::get_comdat_behavior): New.
> * sparc.cc (Relocate::get_comdat_behavior): New.
> * tilegx.cc (Relocate::get_comdat_behavior): New.
> * x86_64.cc (Relocate::get_comdat_behavior): New.
> * powerpc.cc (Relocate::get_comdat_behavior): New.
> (Target_powerpc::relocate_section): Don't zap opd relocs.
You can implement this without requiring every target to have a
trivial get_comdat_behavior method. Add a new template parameter to
relocate_section in target-reloc.h. Give it a default value.
template<..., typename Relocate_omdat_behaviour = Default_comdat_behavior>
inline void
Relocate_section(...)
Add a local variable
Relocate_comdat_behavior comdat_behavior;
Change the calls to get_comdat_behavior() to call comdat_behavior.get().
Change the function get_comdat_behavior to
class Default_comdat_behavior
{
public:
Comdat_behavior
get(const char *name)
{
// Same implementation.
}
};
At this point all the target should work with the old behavior. Now
change the call to relocate_section in powerpc.cc to pass
Powerpc_comdat_behavior as the last template argument. Write that
class with a get method that does what you want.
All untested, obviously.
Ian