From 82058a735bbff6d114ab25e828e9c500abea87ac Mon Sep 17 00:00:00 2001 From: Martin Schwidefsky Date: Fri, 9 May 2003 15:17:54 +0000 Subject: * elf32-s390.c (allocate_dynrelocs): For undef weak syms with non-default visibility, a) don't make them dynamic, b) discard space for dynamic relocs. (elf_s390_relocate_section): Initialize the GOT entries and skip R_390_{8,16,32}/R_390_PC{16,16DBL,32DBL,32} for weak undefined symbols with non-default visibility. * elf64-s390.c: Likewise. --- bfd/ChangeLog | 10 ++++++++++ bfd/elf32-s390.c | 25 +++++++++++++++++++++---- bfd/elf64-s390.c | 25 +++++++++++++++++++++---- 3 files changed, 52 insertions(+), 8 deletions(-) (limited to 'bfd') diff --git a/bfd/ChangeLog b/bfd/ChangeLog index b9fb970..ff0e7e2 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,13 @@ +2003-05-09 Martin Schwidefsky + + * elf32-s390.c (allocate_dynrelocs): For undef weak syms with + non-default visibility, a) don't make them dynamic, b) discard + space for dynamic relocs. + (elf_s390_relocate_section): Initialize the GOT entries and skip + R_390_{8,16,32}/R_390_PC{16,16DBL,32DBL,32} for weak undefined + symbols with non-default visibility. + * elf64-s390.c: Likewise. + 2003-05-09 Alan Modra * cpu-arm.c (arm_check_note): Warning fix. diff --git a/bfd/elf32-s390.c b/bfd/elf32-s390.c index 857b7a0..0ee371a 100644 --- a/bfd/elf32-s390.c +++ b/bfd/elf32-s390.c @@ -1651,7 +1651,9 @@ allocate_dynrelocs (h, inf) htab = elf_s390_hash_table (info); if (htab->elf.dynamic_sections_created - && h->plt.refcount > 0) + && h->plt.refcount > 0 + && (ELF_ST_VISIBILITY (h->other) == STV_DEFAULT + || h->root.type != bfd_link_hash_undefweak)) { /* Make sure this symbol is output as a dynamic symbol. Undefined weak syms won't yet be marked as dynamic. */ @@ -1662,7 +1664,8 @@ allocate_dynrelocs (h, inf) return FALSE; } - if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (1, info, h)) + if (info->shared + || WILL_CALL_FINISH_DYNAMIC_SYMBOL (1, info, h)) { asection *s = htab->splt; @@ -1758,7 +1761,10 @@ allocate_dynrelocs (h, inf) htab->srelgot->_raw_size += sizeof (Elf32_External_Rela); else if (tls_type == GOT_TLS_GD) htab->srelgot->_raw_size += 2 * sizeof (Elf32_External_Rela); - else if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, info, h)) + else if ((ELF_ST_VISIBILITY (h->other) == STV_DEFAULT + || h->root.type != bfd_link_hash_undefweak) + && (info->shared + || WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, 0, h))) htab->srelgot->_raw_size += sizeof (Elf32_External_Rela); } else @@ -1792,6 +1798,12 @@ allocate_dynrelocs (h, inf) pp = &p->next; } } + + /* Also discard relocs on undefined weak syms with non-default + visibility. */ + if (ELF_ST_VISIBILITY (h->other) != STV_DEFAULT + && h->root.type == bfd_link_hash_undefweak) + eh->dyn_relocs = NULL; } else { @@ -2306,7 +2318,9 @@ elf_s390_relocate_section (output_bfd, info, input_bfd, input_section, && (info->symbolic || h->dynindx == -1 || (h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL)) - && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR))) + && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR)) + || (ELF_ST_VISIBILITY (h->other) + && h->root.type == bfd_link_hash_undefweak)) { /* This is actually a static link, or it is a -Bsymbolic link and the symbol is defined @@ -2471,6 +2485,9 @@ elf_s390_relocate_section (output_bfd, info, input_bfd, input_section, break; if ((info->shared + && (h == NULL + || ELF_ST_VISIBILITY (h->other) == STV_DEFAULT + || h->root.type != bfd_link_hash_undefweak) && ((r_type != R_390_PC16 && r_type != R_390_PC16DBL && r_type != R_390_PC32DBL diff --git a/bfd/elf64-s390.c b/bfd/elf64-s390.c index 37fcf72..1c10643 100644 --- a/bfd/elf64-s390.c +++ b/bfd/elf64-s390.c @@ -1623,7 +1623,9 @@ allocate_dynrelocs (h, inf) htab = elf_s390_hash_table (info); if (htab->elf.dynamic_sections_created - && h->plt.refcount > 0) + && h->plt.refcount > 0 + && (ELF_ST_VISIBILITY (h->other) == STV_DEFAULT + || h->root.type != bfd_link_hash_undefweak)) { /* Make sure this symbol is output as a dynamic symbol. Undefined weak syms won't yet be marked as dynamic. */ @@ -1634,7 +1636,8 @@ allocate_dynrelocs (h, inf) return FALSE; } - if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (1, info, h)) + if (info->shared + || WILL_CALL_FINISH_DYNAMIC_SYMBOL (1, info, h)) { asection *s = htab->splt; @@ -1730,7 +1733,10 @@ allocate_dynrelocs (h, inf) htab->srelgot->_raw_size += sizeof (Elf64_External_Rela); else if (tls_type == GOT_TLS_GD) htab->srelgot->_raw_size += 2 * sizeof (Elf64_External_Rela); - else if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, info, h)) + else if ((ELF_ST_VISIBILITY (h->other) == STV_DEFAULT + || h->root.type != bfd_link_hash_undefweak) + && (info->shared + || WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, 0, h))) htab->srelgot->_raw_size += sizeof (Elf64_External_Rela); } else @@ -1764,6 +1770,12 @@ allocate_dynrelocs (h, inf) pp = &p->next; } } + + /* Also discard relocs on undefined weak syms with non-default + visibility. */ + if (ELF_ST_VISIBILITY (h->other) != STV_DEFAULT + && h->root.type == bfd_link_hash_undefweak) + eh->dyn_relocs = NULL; } else { @@ -2279,7 +2291,9 @@ elf_s390_relocate_section (output_bfd, info, input_bfd, input_section, && (info->symbolic || h->dynindx == -1 || (h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL)) - && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR))) + && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR)) + || (ELF_ST_VISIBILITY (h->other) + && h->root.type == bfd_link_hash_undefweak)) { /* This is actually a static link, or it is a -Bsymbolic link and the symbol is defined @@ -2449,6 +2463,9 @@ elf_s390_relocate_section (output_bfd, info, input_bfd, input_section, break; if ((info->shared + && (h == NULL + || ELF_ST_VISIBILITY (h->other) == STV_DEFAULT + || h->root.type != bfd_link_hash_undefweak) && ((r_type != R_390_PC16 && r_type != R_390_PC16DBL && r_type != R_390_PC32 -- cgit v1.1