summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Modra <amodra@bigpond.net.au>2003-03-06 23:26:20 +0000
committerAlan Modra <amodra@bigpond.net.au>2003-03-06 23:26:20 +0000
commita8f761c9f27565e00558412030fee8580a884033 (patch)
tree78156c491221981e38e9509f77753d1029903882
parentfdec05e696c26d2c0a072118e08027aebbf134de (diff)
downloadbinutils-redhat-a8f761c9f27565e00558412030fee8580a884033.tar.gz
* elf32-ppc.c (ELIMINATE_COPY_RELOCS): Define as one.
(ppc_elf_adjust_dynamic_symbol): For weak symbols, copy ELF_LINK_NON_GOT_REF from weakdef. * elf64-ppc.c (ELIMINATE_COPY_RELOCS): Define as one. (ppc64_elf_adjust_dynamic_symbol): For weak symbols, copy ELF_LINK_NON_GOT_REF from weakdef. * elf32-i386.c (ELIMINATE_COPY_RELOCS): Define as one. Use throughout. (elf_i386_adjust_dynamic_symbol): For weak symbols, copy ELF_LINK_NON_GOT_REF from weakdef.
-rw-r--r--bfd/ChangeLog12
-rw-r--r--bfd/elf32-i386.c50
-rw-r--r--bfd/elf32-ppc.c6
-rw-r--r--bfd/elf64-ppc.c6
4 files changed, 55 insertions, 19 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 341e629429..fc7bfb9763 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,15 @@
+2003-03-07 Alan Modra <amodra@bigpond.net.au>
+
+ * elf32-ppc.c (ELIMINATE_COPY_RELOCS): Define as one.
+ (ppc_elf_adjust_dynamic_symbol): For weak symbols, copy
+ ELF_LINK_NON_GOT_REF from weakdef.
+ * elf64-ppc.c (ELIMINATE_COPY_RELOCS): Define as one.
+ (ppc64_elf_adjust_dynamic_symbol): For weak symbols, copy
+ ELF_LINK_NON_GOT_REF from weakdef.
+ * elf32-i386.c (ELIMINATE_COPY_RELOCS): Define as one. Use throughout.
+ (elf_i386_adjust_dynamic_symbol): For weak symbols, copy
+ ELF_LINK_NON_GOT_REF from weakdef.
+
2003-03-06 Jakub Jelinek <jakub@redhat.com>
Andrew Haley <aph@redhat.com>
diff --git a/bfd/elf32-i386.c b/bfd/elf32-i386.c
index a751d98285..eae3190c42 100644
--- a/bfd/elf32-i386.c
+++ b/bfd/elf32-i386.c
@@ -506,6 +506,12 @@ elf_i386_grok_psinfo (abfd, note)
#define ELF_DYNAMIC_INTERPRETER "/usr/lib/libc.so.1"
+/* If ELIMINATE_COPY_RELOCS is non-zero, the linker will try to avoid
+ copying dynamic variables from a shared lib into an app's dynbss
+ section, and instead use a dynamic relocation to point into the
+ shared lib. */
+#define ELIMINATE_COPY_RELOCS 1
+
/* The size in bytes of an entry in the procedure linkage table. */
#define PLT_ENTRY_SIZE 16
@@ -1106,7 +1112,8 @@ elf_i386_check_relocs (abfd, info, sec, relocs)
|| h->root.type == bfd_link_hash_defweak
|| (h->elf_link_hash_flags
& ELF_LINK_HASH_DEF_REGULAR) == 0))))
- || (!info->shared
+ || (ELIMINATE_COPY_RELOCS
+ && !info->shared
&& (sec->flags & SEC_ALLOC) != 0
&& h != NULL
&& (h->root.type == bfd_link_hash_defweak
@@ -1372,8 +1379,6 @@ elf_i386_adjust_dynamic_symbol (info, h)
struct elf_link_hash_entry *h;
{
struct elf_i386_link_hash_table *htab;
- struct elf_i386_link_hash_entry * eh;
- struct elf_i386_dyn_relocs *p;
asection *s;
unsigned int power_of_two;
@@ -1418,6 +1423,10 @@ elf_i386_adjust_dynamic_symbol (info, h)
|| h->weakdef->root.type == bfd_link_hash_defweak);
h->root.u.def.section = h->weakdef->root.u.def.section;
h->root.u.def.value = h->weakdef->root.u.def.value;
+ if (ELIMINATE_COPY_RELOCS || info->nocopyreloc)
+ h->elf_link_hash_flags
+ = ((h->elf_link_hash_flags & ~ELF_LINK_NON_GOT_REF)
+ | (h->weakdef->elf_link_hash_flags & ELF_LINK_NON_GOT_REF));
return TRUE;
}
@@ -1443,20 +1452,26 @@ elf_i386_adjust_dynamic_symbol (info, h)
return TRUE;
}
- eh = (struct elf_i386_link_hash_entry *) h;
- for (p = eh->dyn_relocs; p != NULL; p = p->next)
+ if (ELIMINATE_COPY_RELOCS)
{
- s = p->sec->output_section;
- if (s != NULL && (s->flags & SEC_READONLY) != 0)
- break;
- }
+ struct elf_i386_link_hash_entry * eh;
+ struct elf_i386_dyn_relocs *p;
- /* If we didn't find any dynamic relocs in read-only sections, then
- we'll be keeping the dynamic relocs and avoiding the copy reloc. */
- if (p == NULL)
- {
- h->elf_link_hash_flags &= ~ELF_LINK_NON_GOT_REF;
- return TRUE;
+ eh = (struct elf_i386_link_hash_entry *) h;
+ for (p = eh->dyn_relocs; p != NULL; p = p->next)
+ {
+ s = p->sec->output_section;
+ if (s != NULL && (s->flags & SEC_READONLY) != 0)
+ break;
+ }
+
+ /* If we didn't find any dynamic relocs in read-only sections, then
+ we'll be keeping the dynamic relocs and avoiding the copy reloc. */
+ if (p == NULL)
+ {
+ h->elf_link_hash_flags &= ~ELF_LINK_NON_GOT_REF;
+ return TRUE;
+ }
}
/* We must allocate the symbol in our .dynbss section, which will
@@ -1676,7 +1691,7 @@ allocate_dynrelocs (h, inf)
}
}
}
- else
+ else if (ELIMINATE_COPY_RELOCS)
{
/* For the non-shared case, discard space for relocs against
symbols which turn out to need copy relocs or are not
@@ -2412,7 +2427,8 @@ elf_i386_relocate_section (output_bfd, info, input_bfd, input_section,
&& (! info->symbolic
|| (h->elf_link_hash_flags
& ELF_LINK_HASH_DEF_REGULAR) == 0))))
- || (!info->shared
+ || (ELIMINATE_COPY_RELOCS
+ && !info->shared
&& h != NULL
&& h->dynindx != -1
&& (h->elf_link_hash_flags & ELF_LINK_NON_GOT_REF) == 0
diff --git a/bfd/elf32-ppc.c b/bfd/elf32-ppc.c
index 236ed90ae0..d51c66cd6f 100644
--- a/bfd/elf32-ppc.c
+++ b/bfd/elf32-ppc.c
@@ -2455,7 +2455,7 @@ ppc_elf_create_dynamic_sections (abfd, info)
copying dynamic variables from a shared lib into an app's dynbss
section, and instead use a dynamic relocation to point into the
shared lib. */
-#define ELIMINATE_COPY_RELOCS 0
+#define ELIMINATE_COPY_RELOCS 1
/* Adjust a symbol defined by a dynamic object and referenced by a
regular object. The current definition is in some section of the
@@ -2525,6 +2525,10 @@ ppc_elf_adjust_dynamic_symbol (info, h)
|| h->weakdef->root.type == bfd_link_hash_defweak);
h->root.u.def.section = h->weakdef->root.u.def.section;
h->root.u.def.value = h->weakdef->root.u.def.value;
+ if (ELIMINATE_COPY_RELOCS)
+ h->elf_link_hash_flags
+ = ((h->elf_link_hash_flags & ~ELF_LINK_NON_GOT_REF)
+ | (h->weakdef->elf_link_hash_flags & ELF_LINK_NON_GOT_REF));
return TRUE;
}
diff --git a/bfd/elf64-ppc.c b/bfd/elf64-ppc.c
index 5963e97fdd..1030e69b7d 100644
--- a/bfd/elf64-ppc.c
+++ b/bfd/elf64-ppc.c
@@ -2545,7 +2545,7 @@ struct plt_entry
copying dynamic variables from a shared lib into an app's dynbss
section, and instead use a dynamic relocation to point into the
shared lib. */
-#define ELIMINATE_COPY_RELOCS 0
+#define ELIMINATE_COPY_RELOCS 1
/* Section name for stubs is the associated section name plus this
string. */
@@ -4518,6 +4518,10 @@ ppc64_elf_adjust_dynamic_symbol (info, h)
|| h->weakdef->root.type == bfd_link_hash_defweak);
h->root.u.def.section = h->weakdef->root.u.def.section;
h->root.u.def.value = h->weakdef->root.u.def.value;
+ if (ELIMINATE_COPY_RELOCS)
+ h->elf_link_hash_flags
+ = ((h->elf_link_hash_flags & ~ELF_LINK_NON_GOT_REF)
+ | (h->weakdef->elf_link_hash_flags & ELF_LINK_NON_GOT_REF));
return TRUE;
}