This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: non_got_ref after adjust_dynamic_relocs
On Wed, Nov 22, 2017 at 01:43:33PM +1030, Alan Modra wrote:
> On Tue, Nov 21, 2017 at 10:52:18PM +0000, Joseph Myers wrote:
> > This commit (529fe20eeb0030ea5d653d0ebec433f9e3145874) breaks building the
> > glibc testsuite for powerpc-linux-gnu (32-bit only, I think). I see a
> > link failure very early in "make check":
> >
> > /scratch/jmyers/glibc/many8/build/glibcs/powerpc-linux-gnu/glibc/support/libsupport_nonshared.a(support_test_main.oS):(.got2+0x34): unresolvable R_PPC_ADDR32 relocation against symbol `program_invocation_short_name@@GLIBC_2.0'
> > /scratch/jmyers/glibc/many8/install/compilers/powerpc-linux-gnu/lib/gcc/powerpc-glibc-linux-gnu/8.0.0/../../../../powerpc-glibc-linux-gnu/bin/ld: final link failed: Nonrepresentable section on output
> > collect2: error: ld returned 1 exit status
> > ../Rules:202: recipe for target '/scratch/jmyers/glibc/many8/build/glibcs/powerpc-linux-gnu/glibc/csu/test-as-const-locale-defines' failed
>
> Thanks for the report. I'm sure I tested a powerpc-linux glibc build
> when developing the patch, but it seems likely I didn't retest some
> last-minute changes. The trigger is a symbol with a weakdef (ie. weak
> symbol with an alias), and the bug is clearing non_got_ref in
> allocate_dynrelocs when dyn_relocs is NULL. I could just revert the
> last-minute changes, but I'd like to spend a little time thinking over
> what is best to do here.
If I don't find a better solution, the following reverts those
last-minute changes.
diff --git a/bfd/elf32-hppa.c b/bfd/elf32-hppa.c
index 7fc447e..266b49e 100644
--- a/bfd/elf32-hppa.c
+++ b/bfd/elf32-hppa.c
@@ -2006,10 +2006,7 @@ allocate_dynrelocs (struct elf_link_hash_entry *eh, void *inf)
hh->dyn_relocs = NULL;
if (hh->dyn_relocs == NULL)
- {
- eh->non_got_ref = 0;
- return TRUE;
- }
+ return TRUE;
/* If this is a -Bsymbolic shared link, then we need to discard all
space allocated for dynamic pc-relative relocs against symbols
@@ -3912,7 +3909,10 @@ elf32_hppa_relocate_section (bfd *output_bfd,
|| (ELIMINATE_COPY_RELOCS
&& !bfd_link_pic (info)
&& hh != NULL
- && hh->eh.non_got_ref))
+ && hh->eh.dynamic_adjusted
+ && hh->eh.non_got_ref
+ && !hh->eh.def_regular
+ && !ELF_COMMON_DEF_P (&hh->eh)))
{
Elf_Internal_Rela outrel;
bfd_boolean skip;
diff --git a/bfd/elf32-ppc.c b/bfd/elf32-ppc.c
index f68a7a4..cc89ea6 100644
--- a/bfd/elf32-ppc.c
+++ b/bfd/elf32-ppc.c
@@ -5912,7 +5912,7 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
eh->dyn_relocs = NULL;
if (eh->dyn_relocs == NULL)
- h->non_got_ref = 0;
+ ;
/* In the shared -Bsymbolic case, discard space allocated for
dynamic pc-relative relocs against symbols which turn out to be
@@ -8766,7 +8766,14 @@ ppc_elf_relocate_section (bfd *output_bfd,
|| (ELIMINATE_COPY_RELOCS
&& !bfd_link_pic (info)
&& h != NULL
- && h->non_got_ref))
+ && h->dynamic_adjusted
+ && h->non_got_ref
+ && !h->def_regular
+ && !ELF_COMMON_DEF_P (h)
+ && !(h->protected_def
+ && ppc_elf_hash_entry (h)->has_addr16_ha
+ && ppc_elf_hash_entry (h)->has_addr16_lo
+ && htab->params->pic_fixup > 0)))
{
int skip;
bfd_byte *loc;
--
Alan Modra
Australia Development Lab, IBM