From: Alan Modra Date: Mon, 5 May 2003 14:12:05 +0000 (+0000) Subject: * elf32-i386.c (allocate_dynrelocs): For undef weak syms with X-Git-Tag: ezannoni_pie-20030916-branchpoint~1821 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4e795f50c1c5f7e59a8ab1f127bc5267d81600f1;p=external%2Fbinutils.git * elf32-i386.c (allocate_dynrelocs): For undef weak syms with non-default visibility, a) don't make them dynamic, b) discard space for dynamic relocs. * elf64-x86-64.c (allocate_dynrelocs): Likewise. * elf32-ppc.c (allocate_dynrelocs): For undef weak syms with non-default visibility, a) don't allocate plt entries, b) don't allocate .got relocs, c) discard dyn rel space, (ppc_elf_relocate_section): d) don't generate .got relocs, e) don't generate dynamic relocs. * elf64-ppc.c (allocate_dynrelocs): As above. (ppc64_elf_relocate_section): As above. --- diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 42c07e8..ca2a5d1 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,18 @@ +2003-05-05 Alan Modra + + * elf32-i386.c (allocate_dynrelocs): For undef weak syms with + non-default visibility, a) don't make them dynamic, b) discard + space for dynamic relocs. + * elf64-x86-64.c (allocate_dynrelocs): Likewise. + + * elf32-ppc.c (allocate_dynrelocs): For undef weak syms with + non-default visibility, a) don't allocate plt entries, b) don't + allocate .got relocs, c) discard dyn rel space, + (ppc_elf_relocate_section): d) don't generate .got relocs, e) + don't generate dynamic relocs. + * elf64-ppc.c (allocate_dynrelocs): As above. + (ppc64_elf_relocate_section): As above. + 2003-05-05 Andreas Jaeger * elf64-x86-64.c (allocate_dynrelocs): Don't allocate dynamic diff --git a/bfd/elf32-i386.c b/bfd/elf32-i386.c index ac292a1..320e985 100644 --- a/bfd/elf32-i386.c +++ b/bfd/elf32-i386.c @@ -1558,7 +1558,9 @@ allocate_dynrelocs (h, inf) htab = elf_i386_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. */ @@ -1569,10 +1571,8 @@ allocate_dynrelocs (h, inf) return FALSE; } - if ((ELF_ST_VISIBILITY (h->other) == STV_DEFAULT - || h->root.type != bfd_link_hash_undefweak) - && (info->shared - || WILL_CALL_FINISH_DYNAMIC_SYMBOL (1, 0, h))) + if (info->shared + || WILL_CALL_FINISH_DYNAMIC_SYMBOL (1, 0, h)) { asection *s = htab->splt; @@ -1695,6 +1695,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 if (ELIMINATE_COPY_RELOCS) { diff --git a/bfd/elf32-ppc.c b/bfd/elf32-ppc.c index 69bb0d6..81a4b62 100644 --- a/bfd/elf32-ppc.c +++ b/bfd/elf32-ppc.c @@ -2694,7 +2694,9 @@ allocate_dynrelocs (h, inf) htab = ppc_elf_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. */ if (h->dynindx == -1 @@ -2789,8 +2791,10 @@ allocate_dynrelocs (h, inf) else htab->got->_raw_size += 4; dyn = htab->elf.dynamic_sections_created; - if (info->shared - || WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, 0, &eh->elf)) + if ((info->shared + || WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, 0, &eh->elf)) + && (ELF_ST_VISIBILITY (eh->elf.other) == STV_DEFAULT + || eh->elf.root.type != bfd_link_hash_undefweak)) { /* All the entries we allocated need relocs. */ htab->relgot->_raw_size @@ -2831,6 +2835,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 if (ELIMINATE_COPY_RELOCS) { @@ -4793,7 +4803,10 @@ ppc_elf_relocate_section (output_bfd, info, input_bfd, input_section, } /* Generate relocs for the dynamic linker. */ - if (info->shared || indx != 0) + if ((info->shared || indx != 0) + && (h == NULL + || ELF_ST_VISIBILITY (h->other) == STV_DEFAULT + || h->root.type != bfd_link_hash_undefweak)) { outrel.r_offset = (htab->got->output_section->vma + htab->got->output_offset @@ -4995,6 +5008,9 @@ ppc_elf_relocate_section (output_bfd, info, input_bfd, input_section, /* Fall thru. */ if ((info->shared + && (h == NULL + || ELF_ST_VISIBILITY (h->other) == STV_DEFAULT + || h->root.type != bfd_link_hash_undefweak) && (MUST_BE_DYN_RELOC (r_type) || (h != NULL && h->dynindx != -1 diff --git a/bfd/elf64-ppc.c b/bfd/elf64-ppc.c index 1e7a498..e7e81d7 100644 --- a/bfd/elf64-ppc.c +++ b/bfd/elf64-ppc.c @@ -5497,7 +5497,9 @@ allocate_dynrelocs (h, inf) if (htab->elf.dynamic_sections_created && h->dynindx != -1 - && WILL_CALL_FINISH_DYNAMIC_SYMBOL (1, info->shared, h)) + && WILL_CALL_FINISH_DYNAMIC_SYMBOL (1, info->shared, h) + && (ELF_ST_VISIBILITY (h->other) == STV_DEFAULT + || h->root.type != bfd_link_hash_undefweak)) { struct plt_entry *pent; bfd_boolean doneone = FALSE; @@ -5597,8 +5599,10 @@ allocate_dynrelocs (h, inf) s->_raw_size += (gent->tls_type & eh->tls_mask & (TLS_GD | TLS_LD)) ? 16 : 8; dyn = htab->elf.dynamic_sections_created; - if (info->shared - || WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, 0, h)) + if ((info->shared + || WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, 0, h)) + && (ELF_ST_VISIBILITY (h->other) == STV_DEFAULT + || h->root.type != bfd_link_hash_undefweak)) htab->srelgot->_raw_size += (gent->tls_type & eh->tls_mask & TLS_GD ? 2 * sizeof (Elf64_External_Rela) @@ -5634,6 +5638,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 if (ELIMINATE_COPY_RELOCS) { @@ -7640,7 +7650,10 @@ ppc64_elf_relocate_section (output_bfd, info, input_bfd, input_section, the case of TLSLD where we'll use one entry per module. */ *offp = off | 1; - if (info->shared || indx != 0) + if ((info->shared || indx != 0) + && (h == NULL + || ELF_ST_VISIBILITY (h->other) == STV_DEFAULT + || h->root.type != bfd_link_hash_undefweak)) { outrel.r_offset = (htab->sgot->output_section->vma + htab->sgot->output_offset @@ -7864,6 +7877,9 @@ ppc64_elf_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) && (MUST_BE_DYN_RELOC (r_type) || (h != NULL && h->dynindx != -1 diff --git a/bfd/elf64-x86-64.c b/bfd/elf64-x86-64.c index f8d2a0c..c0ce57d 100644 --- a/bfd/elf64-x86-64.c +++ b/bfd/elf64-x86-64.c @@ -1385,7 +1385,9 @@ allocate_dynrelocs (h, inf) htab = elf64_x86_64_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. */ @@ -1396,9 +1398,7 @@ allocate_dynrelocs (h, inf) return FALSE; } - if ((ELF_ST_VISIBILITY (h->other) == STV_DEFAULT - || h->root.type != bfd_link_hash_undefweak) - && WILL_CALL_FINISH_DYNAMIC_SYMBOL (1, info, h)) + if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (1, info, h)) { asection *s = htab->splt; @@ -1516,6 +1516,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 if (ELIMINATE_COPY_RELOCS) {