summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Modra <amodra@bigpond.net.au>2003-05-01 10:22:46 +0000
committerAlan Modra <amodra@bigpond.net.au>2003-05-01 10:22:46 +0000
commite59b208a32047d75b57ae11c24bf1619b1d07ad2 (patch)
tree08303a530bb73ea8d4a0447386bceda05e26b922
parent47575a180dcb3372f6e0db2ca46a0f013217a908 (diff)
downloadgdb-e59b208a32047d75b57ae11c24bf1619b1d07ad2.tar.gz
* elf32-ppc.c (ppc_elf_copy_indirect_symbol): Test whether the
weakdef sym has already been adjusted before treating it specially. * elf32-i386.c (elf_i386_copy_indirect_symbol): Don't copy ELF_LINK_NON_GOT_REF for weakdefs when symbol already adjusted. * elf64-ppc.c (ppc64_elf_copy_indirect_symbol): Likewise. (ppc64_elf_check_relocs): Set ELF_LINK_NON_GOT_REF.
-rw-r--r--bfd/ChangeLog10
-rw-r--r--bfd/elf32-i386.c14
-rw-r--r--bfd/elf32-ppc.c4
-rw-r--r--bfd/elf64-ppc.c27
4 files changed, 41 insertions, 14 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 34883f6f660..93b7fda83b9 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,7 +1,11 @@
-2003-04-30 Nick Clifton <nickc@redhat.com>
+2003-05-01 Alan Modra <amodra@bigpond.net.au>
- * elf32-h8300.c (elf32_h8_relax_section): Do not crash when
- encountering relocs against the *ABS* section.
+ * elf32-ppc.c (ppc_elf_copy_indirect_symbol): Test whether the
+ weakdef sym has already been adjusted before treating it specially.
+ * elf32-i386.c (elf_i386_copy_indirect_symbol): Don't copy
+ ELF_LINK_NON_GOT_REF for weakdefs when symbol already adjusted.
+ * elf64-ppc.c (ppc64_elf_copy_indirect_symbol): Likewise.
+ (ppc64_elf_check_relocs): Set ELF_LINK_NON_GOT_REF.
2003-04-28 H.J. Lu <hjl@gnu.org>
diff --git a/bfd/elf32-i386.c b/bfd/elf32-i386.c
index 4f6bd80b58e..060d66c20ce 100644
--- a/bfd/elf32-i386.c
+++ b/bfd/elf32-i386.c
@@ -838,7 +838,19 @@ elf_i386_copy_indirect_symbol (bed, dir, ind)
edir->tls_type = eind->tls_type;
eind->tls_type = GOT_UNKNOWN;
}
- _bfd_elf_link_hash_copy_indirect (bed, dir, ind);
+
+ if (ELIMINATE_COPY_RELOCS
+ && ind->root.type != bfd_link_hash_indirect
+ && (dir->elf_link_hash_flags & ELF_LINK_HASH_DYNAMIC_ADJUSTED) != 0)
+ /* If called to transfer flags for a weakdef during processing
+ of elf_adjust_dynamic_symbol, don't copy ELF_LINK_NON_GOT_REF.
+ We clear it ourselves for ELIMINATE_COPY_RELOCS. */
+ dir->elf_link_hash_flags |=
+ (ind->elf_link_hash_flags & (ELF_LINK_HASH_REF_DYNAMIC
+ | ELF_LINK_HASH_REF_REGULAR
+ | ELF_LINK_HASH_REF_REGULAR_NONWEAK));
+ else
+ _bfd_elf_link_hash_copy_indirect (bed, dir, ind);
}
static int
diff --git a/bfd/elf32-ppc.c b/bfd/elf32-ppc.c
index 22cff53c1fa..69bb0d676e0 100644
--- a/bfd/elf32-ppc.c
+++ b/bfd/elf32-ppc.c
@@ -374,7 +374,9 @@ ppc_elf_copy_indirect_symbol (bed, dir, ind)
edir->tls_mask |= eind->tls_mask;
- if (ELIMINATE_COPY_RELOCS && ind->root.type != bfd_link_hash_indirect)
+ if (ELIMINATE_COPY_RELOCS
+ && ind->root.type != bfd_link_hash_indirect
+ && (dir->elf_link_hash_flags & ELF_LINK_HASH_DYNAMIC_ADJUSTED) != 0)
/* If called to transfer flags for a weakdef during processing
of elf_adjust_dynamic_symbol, don't copy ELF_LINK_NON_GOT_REF.
We clear it ourselves for ELIMINATE_COPY_RELOCS. */
diff --git a/bfd/elf64-ppc.c b/bfd/elf64-ppc.c
index 29c90fe32e4..1e7a498dab3 100644
--- a/bfd/elf64-ppc.c
+++ b/bfd/elf64-ppc.c
@@ -3272,6 +3272,7 @@ ppc64_elf_copy_indirect_symbol (bed, dir, ind)
struct elf_link_hash_entry *dir, *ind;
{
struct ppc_link_hash_entry *edir, *eind;
+ flagword mask;
edir = (struct ppc_link_hash_entry *) dir;
eind = (struct ppc_link_hash_entry *) ind;
@@ -3316,20 +3317,24 @@ ppc64_elf_copy_indirect_symbol (bed, dir, ind)
edir->is_entry |= eind->is_entry;
edir->tls_mask |= eind->tls_mask;
- /* Copy down any references that we may have already seen to the
- symbol which just became indirect. */
- edir->elf.elf_link_hash_flags |=
- (eind->elf.elf_link_hash_flags
- & (ELF_LINK_HASH_REF_DYNAMIC
- | ELF_LINK_HASH_REF_REGULAR
- | ELF_LINK_HASH_REF_REGULAR_NONWEAK
- | ELF_LINK_NON_GOT_REF));
+ mask = (ELF_LINK_HASH_REF_DYNAMIC | ELF_LINK_HASH_REF_REGULAR
+ | ELF_LINK_HASH_REF_REGULAR_NONWEAK | ELF_LINK_NON_GOT_REF);
+ /* If called to transfer flags for a weakdef during processing
+ of elf_adjust_dynamic_symbol, don't copy ELF_LINK_NON_GOT_REF.
+ We clear it ourselves for ELIMINATE_COPY_RELOCS. */
+ if (ELIMINATE_COPY_RELOCS
+ && eind->elf.root.type != bfd_link_hash_indirect
+ && (edir->elf.elf_link_hash_flags & ELF_LINK_HASH_DYNAMIC_ADJUSTED) != 0)
+ mask &= ~ELF_LINK_NON_GOT_REF;
+
+ edir->elf.elf_link_hash_flags |= eind->elf.elf_link_hash_flags & mask;
/* If we were called to copy over info for a weak sym, that's all. */
if (eind->elf.root.type != bfd_link_hash_indirect)
return;
- /* Copy over got entries. */
+ /* Copy over got entries that we may have already seen to the
+ symbol which just became indirect. */
if (eind->elf.got.glist != NULL)
{
if (edir->elf.got.glist != NULL)
@@ -3877,6 +3882,10 @@ ppc64_elf_check_relocs (abfd, info, sec, relocs)
case R_PPC64_UADDR32:
case R_PPC64_UADDR64:
case R_PPC64_TOC:
+ if (h != NULL && !info->shared)
+ /* We may need a copy reloc. */
+ h->elf_link_hash_flags |= ELF_LINK_NON_GOT_REF;
+
/* Don't propagate .opd relocs. */
if (NO_OPD_RELOCS && opd_sym_map != NULL)
break;