* elf32-s390.c (ELIMINATE_COPY_RELOCS): Define as one.

(elf_s390_adjust_dynamic_symbol): For weak symbols, copy
	ELF_LINK_NON_GOT_REF from weakdef.
	(elf_s390_copy_indirect_symbol): Test whether the weakdef sym has
	already been adjusted before treating it specially.
	* el64-s390.c: Likwise.
This commit is contained in:
Martin Schwidefsky
2003-05-09 15:29:47 +00:00
parent 82058a735b
commit 64285810f5
3 changed files with 99 additions and 36 deletions

View File

@ -1,3 +1,12 @@
2003-05-09 Martin Schwidefsky <schwidefsky@de.ibm.com>
* elf32-s390.c (ELIMINATE_COPY_RELOCS): Define as one.
(elf_s390_adjust_dynamic_symbol): For weak symbols, copy
ELF_LINK_NON_GOT_REF from weakdef.
(elf_s390_copy_indirect_symbol): Test whether the weakdef sym has
already been adjusted before treating it specially.
* el64-s390.c: Likwise.
2003-05-09 Martin Schwidefsky <schwidefsky@de.ibm.com> 2003-05-09 Martin Schwidefsky <schwidefsky@de.ibm.com>
* elf32-s390.c (allocate_dynrelocs): For undef weak syms with * elf32-s390.c (allocate_dynrelocs): For undef weak syms with

View File

@ -383,6 +383,12 @@ elf_s390_is_local_label_name (abfd, name)
#define ELF_DYNAMIC_INTERPRETER "/usr/lib/ld.so.1" #define ELF_DYNAMIC_INTERPRETER "/usr/lib/ld.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 the first entry in the procedure linkage table. */ /* The size in bytes of the first entry in the procedure linkage table. */
#define PLT_FIRST_ENTRY_SIZE 32 #define PLT_FIRST_ENTRY_SIZE 32
/* The size in bytes of an entry in the procedure linkage table. */ /* The size in bytes of an entry in the procedure linkage table. */
@ -828,6 +834,17 @@ elf_s390_copy_indirect_symbol (bed, dir, ind)
eind->tls_type = GOT_UNKNOWN; eind->tls_type = GOT_UNKNOWN;
} }
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); _bfd_elf_link_hash_copy_indirect (bed, dir, ind);
} }
@ -1149,7 +1166,8 @@ elf_s390_check_relocs (abfd, info, sec, relocs)
|| h->root.type == bfd_link_hash_defweak || h->root.type == bfd_link_hash_defweak
|| (h->elf_link_hash_flags || (h->elf_link_hash_flags
& ELF_LINK_HASH_DEF_REGULAR) == 0)))) & ELF_LINK_HASH_DEF_REGULAR) == 0))))
|| (!info->shared || (ELIMINATE_COPY_RELOCS
&& !info->shared
&& (sec->flags & SEC_ALLOC) != 0 && (sec->flags & SEC_ALLOC) != 0
&& h != NULL && h != NULL
&& (h->root.type == bfd_link_hash_defweak && (h->root.type == bfd_link_hash_defweak
@ -1480,8 +1498,6 @@ elf_s390_adjust_dynamic_symbol (info, h)
struct elf_link_hash_entry *h; struct elf_link_hash_entry *h;
{ {
struct elf_s390_link_hash_table *htab; struct elf_s390_link_hash_table *htab;
struct elf_s390_link_hash_entry * eh;
struct elf_s390_dyn_relocs *p;
asection *s; asection *s;
unsigned int power_of_two; unsigned int power_of_two;
@ -1527,6 +1543,10 @@ elf_s390_adjust_dynamic_symbol (info, h)
|| h->weakdef->root.type == bfd_link_hash_defweak); || h->weakdef->root.type == bfd_link_hash_defweak);
h->root.u.def.section = h->weakdef->root.u.def.section; h->root.u.def.section = h->weakdef->root.u.def.section;
h->root.u.def.value = h->weakdef->root.u.def.value; 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; return TRUE;
} }
@ -1552,6 +1572,11 @@ elf_s390_adjust_dynamic_symbol (info, h)
return TRUE; return TRUE;
} }
if (ELIMINATE_COPY_RELOCS)
{
struct elf_s390_link_hash_entry * eh;
struct elf_s390_dyn_relocs *p;
eh = (struct elf_s390_link_hash_entry *) h; eh = (struct elf_s390_link_hash_entry *) h;
for (p = eh->dyn_relocs; p != NULL; p = p->next) for (p = eh->dyn_relocs; p != NULL; p = p->next)
{ {
@ -1567,6 +1592,7 @@ elf_s390_adjust_dynamic_symbol (info, h)
h->elf_link_hash_flags &= ~ELF_LINK_NON_GOT_REF; h->elf_link_hash_flags &= ~ELF_LINK_NON_GOT_REF;
return TRUE; return TRUE;
} }
}
/* We must allocate the symbol in our .dynbss section, which will /* We must allocate the symbol in our .dynbss section, which will
become part of the .bss section of the executable. There will be become part of the .bss section of the executable. There will be
@ -1805,7 +1831,7 @@ allocate_dynrelocs (h, inf)
&& h->root.type == bfd_link_hash_undefweak) && h->root.type == bfd_link_hash_undefweak)
eh->dyn_relocs = NULL; eh->dyn_relocs = NULL;
} }
else else if (ELIMINATE_COPY_RELOCS)
{ {
/* For the non-shared case, discard space for relocs against /* For the non-shared case, discard space for relocs against
symbols which turn out to need copy relocs or are not symbols which turn out to need copy relocs or are not
@ -2497,7 +2523,8 @@ elf_s390_relocate_section (output_bfd, info, input_bfd, input_section,
&& (! info->symbolic && (! info->symbolic
|| (h->elf_link_hash_flags || (h->elf_link_hash_flags
& ELF_LINK_HASH_DEF_REGULAR) == 0)))) & ELF_LINK_HASH_DEF_REGULAR) == 0))))
|| (!info->shared || (ELIMINATE_COPY_RELOCS
&& !info->shared
&& h != NULL && h != NULL
&& h->dynindx != -1 && h->dynindx != -1
&& (h->elf_link_hash_flags & ELF_LINK_NON_GOT_REF) == 0 && (h->elf_link_hash_flags & ELF_LINK_NON_GOT_REF) == 0

View File

@ -405,6 +405,12 @@ elf_s390_is_local_label_name (abfd, name)
#define ELF_DYNAMIC_INTERPRETER "/usr/lib/ld.so.1" #define ELF_DYNAMIC_INTERPRETER "/usr/lib/ld.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 the first entry in the procedure linkage table. */ /* The size in bytes of the first entry in the procedure linkage table. */
#define PLT_FIRST_ENTRY_SIZE 32 #define PLT_FIRST_ENTRY_SIZE 32
/* The size in bytes of an entry in the procedure linkage table. */ /* The size in bytes of an entry in the procedure linkage table. */
@ -782,6 +788,17 @@ elf_s390_copy_indirect_symbol (bed, dir, ind)
eind->tls_type = GOT_UNKNOWN; eind->tls_type = GOT_UNKNOWN;
} }
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); _bfd_elf_link_hash_copy_indirect (bed, dir, ind);
} }
@ -1114,7 +1131,8 @@ elf_s390_check_relocs (abfd, info, sec, relocs)
|| h->root.type == bfd_link_hash_defweak || h->root.type == bfd_link_hash_defweak
|| (h->elf_link_hash_flags || (h->elf_link_hash_flags
& ELF_LINK_HASH_DEF_REGULAR) == 0)))) & ELF_LINK_HASH_DEF_REGULAR) == 0))))
|| (!info->shared || (ELIMINATE_COPY_RELOCS
&& !info->shared
&& (sec->flags & SEC_ALLOC) != 0 && (sec->flags & SEC_ALLOC) != 0
&& h != NULL && h != NULL
&& (h->root.type == bfd_link_hash_defweak && (h->root.type == bfd_link_hash_defweak
@ -1452,8 +1470,6 @@ elf_s390_adjust_dynamic_symbol (info, h)
struct elf_link_hash_entry *h; struct elf_link_hash_entry *h;
{ {
struct elf_s390_link_hash_table *htab; struct elf_s390_link_hash_table *htab;
struct elf_s390_link_hash_entry * eh;
struct elf_s390_dyn_relocs *p;
asection *s; asection *s;
unsigned int power_of_two; unsigned int power_of_two;
@ -1499,6 +1515,10 @@ elf_s390_adjust_dynamic_symbol (info, h)
|| h->weakdef->root.type == bfd_link_hash_defweak); || h->weakdef->root.type == bfd_link_hash_defweak);
h->root.u.def.section = h->weakdef->root.u.def.section; h->root.u.def.section = h->weakdef->root.u.def.section;
h->root.u.def.value = h->weakdef->root.u.def.value; 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; return TRUE;
} }
@ -1524,6 +1544,11 @@ elf_s390_adjust_dynamic_symbol (info, h)
return TRUE; return TRUE;
} }
if (ELIMINATE_COPY_RELOCS)
{
struct elf_s390_link_hash_entry * eh;
struct elf_s390_dyn_relocs *p;
eh = (struct elf_s390_link_hash_entry *) h; eh = (struct elf_s390_link_hash_entry *) h;
for (p = eh->dyn_relocs; p != NULL; p = p->next) for (p = eh->dyn_relocs; p != NULL; p = p->next)
{ {
@ -1539,6 +1564,7 @@ elf_s390_adjust_dynamic_symbol (info, h)
h->elf_link_hash_flags &= ~ELF_LINK_NON_GOT_REF; h->elf_link_hash_flags &= ~ELF_LINK_NON_GOT_REF;
return TRUE; return TRUE;
} }
}
/* We must allocate the symbol in our .dynbss section, which will /* We must allocate the symbol in our .dynbss section, which will
become part of the .bss section of the executable. There will be become part of the .bss section of the executable. There will be
@ -1777,7 +1803,7 @@ allocate_dynrelocs (h, inf)
&& h->root.type == bfd_link_hash_undefweak) && h->root.type == bfd_link_hash_undefweak)
eh->dyn_relocs = NULL; eh->dyn_relocs = NULL;
} }
else else if (ELIMINATE_COPY_RELOCS)
{ {
/* For the non-shared case, discard space for relocs against /* For the non-shared case, discard space for relocs against
symbols which turn out to need copy relocs or are not symbols which turn out to need copy relocs or are not
@ -2476,7 +2502,8 @@ elf_s390_relocate_section (output_bfd, info, input_bfd, input_section,
&& (! info->symbolic && (! info->symbolic
|| (h->elf_link_hash_flags || (h->elf_link_hash_flags
& ELF_LINK_HASH_DEF_REGULAR) == 0)))) & ELF_LINK_HASH_DEF_REGULAR) == 0))))
|| (!info->shared || (ELIMINATE_COPY_RELOCS
&& !info->shared
&& h != NULL && h != NULL
&& h->dynindx != -1 && h->dynindx != -1
&& (h->elf_link_hash_flags & ELF_LINK_NON_GOT_REF) == 0 && (h->elf_link_hash_flags & ELF_LINK_NON_GOT_REF) == 0