From 60d67dc84bbc7d73672d297d714f8a4a0547618d Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Wed, 22 Nov 2017 17:30:55 +1030 Subject: [PATCH] Rename u.weakdef and make it a circular list This makes the elf_link_hash_entry weakdef field, currently used to point from a weak symbol to a strong alias, a circular list so that all aliases can be found from any of them. A new flag, is_weakalias, distinguishes the weak symbol from a strong alias, and is used in all places where we currently test u.weakdef != NULL. With the original u.weakdef handling it was possible to have two or more weak symbols pointing via u.weakdef to a strong definition. Obviously that situation can't map to a circular list; One or more of the weak symbols must point at another weak alias rather than the strong definition. To handle that, I've added an accessor function to return the strong definition. * elf-bfd.h (struct elf_link_hash_entry): Add is_weakalias. Rename u.weakdef to u.alias and update comment. (weakdef): New static inline function. * elflink.c (bfd_elf_record_link_assignment) Test is_weakalias rather than u.weakdef != NULL, and use weakdef function. (_bfd_elf_adjust_dynamic_symbol): Likewise. (_bfd_elf_fix_symbol_flags): Likewise. Clear is_weakalias on all aliases if def has been overridden in a regular object, not u.weakdef. (elf_link_add_object_symbols): Delete new_weakdef flag. Test is_weakalias and use weakdef. Set is_weakalias and circular u.alias. Update comments. (_bfd_elf_gc_mark_rsec): Test is_weakalias rather than u.weakdef != NULL and use weakdef function. * elf-m10300.c (_bfd_mn10300_elf_adjust_dynamic_symbol): Test is_weakalias rather than u.weakdef != NULL and use weakdef function. Assert that def is strong defined. * elf32-arc.c (elf_arc_adjust_dynamic_symbol): Likewise. * elf32-arm.c (elf32_arm_adjust_dynamic_symbol): Likewise. * elf32-bfin.c (elf32_bfinfdpic_adjust_dynamic_symbol): Likewise. (bfin_adjust_dynamic_symbol): Likewise. * elf32-cr16.c (_bfd_cr16_elf_adjust_dynamic_symbol): Likewise. * elf32-cris.c (elf_cris_adjust_dynamic_symbol): Likewise. * elf32-frv.c (elf32_frvfdpic_adjust_dynamic_symbol): Likewise. * elf32-hppa.c (elf32_hppa_adjust_dynamic_symbol): Likewise. * elf32-i370.c (i370_elf_adjust_dynamic_symbol): Likewise. * elf32-lm32.c (lm32_elf_adjust_dynamic_symbol): Likewise. * elf32-m32r.c (m32r_elf_adjust_dynamic_symbol): Likewise. * elf32-m68k.c (elf_m68k_adjust_dynamic_symbol): Likewise. * elf32-metag.c (elf_metag_adjust_dynamic_symbol): Likewise. * elf32-microblaze.c (microblaze_elf_adjust_dynamic_symbol): Likewise. * elf32-nds32.c (nds32_elf_adjust_dynamic_symbol): Likewise. * elf32-nios2.c (nios2_elf32_adjust_dynamic_symbol): Likewise. * elf32-or1k.c (or1k_elf_adjust_dynamic_symbol): Likewise. * elf32-ppc.c (ppc_elf_adjust_dynamic_symbol): Likewise. * elf32-s390.c (elf_s390_adjust_dynamic_symbol): Likewise. * elf32-score.c (s3_bfd_score_elf_adjust_dynamic_symbol): Likewise. * elf32-score7.c (s7_bfd_score_elf_adjust_dynamic_symbol): Likewise. * elf32-sh.c (sh_elf_adjust_dynamic_symbol): Likewise. * elf32-tic6x.c (elf32_tic6x_adjust_dynamic_symbol): Likewise. * elf32-tilepro.c (tilepro_elf_gc_mark_hook): Likewise. (tilepro_elf_adjust_dynamic_symbol): Likewise. * elf32-vax.c (elf_vax_adjust_dynamic_symbol): Likewise. * elf32-xtensa.c (elf_xtensa_adjust_dynamic_symbol): Likewise. * elf64-alpha.c (elf64_alpha_adjust_dynamic_symbol): Likewise. * elf64-hppa.c (elf64_hppa_adjust_dynamic_symbol): Likewise. * elf64-ia64-vms.c (elf64_ia64_adjust_dynamic_symbol): Likewise. * elf64-ppc.c (ppc64_elf_gc_mark_hook): Likewise. (ppc64_elf_adjust_dynamic_symbol): Likewise. * elf64-s390.c (elf_s390_adjust_dynamic_symbol): Likewise. * elf64-sh64.c (sh64_elf64_adjust_dynamic_symbol): Likewise. * elfnn-aarch64.c (elfNN_aarch64_adjust_dynamic_symbol): Likewise. * elfnn-ia64.c (elfNN_ia64_adjust_dynamic_symbol): Likewise. * elfnn-riscv.c (riscv_elf_adjust_dynamic_symbol): Likewise. * elfxx-mips.c (_bfd_mips_elf_adjust_dynamic_symbol): Likewise. * elfxx-sparc.c (_bfd_sparc_elf_gc_mark_hook): Likewise. (_bfd_sparc_elf_adjust_dynamic_symbol): Likewise. * elfxx-tilegx.c (tilegx_elf_gc_mark_hook): Likewise. (tilegx_elf_adjust_dynamic_symbol): Likewise. * elfxx-x86.c (_bfd_x86_elf_adjust_dynamic_symbol): Likewise. --- bfd/ChangeLog | 63 ++++++++++++++++++++++++++++++ bfd/elf-bfd.h | 22 ++++++++--- bfd/elf-m10300.c | 12 +++--- bfd/elf32-arc.c | 10 ++--- bfd/elf32-arm.c | 12 +++--- bfd/elf32-bfin.c | 24 ++++++------ bfd/elf32-cr16.c | 12 +++--- bfd/elf32-cris.c | 12 +++--- bfd/elf32-frv.c | 13 +++--- bfd/elf32-hppa.c | 13 +++--- bfd/elf32-i370.c | 12 +++--- bfd/elf32-lm32.c | 12 +++--- bfd/elf32-m32r.c | 12 +++--- bfd/elf32-m68k.c | 12 +++--- bfd/elf32-metag.c | 13 +++--- bfd/elf32-microblaze.c | 10 ++--- bfd/elf32-nds32.c | 12 +++--- bfd/elf32-nios2.c | 12 +++--- bfd/elf32-or1k.c | 12 +++--- bfd/elf32-ppc.c | 18 ++++----- bfd/elf32-s390.c | 12 +++--- bfd/elf32-score.c | 12 +++--- bfd/elf32-score7.c | 12 +++--- bfd/elf32-sh.c | 14 +++---- bfd/elf32-tic6x.c | 14 +++---- bfd/elf32-tilepro.c | 16 ++++---- bfd/elf32-vax.c | 12 +++--- bfd/elf32-xtensa.c | 10 ++--- bfd/elf64-alpha.c | 10 ++--- bfd/elf64-hppa.c | 10 ++--- bfd/elf64-ia64-vms.c | 10 ++--- bfd/elf64-ppc.c | 16 ++++---- bfd/elf64-s390.c | 12 +++--- bfd/elf64-sh64.c | 12 +++--- bfd/elflink.c | 89 +++++++++++++++++++++++------------------- bfd/elfnn-aarch64.c | 12 +++--- bfd/elfnn-ia64.c | 10 ++--- bfd/elfnn-riscv.c | 12 +++--- bfd/elfxx-mips.c | 12 +++--- bfd/elfxx-sparc.c | 16 ++++---- bfd/elfxx-tilegx.c | 16 ++++---- bfd/elfxx-x86.c | 14 +++---- 42 files changed, 377 insertions(+), 294 deletions(-) diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 696b2d8ae90..f21c606553f 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,66 @@ +2017-11-23 Alan Modra + + * elf-bfd.h (struct elf_link_hash_entry): Add is_weakalias. + Rename u.weakdef to u.alias and update comment. + (weakdef): New static inline function. + * elflink.c (bfd_elf_record_link_assignment) Test is_weakalias + rather than u.weakdef != NULL, and use weakdef function. + (_bfd_elf_adjust_dynamic_symbol): Likewise. + (_bfd_elf_fix_symbol_flags): Likewise. Clear is_weakalias on + all aliases if def has been overridden in a regular object, not + u.weakdef. + (elf_link_add_object_symbols): Delete new_weakdef flag. Test + is_weakalias and use weakdef. Set is_weakalias and circular + u.alias. Update comments. + (_bfd_elf_gc_mark_rsec): Test is_weakalias rather than + u.weakdef != NULL and use weakdef function. + * elf-m10300.c (_bfd_mn10300_elf_adjust_dynamic_symbol): Test + is_weakalias rather than u.weakdef != NULL and use weakdef + function. Assert that def is strong defined. + * elf32-arc.c (elf_arc_adjust_dynamic_symbol): Likewise. + * elf32-arm.c (elf32_arm_adjust_dynamic_symbol): Likewise. + * elf32-bfin.c (elf32_bfinfdpic_adjust_dynamic_symbol): Likewise. + (bfin_adjust_dynamic_symbol): Likewise. + * elf32-cr16.c (_bfd_cr16_elf_adjust_dynamic_symbol): Likewise. + * elf32-cris.c (elf_cris_adjust_dynamic_symbol): Likewise. + * elf32-frv.c (elf32_frvfdpic_adjust_dynamic_symbol): Likewise. + * elf32-hppa.c (elf32_hppa_adjust_dynamic_symbol): Likewise. + * elf32-i370.c (i370_elf_adjust_dynamic_symbol): Likewise. + * elf32-lm32.c (lm32_elf_adjust_dynamic_symbol): Likewise. + * elf32-m32r.c (m32r_elf_adjust_dynamic_symbol): Likewise. + * elf32-m68k.c (elf_m68k_adjust_dynamic_symbol): Likewise. + * elf32-metag.c (elf_metag_adjust_dynamic_symbol): Likewise. + * elf32-microblaze.c (microblaze_elf_adjust_dynamic_symbol): Likewise. + * elf32-nds32.c (nds32_elf_adjust_dynamic_symbol): Likewise. + * elf32-nios2.c (nios2_elf32_adjust_dynamic_symbol): Likewise. + * elf32-or1k.c (or1k_elf_adjust_dynamic_symbol): Likewise. + * elf32-ppc.c (ppc_elf_adjust_dynamic_symbol): Likewise. + * elf32-s390.c (elf_s390_adjust_dynamic_symbol): Likewise. + * elf32-score.c (s3_bfd_score_elf_adjust_dynamic_symbol): Likewise. + * elf32-score7.c (s7_bfd_score_elf_adjust_dynamic_symbol): Likewise. + * elf32-sh.c (sh_elf_adjust_dynamic_symbol): Likewise. + * elf32-tic6x.c (elf32_tic6x_adjust_dynamic_symbol): Likewise. + * elf32-tilepro.c (tilepro_elf_gc_mark_hook): Likewise. + (tilepro_elf_adjust_dynamic_symbol): Likewise. + * elf32-vax.c (elf_vax_adjust_dynamic_symbol): Likewise. + * elf32-xtensa.c (elf_xtensa_adjust_dynamic_symbol): Likewise. + * elf64-alpha.c (elf64_alpha_adjust_dynamic_symbol): Likewise. + * elf64-hppa.c (elf64_hppa_adjust_dynamic_symbol): Likewise. + * elf64-ia64-vms.c (elf64_ia64_adjust_dynamic_symbol): Likewise. + * elf64-ppc.c (ppc64_elf_gc_mark_hook): Likewise. + (ppc64_elf_adjust_dynamic_symbol): Likewise. + * elf64-s390.c (elf_s390_adjust_dynamic_symbol): Likewise. + * elf64-sh64.c (sh64_elf64_adjust_dynamic_symbol): Likewise. + * elfnn-aarch64.c (elfNN_aarch64_adjust_dynamic_symbol): Likewise. + * elfnn-ia64.c (elfNN_ia64_adjust_dynamic_symbol): Likewise. + * elfnn-riscv.c (riscv_elf_adjust_dynamic_symbol): Likewise. + * elfxx-mips.c (_bfd_mips_elf_adjust_dynamic_symbol): Likewise. + * elfxx-sparc.c (_bfd_sparc_elf_gc_mark_hook): Likewise. + (_bfd_sparc_elf_adjust_dynamic_symbol): Likewise. + * elfxx-tilegx.c (tilegx_elf_gc_mark_hook): Likewise. + (tilegx_elf_adjust_dynamic_symbol): Likewise. + * elfxx-x86.c (_bfd_x86_elf_adjust_dynamic_symbol): Likewise. + 2017-11-21 Alan Modra * elf-bfd.h (elf_symbol_from): Check for NULL symbol bfd. diff --git a/bfd/elf-bfd.h b/bfd/elf-bfd.h index 954105e26e2..aebfbd95a32 100644 --- a/bfd/elf-bfd.h +++ b/bfd/elf-bfd.h @@ -216,20 +216,22 @@ struct elf_link_hash_entry /* Symbol is __start_SECNAME or __stop_SECNAME to mark section SECNAME. */ unsigned int start_stop : 1; + /* Symbol is or was a weak defined symbol from a dynamic object with + a strong defined symbol alias. U.ALIAS points to a list of aliases, + the definition having is_weakalias clear. */ + unsigned int is_weakalias : 1; /* String table index in .dynstr if this is a dynamic symbol. */ unsigned long dynstr_index; union { - /* If this is a weak defined symbol from a dynamic object, this - field points to a defined symbol with the same value, if there is - one. Otherwise it is NULL. */ - struct elf_link_hash_entry *weakdef; + /* Points to a circular list of non-function symbol aliases. */ + struct elf_link_hash_entry *alias; /* Hash value of the name computed using the ELF hash function. Used part way through size_dynamic_sections, after we've finished - with weakdefs. */ + with aliases. */ unsigned long elf_hash_value; } u; @@ -257,6 +259,16 @@ struct elf_link_hash_entry } u2; }; +/* Return the strong definition for a weak symbol with aliases. */ + +static inline struct elf_link_hash_entry * +weakdef (struct elf_link_hash_entry *h) +{ + while (h->is_weakalias) + h = h->u.alias; + return h; +} + /* Will references to this symbol always reference the symbol in this object? */ #define SYMBOL_REFERENCES_LOCAL(INFO, H) \ diff --git a/bfd/elf-m10300.c b/bfd/elf-m10300.c index b5951c60054..82d58e716a6 100644 --- a/bfd/elf-m10300.c +++ b/bfd/elf-m10300.c @@ -4889,7 +4889,7 @@ _bfd_mn10300_elf_adjust_dynamic_symbol (struct bfd_link_info * info, /* Make sure we know what is going on here. */ BFD_ASSERT (dynobj != NULL && (h->needs_plt - || h->u.weakdef != NULL + || h->is_weakalias || (h->def_dynamic && h->ref_regular && !h->def_regular))); @@ -4962,12 +4962,12 @@ _bfd_mn10300_elf_adjust_dynamic_symbol (struct bfd_link_info * info, /* If this is a weak symbol, and there is a real definition, the processor independent code will have arranged for us to see the real definition first, and we can just use the same value. */ - if (h->u.weakdef != NULL) + if (h->is_weakalias) { - BFD_ASSERT (h->u.weakdef->root.type == bfd_link_hash_defined - || h->u.weakdef->root.type == bfd_link_hash_defweak); - h->root.u.def.section = h->u.weakdef->root.u.def.section; - h->root.u.def.value = h->u.weakdef->root.u.def.value; + struct elf_link_hash_entry *def = weakdef (h); + BFD_ASSERT (def->root.type == bfd_link_hash_defined); + h->root.u.def.section = def->root.u.def.section; + h->root.u.def.value = def->root.u.def.value; return TRUE; } diff --git a/bfd/elf32-arc.c b/bfd/elf32-arc.c index cdecdb14528..af46369f138 100644 --- a/bfd/elf32-arc.c +++ b/bfd/elf32-arc.c @@ -2291,12 +2291,12 @@ elf_arc_adjust_dynamic_symbol (struct bfd_link_info *info, /* If this is a weak symbol, and there is a real definition, the processor independent code will have arranged for us to see the real definition first, and we can just use the same value. */ - if (h->u.weakdef != NULL) + if (h->is_weakalias) { - BFD_ASSERT (h->u.weakdef->root.type == bfd_link_hash_defined - || h->u.weakdef->root.type == bfd_link_hash_defweak); - h->root.u.def.section = h->u.weakdef->root.u.def.section; - h->root.u.def.value = h->u.weakdef->root.u.def.value; + struct elf_link_hash_entry *def = weakdef (h); + BFD_ASSERT (def->root.type == bfd_link_hash_defined); + h->root.u.def.section = def->root.u.def.section; + h->root.u.def.value = def->root.u.def.value; return TRUE; } diff --git a/bfd/elf32-arm.c b/bfd/elf32-arm.c index 23c7664481e..f358995e272 100644 --- a/bfd/elf32-arm.c +++ b/bfd/elf32-arm.c @@ -15120,7 +15120,7 @@ elf32_arm_adjust_dynamic_symbol (struct bfd_link_info * info, BFD_ASSERT (dynobj != NULL && (h->needs_plt || h->type == STT_GNU_IFUNC - || h->u.weakdef != NULL + || h->is_weakalias || (h->def_dynamic && h->ref_regular && !h->def_regular))); @@ -15170,12 +15170,12 @@ elf32_arm_adjust_dynamic_symbol (struct bfd_link_info * info, /* If this is a weak symbol, and there is a real definition, the processor independent code will have arranged for us to see the real definition first, and we can just use the same value. */ - if (h->u.weakdef != NULL) + if (h->is_weakalias) { - BFD_ASSERT (h->u.weakdef->root.type == bfd_link_hash_defined - || h->u.weakdef->root.type == bfd_link_hash_defweak); - h->root.u.def.section = h->u.weakdef->root.u.def.section; - h->root.u.def.value = h->u.weakdef->root.u.def.value; + struct elf_link_hash_entry *def = weakdef (h); + BFD_ASSERT (def->root.type == bfd_link_hash_defined); + h->root.u.def.section = def->root.u.def.section; + h->root.u.def.value = def->root.u.def.value; return TRUE; } diff --git a/bfd/elf32-bfin.c b/bfd/elf32-bfin.c index 9e66a77ac97..df6634aad18 100644 --- a/bfd/elf32-bfin.c +++ b/bfd/elf32-bfin.c @@ -4327,7 +4327,7 @@ elf32_bfinfdpic_adjust_dynamic_symbol (struct bfd_link_info *info, /* Make sure we know what is going on here. */ BFD_ASSERT (dynobj != NULL - && (h->u.weakdef != NULL + && (h->is_weakalias || (h->def_dynamic && h->ref_regular && !h->def_regular))); @@ -4335,12 +4335,12 @@ elf32_bfinfdpic_adjust_dynamic_symbol (struct bfd_link_info *info, /* If this is a weak symbol, and there is a real definition, the processor independent code will have arranged for us to see the real definition first, and we can just use the same value. */ - if (h->u.weakdef != NULL) + if (h->is_weakalias) { - BFD_ASSERT (h->u.weakdef->root.type == bfd_link_hash_defined - || h->u.weakdef->root.type == bfd_link_hash_defweak); - h->root.u.def.section = h->u.weakdef->root.u.def.section; - h->root.u.def.value = h->u.weakdef->root.u.def.value; + struct elf_link_hash_entry *def = weakdef (h); + BFD_ASSERT (def->root.type == bfd_link_hash_defined); + h->root.u.def.section = def->root.u.def.section; + h->root.u.def.value = def->root.u.def.value; } return TRUE; @@ -4984,7 +4984,7 @@ bfin_adjust_dynamic_symbol (struct bfd_link_info *info, /* Make sure we know what is going on here. */ BFD_ASSERT (dynobj != NULL && (h->needs_plt - || h->u.weakdef != NULL + || h->is_weakalias || (h->def_dynamic && h->ref_regular && !h->def_regular))); /* If this is a function, put it in the procedure linkage table. We @@ -4998,12 +4998,12 @@ bfin_adjust_dynamic_symbol (struct bfd_link_info *info, /* If this is a weak symbol, and there is a real definition, the processor independent code will have arranged for us to see the real definition first, and we can just use the same value. */ - if (h->u.weakdef != NULL) + if (h->is_weakalias) { - BFD_ASSERT (h->u.weakdef->root.type == bfd_link_hash_defined - || h->u.weakdef->root.type == bfd_link_hash_defweak); - h->root.u.def.section = h->u.weakdef->root.u.def.section; - h->root.u.def.value = h->u.weakdef->root.u.def.value; + struct elf_link_hash_entry *def = weakdef (h); + BFD_ASSERT (def->root.type == bfd_link_hash_defined); + h->root.u.def.section = def->root.u.def.section; + h->root.u.def.value = def->root.u.def.value; return TRUE; } diff --git a/bfd/elf32-cr16.c b/bfd/elf32-cr16.c index 0f09102d03b..6d7962dc968 100644 --- a/bfd/elf32-cr16.c +++ b/bfd/elf32-cr16.c @@ -2308,7 +2308,7 @@ _bfd_cr16_elf_adjust_dynamic_symbol (struct bfd_link_info * info, /* Make sure we know what is going on here. */ BFD_ASSERT (dynobj != NULL && (h->needs_plt - || h->u.weakdef != NULL + || h->is_weakalias || (h->def_dynamic && h->ref_regular && !h->def_regular))); @@ -2358,12 +2358,12 @@ _bfd_cr16_elf_adjust_dynamic_symbol (struct bfd_link_info * info, /* If this is a weak symbol, and there is a real definition, the processor independent code will have arranged for us to see the real definition first, and we can just use the same value. */ - if (h->u.weakdef != NULL) + if (h->is_weakalias) { - BFD_ASSERT (h->u.weakdef->root.type == bfd_link_hash_defined - || h->u.weakdef->root.type == bfd_link_hash_defweak); - h->root.u.def.section = h->u.weakdef->root.u.def.section; - h->root.u.def.value = h->u.weakdef->root.u.def.value; + struct elf_link_hash_entry *def = weakdef (h); + BFD_ASSERT (def->root.type == bfd_link_hash_defined); + h->root.u.def.section = def->root.u.def.section; + h->root.u.def.value = def->root.u.def.value; return TRUE; } diff --git a/bfd/elf32-cris.c b/bfd/elf32-cris.c index 012e663c363..9f1d24418ee 100644 --- a/bfd/elf32-cris.c +++ b/bfd/elf32-cris.c @@ -2671,7 +2671,7 @@ elf_cris_adjust_dynamic_symbol (struct bfd_link_info *info, /* Make sure we know what is going on here. */ BFD_ASSERT (dynobj != NULL && (h->needs_plt - || h->u.weakdef != NULL + || h->is_weakalias || (h->def_dynamic && h->ref_regular && !h->def_regular))); @@ -2813,12 +2813,12 @@ elf_cris_adjust_dynamic_symbol (struct bfd_link_info *info, /* If this is a weak symbol, and there is a real definition, the processor independent code will have arranged for us to see the real definition first, and we can just use the same value. */ - if (h->u.weakdef != NULL) + if (h->is_weakalias) { - BFD_ASSERT (h->u.weakdef->root.type == bfd_link_hash_defined - || h->u.weakdef->root.type == bfd_link_hash_defweak); - h->root.u.def.section = h->u.weakdef->root.u.def.section; - h->root.u.def.value = h->u.weakdef->root.u.def.value; + struct elf_link_hash_entry *def = weakdef (h); + BFD_ASSERT (def->root.type == bfd_link_hash_defined); + h->root.u.def.section = def->root.u.def.section; + h->root.u.def.value = def->root.u.def.value; return TRUE; } diff --git a/bfd/elf32-frv.c b/bfd/elf32-frv.c index 825b9a06691..935bb10a222 100644 --- a/bfd/elf32-frv.c +++ b/bfd/elf32-frv.c @@ -5824,7 +5824,7 @@ elf32_frvfdpic_adjust_dynamic_symbol /* Make sure we know what is going on here. */ BFD_ASSERT (dynobj != NULL - && (h->u.weakdef != NULL + && (h->is_weakalias || (h->def_dynamic && h->ref_regular && !h->def_regular))); @@ -5832,12 +5832,13 @@ elf32_frvfdpic_adjust_dynamic_symbol /* If this is a weak symbol, and there is a real definition, the processor independent code will have arranged for us to see the real definition first, and we can just use the same value. */ - if (h->u.weakdef != NULL) + if (h->is_weakalias) { - BFD_ASSERT (h->u.weakdef->root.type == bfd_link_hash_defined - || h->u.weakdef->root.type == bfd_link_hash_defweak); - h->root.u.def.section = h->u.weakdef->root.u.def.section; - h->root.u.def.value = h->u.weakdef->root.u.def.value; + struct elf_link_hash_entry *def = weakdef (h); + BFD_ASSERT (def->root.type == bfd_link_hash_defined); + h->root.u.def.section = def->root.u.def.section; + h->root.u.def.value = def->root.u.def.value; + return TRUE; } return TRUE; diff --git a/bfd/elf32-hppa.c b/bfd/elf32-hppa.c index 7fc447e2b46..01060dbef9c 100644 --- a/bfd/elf32-hppa.c +++ b/bfd/elf32-hppa.c @@ -1741,15 +1741,14 @@ elf32_hppa_adjust_dynamic_symbol (struct bfd_link_info *info, /* If this is a weak symbol, and there is a real definition, the processor independent code will have arranged for us to see the real definition first, and we can just use the same value. */ - if (eh->u.weakdef != NULL) + if (eh->is_weakalias) { - if (eh->u.weakdef->root.type != bfd_link_hash_defined - && eh->u.weakdef->root.type != bfd_link_hash_defweak) - abort (); - eh->root.u.def.section = eh->u.weakdef->root.u.def.section; - eh->root.u.def.value = eh->u.weakdef->root.u.def.value; + struct elf_link_hash_entry *def = weakdef (eh); + BFD_ASSERT (def->root.type == bfd_link_hash_defined); + eh->root.u.def.section = def->root.u.def.section; + eh->root.u.def.value = def->root.u.def.value; if (ELIMINATE_COPY_RELOCS) - eh->non_got_ref = eh->u.weakdef->non_got_ref; + eh->non_got_ref = def->non_got_ref; return TRUE; } diff --git a/bfd/elf32-i370.c b/bfd/elf32-i370.c index f305515b949..46f822f4211 100644 --- a/bfd/elf32-i370.c +++ b/bfd/elf32-i370.c @@ -478,7 +478,7 @@ i370_elf_adjust_dynamic_symbol (struct bfd_link_info *info, /* Make sure we know what is going on here. */ BFD_ASSERT (dynobj != NULL && (h->needs_plt - || h->u.weakdef != NULL + || h->is_weakalias || (h->def_dynamic && h->ref_regular && !h->def_regular))); @@ -490,12 +490,12 @@ i370_elf_adjust_dynamic_symbol (struct bfd_link_info *info, /* If this is a weak symbol, and there is a real definition, the processor independent code will have arranged for us to see the real definition first, and we can just use the same value. */ - if (h->u.weakdef != NULL) + if (h->is_weakalias) { - BFD_ASSERT (h->u.weakdef->root.type == bfd_link_hash_defined - || h->u.weakdef->root.type == bfd_link_hash_defweak); - h->root.u.def.section = h->u.weakdef->root.u.def.section; - h->root.u.def.value = h->u.weakdef->root.u.def.value; + struct elf_link_hash_entry *def = weakdef (h); + BFD_ASSERT (def->root.type == bfd_link_hash_defined); + h->root.u.def.section = def->root.u.def.section; + h->root.u.def.value = def->root.u.def.value; return TRUE; } diff --git a/bfd/elf32-lm32.c b/bfd/elf32-lm32.c index f0b46c90851..ea404a9f912 100644 --- a/bfd/elf32-lm32.c +++ b/bfd/elf32-lm32.c @@ -1668,7 +1668,7 @@ lm32_elf_adjust_dynamic_symbol (struct bfd_link_info *info, /* Make sure we know what is going on here. */ BFD_ASSERT (dynobj != NULL && (h->needs_plt - || h->u.weakdef != NULL + || h->is_weakalias || (h->def_dynamic && h->ref_regular && !h->def_regular))); @@ -1702,12 +1702,12 @@ lm32_elf_adjust_dynamic_symbol (struct bfd_link_info *info, /* If this is a weak symbol, and there is a real definition, the processor independent code will have arranged for us to see the real definition first, and we can just use the same value. */ - if (h->u.weakdef != NULL) + if (h->is_weakalias) { - BFD_ASSERT (h->u.weakdef->root.type == bfd_link_hash_defined - || h->u.weakdef->root.type == bfd_link_hash_defweak); - h->root.u.def.section = h->u.weakdef->root.u.def.section; - h->root.u.def.value = h->u.weakdef->root.u.def.value; + struct elf_link_hash_entry *def = weakdef (h); + BFD_ASSERT (def->root.type == bfd_link_hash_defined); + h->root.u.def.section = def->root.u.def.section; + h->root.u.def.value = def->root.u.def.value; return TRUE; } diff --git a/bfd/elf32-m32r.c b/bfd/elf32-m32r.c index 6d83aff3d40..594c9e44bb6 100644 --- a/bfd/elf32-m32r.c +++ b/bfd/elf32-m32r.c @@ -1782,7 +1782,7 @@ m32r_elf_adjust_dynamic_symbol (struct bfd_link_info *info, /* Make sure we know what is going on here. */ BFD_ASSERT (dynobj != NULL && (h->needs_plt - || h->u.weakdef != NULL + || h->is_weakalias || (h->def_dynamic && h->ref_regular && !h->def_regular))); @@ -1816,12 +1816,12 @@ m32r_elf_adjust_dynamic_symbol (struct bfd_link_info *info, /* If this is a weak symbol, and there is a real definition, the processor independent code will have arranged for us to see the real definition first, and we can just use the same value. */ - if (h->u.weakdef != NULL) + if (h->is_weakalias) { - BFD_ASSERT (h->u.weakdef->root.type == bfd_link_hash_defined - || h->u.weakdef->root.type == bfd_link_hash_defweak); - h->root.u.def.section = h->u.weakdef->root.u.def.section; - h->root.u.def.value = h->u.weakdef->root.u.def.value; + struct elf_link_hash_entry *def = weakdef (h); + BFD_ASSERT (def->root.type == bfd_link_hash_defined); + h->root.u.def.section = def->root.u.def.section; + h->root.u.def.value = def->root.u.def.value; return TRUE; } diff --git a/bfd/elf32-m68k.c b/bfd/elf32-m68k.c index d9a2cb84889..b07bbf421f7 100644 --- a/bfd/elf32-m68k.c +++ b/bfd/elf32-m68k.c @@ -2891,7 +2891,7 @@ elf_m68k_adjust_dynamic_symbol (struct bfd_link_info *info, /* Make sure we know what is going on here. */ BFD_ASSERT (dynobj != NULL && (h->needs_plt - || h->u.weakdef != NULL + || h->is_weakalias || (h->def_dynamic && h->ref_regular && !h->def_regular))); @@ -2976,12 +2976,12 @@ elf_m68k_adjust_dynamic_symbol (struct bfd_link_info *info, /* If this is a weak symbol, and there is a real definition, the processor independent code will have arranged for us to see the real definition first, and we can just use the same value. */ - if (h->u.weakdef != NULL) + if (h->is_weakalias) { - BFD_ASSERT (h->u.weakdef->root.type == bfd_link_hash_defined - || h->u.weakdef->root.type == bfd_link_hash_defweak); - h->root.u.def.section = h->u.weakdef->root.u.def.section; - h->root.u.def.value = h->u.weakdef->root.u.def.value; + struct elf_link_hash_entry *def = weakdef (h); + BFD_ASSERT (def->root.type == bfd_link_hash_defined); + h->root.u.def.section = def->root.u.def.section; + h->root.u.def.value = def->root.u.def.value; return TRUE; } diff --git a/bfd/elf32-metag.c b/bfd/elf32-metag.c index c901aa99c23..a44bddbee3e 100644 --- a/bfd/elf32-metag.c +++ b/bfd/elf32-metag.c @@ -2499,14 +2499,13 @@ elf_metag_adjust_dynamic_symbol (struct bfd_link_info *info, /* If this is a weak symbol, and there is a real definition, the processor independent code will have arranged for us to see the real definition first, and we can just use the same value. */ - if (eh->u.weakdef != NULL) + if (eh->is_weakalias) { - if (eh->u.weakdef->root.type != bfd_link_hash_defined - && eh->u.weakdef->root.type != bfd_link_hash_defweak) - abort (); - eh->root.u.def.section = eh->u.weakdef->root.u.def.section; - eh->root.u.def.value = eh->u.weakdef->root.u.def.value; - eh->non_got_ref = eh->u.weakdef->non_got_ref; + struct elf_link_hash_entry *def = weakdef (eh); + BFD_ASSERT (def->root.type == bfd_link_hash_defined); + eh->root.u.def.section = def->root.u.def.section; + eh->root.u.def.value = def->root.u.def.value; + eh->non_got_ref = def->non_got_ref; return TRUE; } diff --git a/bfd/elf32-microblaze.c b/bfd/elf32-microblaze.c index a54044fdb3c..9b581688cd0 100644 --- a/bfd/elf32-microblaze.c +++ b/bfd/elf32-microblaze.c @@ -2606,12 +2606,12 @@ microblaze_elf_adjust_dynamic_symbol (struct bfd_link_info *info, /* If this is a weak symbol, and there is a real definition, the processor independent code will have arranged for us to see the real definition first, and we can just use the same value. */ - if (h->u.weakdef != NULL) + if (h->is_weakalias) { - BFD_ASSERT (h->u.weakdef->root.type == bfd_link_hash_defined - || h->u.weakdef->root.type == bfd_link_hash_defweak); - h->root.u.def.section = h->u.weakdef->root.u.def.section; - h->root.u.def.value = h->u.weakdef->root.u.def.value; + struct elf_link_hash_entry *def = weakdef (h); + BFD_ASSERT (def->root.type == bfd_link_hash_defined); + h->root.u.def.section = def->root.u.def.section; + h->root.u.def.value = def->root.u.def.value; return TRUE; } diff --git a/bfd/elf32-nds32.c b/bfd/elf32-nds32.c index 42de10a0133..32870eea3b3 100644 --- a/bfd/elf32-nds32.c +++ b/bfd/elf32-nds32.c @@ -3584,7 +3584,7 @@ nds32_elf_adjust_dynamic_symbol (struct bfd_link_info *info, /* Make sure we know what is going on here. */ BFD_ASSERT (dynobj != NULL && (h->needs_plt - || h->u.weakdef != NULL + || h->is_weakalias || (h->def_dynamic && h->ref_regular && !h->def_regular))); @@ -3616,12 +3616,12 @@ nds32_elf_adjust_dynamic_symbol (struct bfd_link_info *info, /* If this is a weak symbol, and there is a real definition, the processor independent code will have arranged for us to see the real definition first, and we can just use the same value. */ - if (h->u.weakdef != NULL) + if (h->is_weakalias) { - BFD_ASSERT (h->u.weakdef->root.type == bfd_link_hash_defined - || h->u.weakdef->root.type == bfd_link_hash_defweak); - h->root.u.def.section = h->u.weakdef->root.u.def.section; - h->root.u.def.value = h->u.weakdef->root.u.def.value; + struct elf_link_hash_entry *def = weakdef (h); + BFD_ASSERT (def->root.type == bfd_link_hash_defined); + h->root.u.def.section = def->root.u.def.section; + h->root.u.def.value = def->root.u.def.value; return TRUE; } diff --git a/bfd/elf32-nios2.c b/bfd/elf32-nios2.c index 5456c07d292..f2d0452ea0e 100644 --- a/bfd/elf32-nios2.c +++ b/bfd/elf32-nios2.c @@ -5332,7 +5332,7 @@ nios2_elf32_adjust_dynamic_symbol (struct bfd_link_info *info, /* Make sure we know what is going on here. */ BFD_ASSERT (dynobj != NULL && (h->needs_plt - || h->u.weakdef != NULL + || h->is_weakalias || (h->def_dynamic && h->ref_regular && !h->def_regular))); @@ -5366,12 +5366,12 @@ nios2_elf32_adjust_dynamic_symbol (struct bfd_link_info *info, /* If this is a weak symbol, and there is a real definition, the processor independent code will have arranged for us to see the real definition first, and we can just use the same value. */ - if (h->u.weakdef != NULL) + if (h->is_weakalias) { - BFD_ASSERT (h->u.weakdef->root.type == bfd_link_hash_defined - || h->u.weakdef->root.type == bfd_link_hash_defweak); - h->root.u.def.section = h->u.weakdef->root.u.def.section; - h->root.u.def.value = h->u.weakdef->root.u.def.value; + struct elf_link_hash_entry *def = weakdef (h); + BFD_ASSERT (def->root.type == bfd_link_hash_defined); + h->root.u.def.section = def->root.u.def.section; + h->root.u.def.value = def->root.u.def.value; return TRUE; } diff --git a/bfd/elf32-or1k.c b/bfd/elf32-or1k.c index 6673d4f563e..8abd978afa9 100644 --- a/bfd/elf32-or1k.c +++ b/bfd/elf32-or1k.c @@ -1946,7 +1946,7 @@ or1k_elf_adjust_dynamic_symbol (struct bfd_link_info *info, /* Make sure we know what is going on here. */ BFD_ASSERT (dynobj != NULL && (h->needs_plt - || h->u.weakdef != NULL + || h->is_weakalias || (h->def_dynamic && h->ref_regular && !h->def_regular))); @@ -1980,12 +1980,12 @@ or1k_elf_adjust_dynamic_symbol (struct bfd_link_info *info, /* If this is a weak symbol, and there is a real definition, the processor independent code will have arranged for us to see the real definition first, and we can just use the same value. */ - if (h->u.weakdef != NULL) + if (h->is_weakalias) { - BFD_ASSERT (h->u.weakdef->root.type == bfd_link_hash_defined - || h->u.weakdef->root.type == bfd_link_hash_defweak); - h->root.u.def.section = h->u.weakdef->root.u.def.section; - h->root.u.def.value = h->u.weakdef->root.u.def.value; + struct elf_link_hash_entry *def = weakdef (h); + BFD_ASSERT (def->root.type == bfd_link_hash_defined); + h->root.u.def.section = def->root.u.def.section; + h->root.u.def.value = def->root.u.def.value; return TRUE; } diff --git a/bfd/elf32-ppc.c b/bfd/elf32-ppc.c index f68a7a4e76b..756523b1dd3 100644 --- a/bfd/elf32-ppc.c +++ b/bfd/elf32-ppc.c @@ -5464,7 +5464,7 @@ ppc_elf_adjust_dynamic_symbol (struct bfd_link_info *info, BFD_ASSERT (htab->elf.dynobj != NULL && (h->needs_plt || h->type == STT_GNU_IFUNC - || h->u.weakdef != NULL + || h->is_weakalias || (h->def_dynamic && h->ref_regular && !h->def_regular))); @@ -5499,8 +5499,8 @@ ppc_elf_adjust_dynamic_symbol (struct bfd_link_info *info, Note that function symbols are not supposed to have weakdefs, but since symbols may not be correctly typed we handle them here. */ - h->non_got_ref = (h->u.weakdef != NULL - ? h->u.weakdef->non_got_ref + h->non_got_ref = (h->is_weakalias + ? weakdef (h)->non_got_ref : !local && (((struct ppc_elf_link_hash_entry *) h) ->dyn_relocs != NULL)); @@ -5567,14 +5567,14 @@ ppc_elf_adjust_dynamic_symbol (struct bfd_link_info *info, /* If this is a weak symbol, and there is a real definition, the processor independent code will have arranged for us to see the real definition first, and we can just use the same value. */ - if (h->u.weakdef != NULL) + if (h->is_weakalias) { - BFD_ASSERT (h->u.weakdef->root.type == bfd_link_hash_defined - || h->u.weakdef->root.type == bfd_link_hash_defweak); - h->root.u.def.section = h->u.weakdef->root.u.def.section; - h->root.u.def.value = h->u.weakdef->root.u.def.value; + struct elf_link_hash_entry *def = weakdef (h); + BFD_ASSERT (def->root.type == bfd_link_hash_defined); + h->root.u.def.section = def->root.u.def.section; + h->root.u.def.value = def->root.u.def.value; if (ELIMINATE_COPY_RELOCS) - h->non_got_ref = h->u.weakdef->non_got_ref; + h->non_got_ref = def->non_got_ref; return TRUE; } diff --git a/bfd/elf32-s390.c b/bfd/elf32-s390.c index ce5c98be869..1bd6ab10fa6 100644 --- a/bfd/elf32-s390.c +++ b/bfd/elf32-s390.c @@ -1514,14 +1514,14 @@ elf_s390_adjust_dynamic_symbol (struct bfd_link_info *info, /* If this is a weak symbol, and there is a real definition, the processor independent code will have arranged for us to see the real definition first, and we can just use the same value. */ - if (h->u.weakdef != NULL) + if (h->is_weakalias) { - BFD_ASSERT (h->u.weakdef->root.type == bfd_link_hash_defined - || h->u.weakdef->root.type == bfd_link_hash_defweak); - h->root.u.def.section = h->u.weakdef->root.u.def.section; - h->root.u.def.value = h->u.weakdef->root.u.def.value; + struct elf_link_hash_entry *def = weakdef (h); + BFD_ASSERT (def->root.type == bfd_link_hash_defined); + h->root.u.def.section = def->root.u.def.section; + h->root.u.def.value = def->root.u.def.value; if (ELIMINATE_COPY_RELOCS || info->nocopyreloc) - h->non_got_ref = h->u.weakdef->non_got_ref; + h->non_got_ref = def->non_got_ref; return TRUE; } diff --git a/bfd/elf32-score.c b/bfd/elf32-score.c index 69a19ec4d20..455f8cb0b37 100644 --- a/bfd/elf32-score.c +++ b/bfd/elf32-score.c @@ -3098,7 +3098,7 @@ s3_bfd_score_elf_adjust_dynamic_symbol (struct bfd_link_info *info, /* Make sure we know what is going on here. */ BFD_ASSERT (dynobj != NULL && (h->needs_plt - || h->u.weakdef != NULL + || h->is_weakalias || (h->def_dynamic && h->ref_regular && !h->def_regular))); /* If this symbol is defined in a dynamic object, we need to copy @@ -3157,12 +3157,12 @@ s3_bfd_score_elf_adjust_dynamic_symbol (struct bfd_link_info *info, /* If this is a weak symbol, and there is a real definition, the processor independent code will have arranged for us to see the real definition first, and we can just use the same value. */ - if (h->u.weakdef != NULL) + if (h->is_weakalias) { - BFD_ASSERT (h->u.weakdef->root.type == bfd_link_hash_defined - || h->u.weakdef->root.type == bfd_link_hash_defweak); - h->root.u.def.section = h->u.weakdef->root.u.def.section; - h->root.u.def.value = h->u.weakdef->root.u.def.value; + struct elf_link_hash_entry *def = weakdef (h); + BFD_ASSERT (def->root.type == bfd_link_hash_defined); + h->root.u.def.section = def->root.u.def.section; + h->root.u.def.value = def->root.u.def.value; return TRUE; } diff --git a/bfd/elf32-score7.c b/bfd/elf32-score7.c index 17f5f9d2900..29796b95791 100644 --- a/bfd/elf32-score7.c +++ b/bfd/elf32-score7.c @@ -2904,7 +2904,7 @@ s7_bfd_score_elf_adjust_dynamic_symbol (struct bfd_link_info *info, /* Make sure we know what is going on here. */ BFD_ASSERT (dynobj != NULL && (h->needs_plt - || h->u.weakdef != NULL + || h->is_weakalias || (h->def_dynamic && h->ref_regular && !h->def_regular))); /* If this symbol is defined in a dynamic object, we need to copy @@ -2963,12 +2963,12 @@ s7_bfd_score_elf_adjust_dynamic_symbol (struct bfd_link_info *info, /* If this is a weak symbol, and there is a real definition, the processor independent code will have arranged for us to see the real definition first, and we can just use the same value. */ - if (h->u.weakdef != NULL) + if (h->is_weakalias) { - BFD_ASSERT (h->u.weakdef->root.type == bfd_link_hash_defined - || h->u.weakdef->root.type == bfd_link_hash_defweak); - h->root.u.def.section = h->u.weakdef->root.u.def.section; - h->root.u.def.value = h->u.weakdef->root.u.def.value; + struct elf_link_hash_entry *def = weakdef (h); + BFD_ASSERT (def->root.type == bfd_link_hash_defined); + h->root.u.def.section = def->root.u.def.section; + h->root.u.def.value = def->root.u.def.value; return TRUE; } diff --git a/bfd/elf32-sh.c b/bfd/elf32-sh.c index 3960427bb49..cd1c6fd68e6 100644 --- a/bfd/elf32-sh.c +++ b/bfd/elf32-sh.c @@ -2817,7 +2817,7 @@ sh_elf_adjust_dynamic_symbol (struct bfd_link_info *info, /* Make sure we know what is going on here. */ BFD_ASSERT (htab->root.dynobj != NULL && (h->needs_plt - || h->u.weakdef != NULL + || h->is_weakalias || (h->def_dynamic && h->ref_regular && !h->def_regular))); @@ -2850,14 +2850,14 @@ sh_elf_adjust_dynamic_symbol (struct bfd_link_info *info, /* If this is a weak symbol, and there is a real definition, the processor independent code will have arranged for us to see the real definition first, and we can just use the same value. */ - if (h->u.weakdef != NULL) + if (h->is_weakalias) { - BFD_ASSERT (h->u.weakdef->root.type == bfd_link_hash_defined - || h->u.weakdef->root.type == bfd_link_hash_defweak); - h->root.u.def.section = h->u.weakdef->root.u.def.section; - h->root.u.def.value = h->u.weakdef->root.u.def.value; + struct elf_link_hash_entry *def = weakdef (h); + BFD_ASSERT (def->root.type == bfd_link_hash_defined); + h->root.u.def.section = def->root.u.def.section; + h->root.u.def.value = def->root.u.def.value; if (info->nocopyreloc) - h->non_got_ref = h->u.weakdef->non_got_ref; + h->non_got_ref = def->non_got_ref; return TRUE; } diff --git a/bfd/elf32-tic6x.c b/bfd/elf32-tic6x.c index ef6f1c1bf70..5da819186a3 100644 --- a/bfd/elf32-tic6x.c +++ b/bfd/elf32-tic6x.c @@ -1990,7 +1990,7 @@ elf32_tic6x_adjust_dynamic_symbol (struct bfd_link_info *info, /* Make sure we know what is going on here. */ BFD_ASSERT (dynobj != NULL && (h->needs_plt - || h->u.weakdef != NULL + || h->is_weakalias || (h->def_dynamic && h->ref_regular && !h->def_regular))); /* If this is a function, put it in the procedure linkage table. We @@ -2019,13 +2019,13 @@ elf32_tic6x_adjust_dynamic_symbol (struct bfd_link_info *info, /* If this is a weak symbol, and there is a real definition, the processor independent code will have arranged for us to see the real definition first, and we can just use the same value. */ - if (h->u.weakdef != NULL) + if (h->is_weakalias) { - BFD_ASSERT (h->u.weakdef->root.type == bfd_link_hash_defined - || h->u.weakdef->root.type == bfd_link_hash_defweak); - h->root.u.def.section = h->u.weakdef->root.u.def.section; - h->root.u.def.value = h->u.weakdef->root.u.def.value; - h->non_got_ref = h->u.weakdef->non_got_ref; + struct elf_link_hash_entry *def = weakdef (h); + BFD_ASSERT (def->root.type == bfd_link_hash_defined); + h->root.u.def.section = def->root.u.def.section; + h->root.u.def.value = def->root.u.def.value; + h->non_got_ref = def->non_got_ref; return TRUE; } diff --git a/bfd/elf32-tilepro.c b/bfd/elf32-tilepro.c index 7731318b5e8..86456648ce2 100644 --- a/bfd/elf32-tilepro.c +++ b/bfd/elf32-tilepro.c @@ -1884,8 +1884,8 @@ tilepro_elf_gc_mark_hook (asection *sec, h = (struct elf_link_hash_entry *) bh; BFD_ASSERT (h != NULL); h->mark = 1; - if (h->u.weakdef != NULL) - h->u.weakdef->mark = 1; + if (h->is_weakalias) + weakdef (h)->mark = 1; sym = NULL; } } @@ -1914,7 +1914,7 @@ tilepro_elf_adjust_dynamic_symbol (struct bfd_link_info *info, /* Make sure we know what is going on here. */ BFD_ASSERT (htab->elf.dynobj != NULL && (h->needs_plt - || h->u.weakdef != NULL + || h->is_weakalias || (h->def_dynamic && h->ref_regular && !h->def_regular))); @@ -1947,12 +1947,12 @@ tilepro_elf_adjust_dynamic_symbol (struct bfd_link_info *info, /* If this is a weak symbol, and there is a real definition, the processor independent code will have arranged for us to see the real definition first, and we can just use the same value. */ - if (h->u.weakdef != NULL) + if (h->is_weakalias) { - BFD_ASSERT (h->u.weakdef->root.type == bfd_link_hash_defined - || h->u.weakdef->root.type == bfd_link_hash_defweak); - h->root.u.def.section = h->u.weakdef->root.u.def.section; - h->root.u.def.value = h->u.weakdef->root.u.def.value; + struct elf_link_hash_entry *def = weakdef (h); + BFD_ASSERT (def->root.type == bfd_link_hash_defined); + h->root.u.def.section = def->root.u.def.section; + h->root.u.def.value = def->root.u.def.value; return TRUE; } diff --git a/bfd/elf32-vax.c b/bfd/elf32-vax.c index eb5bd9e0b34..8b55a0c34a8 100644 --- a/bfd/elf32-vax.c +++ b/bfd/elf32-vax.c @@ -839,7 +839,7 @@ elf_vax_adjust_dynamic_symbol (struct bfd_link_info *info, /* Make sure we know what is going on here. */ BFD_ASSERT (dynobj != NULL && (h->needs_plt - || h->u.weakdef != NULL + || h->is_weakalias || (h->def_dynamic && h->ref_regular && !h->def_regular))); @@ -915,12 +915,12 @@ elf_vax_adjust_dynamic_symbol (struct bfd_link_info *info, /* If this is a weak symbol, and there is a real definition, the processor independent code will have arranged for us to see the real definition first, and we can just use the same value. */ - if (h->u.weakdef != NULL) + if (h->is_weakalias) { - BFD_ASSERT (h->u.weakdef->root.type == bfd_link_hash_defined - || h->u.weakdef->root.type == bfd_link_hash_defweak); - h->root.u.def.section = h->u.weakdef->root.u.def.section; - h->root.u.def.value = h->u.weakdef->root.u.def.value; + struct elf_link_hash_entry *def = weakdef (h); + BFD_ASSERT (def->root.type == bfd_link_hash_defined); + h->root.u.def.section = def->root.u.def.section; + h->root.u.def.value = def->root.u.def.value; return TRUE; } diff --git a/bfd/elf32-xtensa.c b/bfd/elf32-xtensa.c index e320e20c887..6aba5bc638f 100644 --- a/bfd/elf32-xtensa.c +++ b/bfd/elf32-xtensa.c @@ -1387,12 +1387,12 @@ elf_xtensa_adjust_dynamic_symbol (struct bfd_link_info *info ATTRIBUTE_UNUSED, /* If this is a weak symbol, and there is a real definition, the processor independent code will have arranged for us to see the real definition first, and we can just use the same value. */ - if (h->u.weakdef) + if (h->is_weakalias) { - BFD_ASSERT (h->u.weakdef->root.type == bfd_link_hash_defined - || h->u.weakdef->root.type == bfd_link_hash_defweak); - h->root.u.def.section = h->u.weakdef->root.u.def.section; - h->root.u.def.value = h->u.weakdef->root.u.def.value; + struct elf_link_hash_entry *def = weakdef (h); + BFD_ASSERT (def->root.type == bfd_link_hash_defined); + h->root.u.def.section = def->root.u.def.section; + h->root.u.def.value = def->root.u.def.value; return TRUE; } diff --git a/bfd/elf64-alpha.c b/bfd/elf64-alpha.c index d90c0168afe..9b2ad36e756 100644 --- a/bfd/elf64-alpha.c +++ b/bfd/elf64-alpha.c @@ -2082,12 +2082,12 @@ elf64_alpha_adjust_dynamic_symbol (struct bfd_link_info *info, /* If this is a weak symbol, and there is a real definition, the processor independent code will have arranged for us to see the real definition first, and we can just use the same value. */ - if (h->u.weakdef != NULL) + if (h->is_weakalias) { - BFD_ASSERT (h->u.weakdef->root.type == bfd_link_hash_defined - || h->u.weakdef->root.type == bfd_link_hash_defweak); - h->root.u.def.section = h->u.weakdef->root.u.def.section; - h->root.u.def.value = h->u.weakdef->root.u.def.value; + struct elf_link_hash_entry *def = weakdef (h); + BFD_ASSERT (def->root.type == bfd_link_hash_defined); + h->root.u.def.section = def->root.u.def.section; + h->root.u.def.value = def->root.u.def.value; return TRUE; } diff --git a/bfd/elf64-hppa.c b/bfd/elf64-hppa.c index 9fefe0eb39c..3f6dec1d728 100644 --- a/bfd/elf64-hppa.c +++ b/bfd/elf64-hppa.c @@ -1474,12 +1474,12 @@ elf64_hppa_adjust_dynamic_symbol (struct bfd_link_info *info ATTRIBUTE_UNUSED, /* If this is a weak symbol, and there is a real definition, the processor independent code will have arranged for us to see the real definition first, and we can just use the same value. */ - if (eh->u.weakdef != NULL) + if (eh->is_weakalias) { - BFD_ASSERT (eh->u.weakdef->root.type == bfd_link_hash_defined - || eh->u.weakdef->root.type == bfd_link_hash_defweak); - eh->root.u.def.section = eh->u.weakdef->root.u.def.section; - eh->root.u.def.value = eh->u.weakdef->root.u.def.value; + struct elf_link_hash_entry *def = weakdef (eh); + BFD_ASSERT (def->root.type == bfd_link_hash_defined); + eh->root.u.def.section = def->root.u.def.section; + eh->root.u.def.value = def->root.u.def.value; return TRUE; } diff --git a/bfd/elf64-ia64-vms.c b/bfd/elf64-ia64-vms.c index 8140dc5f3ad..1fc0957d4c2 100644 --- a/bfd/elf64-ia64-vms.c +++ b/bfd/elf64-ia64-vms.c @@ -2575,12 +2575,12 @@ elf64_ia64_adjust_dynamic_symbol (struct bfd_link_info *info ATTRIBUTE_UNUSED, /* If this is a weak symbol, and there is a real definition, the processor independent code will have arranged for us to see the real definition first, and we can just use the same value. */ - if (h->u.weakdef != NULL) + if (h->is_weakalias) { - BFD_ASSERT (h->u.weakdef->root.type == bfd_link_hash_defined - || h->u.weakdef->root.type == bfd_link_hash_defweak); - h->root.u.def.section = h->u.weakdef->root.u.def.section; - h->root.u.def.value = h->u.weakdef->root.u.def.value; + struct elf_link_hash_entry *def = weakdef (h); + BFD_ASSERT (def->root.type == bfd_link_hash_defined); + h->root.u.def.section = def->root.u.def.section; + h->root.u.def.value = def->root.u.def.value; return TRUE; } diff --git a/bfd/elf64-ppc.c b/bfd/elf64-ppc.c index 8a48848eb27..1a4b7216149 100644 --- a/bfd/elf64-ppc.c +++ b/bfd/elf64-ppc.c @@ -6576,8 +6576,8 @@ ppc64_elf_gc_mark_hook (asection *sec, a call reloc. Mark the function descriptor too against garbage collection. */ fdh->elf.mark = 1; - if (fdh->elf.u.weakdef != NULL) - fdh->elf.u.weakdef->mark = 1; + if (fdh->elf.is_weakalias) + weakdef (&fdh->elf)->mark = 1; eh = fdh; } @@ -7251,14 +7251,14 @@ ppc64_elf_adjust_dynamic_symbol (struct bfd_link_info *info, /* If this is a weak symbol, and there is a real definition, the processor independent code will have arranged for us to see the real definition first, and we can just use the same value. */ - if (h->u.weakdef != NULL) + if (h->is_weakalias) { - BFD_ASSERT (h->u.weakdef->root.type == bfd_link_hash_defined - || h->u.weakdef->root.type == bfd_link_hash_defweak); - h->root.u.def.section = h->u.weakdef->root.u.def.section; - h->root.u.def.value = h->u.weakdef->root.u.def.value; + struct elf_link_hash_entry *def = weakdef (h); + BFD_ASSERT (def->root.type == bfd_link_hash_defined); + h->root.u.def.section = def->root.u.def.section; + h->root.u.def.value = def->root.u.def.value; if (ELIMINATE_COPY_RELOCS) - h->non_got_ref = h->u.weakdef->non_got_ref; + h->non_got_ref = def->non_got_ref; return TRUE; } diff --git a/bfd/elf64-s390.c b/bfd/elf64-s390.c index 08cc19c5eec..5402a8d3948 100644 --- a/bfd/elf64-s390.c +++ b/bfd/elf64-s390.c @@ -1446,14 +1446,14 @@ elf_s390_adjust_dynamic_symbol (struct bfd_link_info *info, /* If this is a weak symbol, and there is a real definition, the processor independent code will have arranged for us to see the real definition first, and we can just use the same value. */ - if (h->u.weakdef != NULL) + if (h->is_weakalias) { - BFD_ASSERT (h->u.weakdef->root.type == bfd_link_hash_defined - || h->u.weakdef->root.type == bfd_link_hash_defweak); - h->root.u.def.section = h->u.weakdef->root.u.def.section; - h->root.u.def.value = h->u.weakdef->root.u.def.value; + struct elf_link_hash_entry *def = weakdef (h); + BFD_ASSERT (def->root.type == bfd_link_hash_defined); + h->root.u.def.section = def->root.u.def.section; + h->root.u.def.value = def->root.u.def.value; if (ELIMINATE_COPY_RELOCS || info->nocopyreloc) - h->non_got_ref = h->u.weakdef->non_got_ref; + h->non_got_ref = def->non_got_ref; return TRUE; } diff --git a/bfd/elf64-sh64.c b/bfd/elf64-sh64.c index 8994e21daff..7133144eeaa 100644 --- a/bfd/elf64-sh64.c +++ b/bfd/elf64-sh64.c @@ -3192,7 +3192,7 @@ sh64_elf64_adjust_dynamic_symbol (struct bfd_link_info *info, /* Make sure we know what is going on here. */ BFD_ASSERT (dynobj != NULL && (h->needs_plt - || h->u.weakdef != NULL + || h->is_weakalias || (h->def_dynamic && h->ref_regular && !h->def_regular))); @@ -3267,12 +3267,12 @@ sh64_elf64_adjust_dynamic_symbol (struct bfd_link_info *info, /* If this is a weak symbol, and there is a real definition, the processor independent code will have arranged for us to see the real definition first, and we can just use the same value. */ - if (h->u.weakdef != NULL) + if (h->is_weakalias) { - BFD_ASSERT (h->u.weakdef->root.type == bfd_link_hash_defined - || h->u.weakdef->root.type == bfd_link_hash_defweak); - h->root.u.def.section = h->u.weakdef->root.u.def.section; - h->root.u.def.value = h->u.weakdef->root.u.def.value; + struct elf_link_hash_entry *def = weakdef (h); + BFD_ASSERT (def->root.type == bfd_link_hash_defined); + h->root.u.def.section = def->root.u.def.section; + h->root.u.def.value = def->root.u.def.value; return TRUE; } diff --git a/bfd/elflink.c b/bfd/elflink.c index 72886d57e50..99f867dc75c 100644 --- a/bfd/elflink.c +++ b/bfd/elflink.c @@ -723,10 +723,12 @@ bfd_elf_record_link_assignment (bfd *output_bfd, /* If this is a weak defined symbol, and we know a corresponding real symbol from the same dynamic object, make sure the real symbol is also made into a dynamic symbol. */ - if (h->u.weakdef != NULL - && h->u.weakdef->dynindx == -1) + if (h->is_weakalias) { - if (! bfd_elf_link_record_dynamic_symbol (info, h->u.weakdef)) + struct elf_link_hash_entry *def = weakdef (h); + + if (def->dynindx == -1 + && !bfd_elf_link_record_dynamic_symbol (info, def)) return FALSE; } } @@ -2782,26 +2784,28 @@ _bfd_elf_fix_symbol_flags (struct elf_link_hash_entry *h, /* If this is a weak defined symbol in a dynamic object, and we know the real definition in the dynamic object, copy interesting flags over to the real definition. */ - if (h->u.weakdef != NULL) + if (h->is_weakalias) { + struct elf_link_hash_entry *def = weakdef (h); + /* If the real definition is defined by a regular object file, don't do anything special. See the longer description in _bfd_elf_adjust_dynamic_symbol, below. */ - if (h->u.weakdef->def_regular) - h->u.weakdef = NULL; + if (def->def_regular) + { + h = def; + while ((h = h->u.alias) != def) + h->is_weakalias = 0; + } else { - struct elf_link_hash_entry *weakdef = h->u.weakdef; - while (h->root.type == bfd_link_hash_indirect) h = (struct elf_link_hash_entry *) h->root.u.i.link; - BFD_ASSERT (h->root.type == bfd_link_hash_defined || h->root.type == bfd_link_hash_defweak); - BFD_ASSERT (weakdef->def_dynamic); - BFD_ASSERT (weakdef->root.type == bfd_link_hash_defined - || weakdef->root.type == bfd_link_hash_defweak); - (*bed->elf_backend_copy_indirect_symbol) (eif->info, weakdef, h); + BFD_ASSERT (def->def_dynamic); + BFD_ASSERT (def->root.type == bfd_link_hash_defined); + (*bed->elf_backend_copy_indirect_symbol) (eif->info, def, h); } } @@ -2863,7 +2867,7 @@ _bfd_elf_adjust_dynamic_symbol (struct elf_link_hash_entry *h, void *data) && (h->def_regular || !h->def_dynamic || (!h->ref_regular - && (h->u.weakdef == NULL || h->u.weakdef->dynindx == -1)))) + && (!h->is_weakalias || weakdef (h)->dynindx == -1)))) { h->plt = elf_hash_table (eif->info)->init_plt_offset; return TRUE; @@ -2908,15 +2912,17 @@ _bfd_elf_adjust_dynamic_symbol (struct elf_link_hash_entry *h, void *data) wind up at different memory locations. The tzset call will set _timezone, leaving timezone unchanged. */ - if (h->u.weakdef != NULL) + if (h->is_weakalias) { + struct elf_link_hash_entry *def = weakdef (h); + /* If we get to this point, there is an implicit reference to - H->U.WEAKDEF by a regular object file via the weak symbol H. */ - h->u.weakdef->ref_regular = 1; + the alias by a regular object file via the weak symbol H. */ + def->ref_regular = 1; /* Ensure that the backend adjust_dynamic_symbol function sees - H->U.WEAKDEF before H by recursively calling ourselves. */ - if (! _bfd_elf_adjust_dynamic_symbol (h->u.weakdef, eif)) + the strong alias before H by recursively calling ourselves. */ + if (!_bfd_elf_adjust_dynamic_symbol (def, eif)) return FALSE; } @@ -4256,7 +4262,6 @@ error_free_dyn: bfd_boolean definition; bfd_boolean size_change_ok; bfd_boolean type_change_ok; - bfd_boolean new_weakdef; bfd_boolean new_weak; bfd_boolean old_weak; bfd_boolean override; @@ -4588,29 +4593,27 @@ error_free_dyn: *sym_hash = h; new_weak = (flags & BSF_WEAK) != 0; - new_weakdef = FALSE; if (dynamic && definition && new_weak && !bed->is_function_type (ELF_ST_TYPE (isym->st_info)) && is_elf_hash_table (htab) - && h->u.weakdef == NULL) + && h->u.alias == NULL) { /* Keep a list of all weak defined non function symbols from - a dynamic object, using the weakdef field. Later in this - function we will set the weakdef field to the correct + a dynamic object, using the alias field. Later in this + function we will set the alias field to the correct value. We only put non-function symbols from dynamic objects on this list, because that happens to be the only time we need to know the normal symbol corresponding to a weak symbol, and the information is time consuming to - figure out. If the weakdef field is not already NULL, + figure out. If the alias field is not already NULL, then this symbol was already defined by some previous dynamic object, and we will be using that previous definition anyhow. */ - h->u.weakdef = weaks; + h->u.alias = weaks; weaks = h; - new_weakdef = TRUE; } /* Set the alignment of a common symbol. */ @@ -4689,9 +4692,8 @@ error_free_dyn: if ((h == hi || !hi->forced_local) && (h->def_regular || h->ref_regular - || (h->u.weakdef != NULL - && ! new_weakdef - && h->u.weakdef->dynindx != -1))) + || (h->is_weakalias + && weakdef (h)->dynindx != -1))) dynsym = TRUE; } @@ -4860,11 +4862,10 @@ error_free_dyn: { if (! bfd_elf_link_record_dynamic_symbol (info, h)) goto error_free_vers; - if (h->u.weakdef != NULL - && ! new_weakdef - && h->u.weakdef->dynindx == -1) + if (h->is_weakalias + && weakdef (h)->dynindx == -1) { - if (!bfd_elf_link_record_dynamic_symbol (info, h->u.weakdef)) + if (!bfd_elf_link_record_dynamic_symbol (info, weakdef (h))) goto error_free_vers; } } @@ -5084,7 +5085,7 @@ error_free_dyn: nondeflt_vers = NULL; } - /* Now set the weakdefs field correctly for all the weak defined + /* Now set the alias field correctly for all the weak defined symbols we found. The only way to do this is to search all the symbols. Since we only need the information for non functions in dynamic objects, that's the only time we actually put anything on @@ -5142,8 +5143,8 @@ error_free_dyn: size_t i, j, idx = 0; hlook = weaks; - weaks = hlook->u.weakdef; - hlook->u.weakdef = NULL; + weaks = hlook->u.alias; + hlook->u.alias = NULL; if (hlook->root.type != bfd_link_hash_defined && hlook->root.type != bfd_link_hash_defweak) @@ -5205,7 +5206,15 @@ error_free_dyn: break; else if (h != hlook) { - hlook->u.weakdef = h; + struct elf_link_hash_entry *t; + + hlook->u.alias = h; + hlook->is_weakalias = 1; + t = h; + if (t->u.alias != NULL) + while (t->u.alias != h) + t = t->u.alias; + t->u.alias = hlook; /* If the weak definition is in the list of dynamic symbols, make sure the real definition is put @@ -12756,8 +12765,8 @@ _bfd_elf_gc_mark_rsec (struct bfd_link_info *info, asection *sec, keep the non-weak definition because many backends put dynamic reloc info on the non-weak definition for code handling copy relocs. */ - if (h->u.weakdef != NULL) - h->u.weakdef->mark = 1; + if (h->is_weakalias) + weakdef (h)->mark = 1; if (start_stop != NULL) { diff --git a/bfd/elfnn-aarch64.c b/bfd/elfnn-aarch64.c index 23c881c51d8..45218843d5c 100644 --- a/bfd/elfnn-aarch64.c +++ b/bfd/elfnn-aarch64.c @@ -6761,14 +6761,14 @@ elfNN_aarch64_adjust_dynamic_symbol (struct bfd_link_info *info, /* If this is a weak symbol, and there is a real definition, the processor independent code will have arranged for us to see the real definition first, and we can just use the same value. */ - if (h->u.weakdef != NULL) + if (h->is_weakalias) { - BFD_ASSERT (h->u.weakdef->root.type == bfd_link_hash_defined - || h->u.weakdef->root.type == bfd_link_hash_defweak); - h->root.u.def.section = h->u.weakdef->root.u.def.section; - h->root.u.def.value = h->u.weakdef->root.u.def.value; + struct elf_link_hash_entry *def = weakdef (h); + BFD_ASSERT (def->root.type == bfd_link_hash_defined); + h->root.u.def.section = def->root.u.def.section; + h->root.u.def.value = def->root.u.def.value; if (ELIMINATE_COPY_RELOCS || info->nocopyreloc) - h->non_got_ref = h->u.weakdef->non_got_ref; + h->non_got_ref = def->non_got_ref; return TRUE; } diff --git a/bfd/elfnn-ia64.c b/bfd/elfnn-ia64.c index 8a2f5e3005f..0c441a8891a 100644 --- a/bfd/elfnn-ia64.c +++ b/bfd/elfnn-ia64.c @@ -2963,12 +2963,12 @@ elfNN_ia64_adjust_dynamic_symbol (struct bfd_link_info *info ATTRIBUTE_UNUSED, /* If this is a weak symbol, and there is a real definition, the processor independent code will have arranged for us to see the real definition first, and we can just use the same value. */ - if (h->u.weakdef != NULL) + if (h->is_weakalias) { - BFD_ASSERT (h->u.weakdef->root.type == bfd_link_hash_defined - || h->u.weakdef->root.type == bfd_link_hash_defweak); - h->root.u.def.section = h->u.weakdef->root.u.def.section; - h->root.u.def.value = h->u.weakdef->root.u.def.value; + struct elf_link_hash_entry *def = weakdef (h); + BFD_ASSERT (def->root.type == bfd_link_hash_defined); + h->root.u.def.section = def->root.u.def.section; + h->root.u.def.value = def->root.u.def.value; return TRUE; } diff --git a/bfd/elfnn-riscv.c b/bfd/elfnn-riscv.c index e782a6083eb..4be12be1fb1 100644 --- a/bfd/elfnn-riscv.c +++ b/bfd/elfnn-riscv.c @@ -786,7 +786,7 @@ riscv_elf_adjust_dynamic_symbol (struct bfd_link_info *info, BFD_ASSERT (dynobj != NULL && (h->needs_plt || h->type == STT_GNU_IFUNC - || h->u.weakdef != NULL + || h->is_weakalias || (h->def_dynamic && h->ref_regular && !h->def_regular))); @@ -817,12 +817,12 @@ riscv_elf_adjust_dynamic_symbol (struct bfd_link_info *info, /* If this is a weak symbol, and there is a real definition, the processor independent code will have arranged for us to see the real definition first, and we can just use the same value. */ - if (h->u.weakdef != NULL) + if (h->is_weakalias) { - BFD_ASSERT (h->u.weakdef->root.type == bfd_link_hash_defined - || h->u.weakdef->root.type == bfd_link_hash_defweak); - h->root.u.def.section = h->u.weakdef->root.u.def.section; - h->root.u.def.value = h->u.weakdef->root.u.def.value; + struct elf_link_hash_entry *def = weakdef (h); + BFD_ASSERT (def->root.type == bfd_link_hash_defined); + h->root.u.def.section = def->root.u.def.section; + h->root.u.def.value = def->root.u.def.value; return TRUE; } diff --git a/bfd/elfxx-mips.c b/bfd/elfxx-mips.c index d279e0b94c0..c3b8ec9f49c 100644 --- a/bfd/elfxx-mips.c +++ b/bfd/elfxx-mips.c @@ -9012,7 +9012,7 @@ _bfd_mips_elf_adjust_dynamic_symbol (struct bfd_link_info *info, /* Make sure we know what is going on here. */ BFD_ASSERT (dynobj != NULL && (h->needs_plt - || h->u.weakdef != NULL + || h->is_weakalias || (h->def_dynamic && h->ref_regular && !h->def_regular))); @@ -9204,12 +9204,12 @@ _bfd_mips_elf_adjust_dynamic_symbol (struct bfd_link_info *info, /* If this is a weak symbol, and there is a real definition, the processor independent code will have arranged for us to see the real definition first, and we can just use the same value. */ - if (h->u.weakdef != NULL) + if (h->is_weakalias) { - BFD_ASSERT (h->u.weakdef->root.type == bfd_link_hash_defined - || h->u.weakdef->root.type == bfd_link_hash_defweak); - h->root.u.def.section = h->u.weakdef->root.u.def.section; - h->root.u.def.value = h->u.weakdef->root.u.def.value; + struct elf_link_hash_entry *def = weakdef (h); + BFD_ASSERT (def->root.type == bfd_link_hash_defined); + h->root.u.def.section = def->root.u.def.section; + h->root.u.def.value = def->root.u.def.value; return TRUE; } diff --git a/bfd/elfxx-sparc.c b/bfd/elfxx-sparc.c index 873062d23db..856adebbac6 100644 --- a/bfd/elfxx-sparc.c +++ b/bfd/elfxx-sparc.c @@ -1932,8 +1932,8 @@ _bfd_sparc_elf_gc_mark_hook (asection *sec, FALSE, FALSE, TRUE); BFD_ASSERT (h != NULL); h->mark = 1; - if (h->u.weakdef != NULL) - h->u.weakdef->mark = 1; + if (h->is_weakalias) + weakdef (h)->mark = 1; sym = NULL; } } @@ -1995,7 +1995,7 @@ _bfd_sparc_elf_adjust_dynamic_symbol (struct bfd_link_info *info, BFD_ASSERT (htab->elf.dynobj != NULL && (h->needs_plt || h->type == STT_GNU_IFUNC - || h->u.weakdef != NULL + || h->is_weakalias || (h->def_dynamic && h->ref_regular && !h->def_regular))); @@ -2038,12 +2038,12 @@ _bfd_sparc_elf_adjust_dynamic_symbol (struct bfd_link_info *info, /* If this is a weak symbol, and there is a real definition, the processor independent code will have arranged for us to see the real definition first, and we can just use the same value. */ - if (h->u.weakdef != NULL) + if (h->is_weakalias) { - BFD_ASSERT (h->u.weakdef->root.type == bfd_link_hash_defined - || h->u.weakdef->root.type == bfd_link_hash_defweak); - h->root.u.def.section = h->u.weakdef->root.u.def.section; - h->root.u.def.value = h->u.weakdef->root.u.def.value; + struct elf_link_hash_entry *def = weakdef (h); + BFD_ASSERT (def->root.type == bfd_link_hash_defined); + h->root.u.def.section = def->root.u.def.section; + h->root.u.def.value = def->root.u.def.value; return TRUE; } diff --git a/bfd/elfxx-tilegx.c b/bfd/elfxx-tilegx.c index 2523813b456..b62fa334b12 100644 --- a/bfd/elfxx-tilegx.c +++ b/bfd/elfxx-tilegx.c @@ -2123,8 +2123,8 @@ tilegx_elf_gc_mark_hook (asection *sec, h = (struct elf_link_hash_entry *) bh; BFD_ASSERT (h != NULL); h->mark = 1; - if (h->u.weakdef != NULL) - h->u.weakdef->mark = 1; + if (h->is_weakalias) + weakdef (h)->mark = 1; sym = NULL; } } @@ -2156,7 +2156,7 @@ tilegx_elf_adjust_dynamic_symbol (struct bfd_link_info *info, /* Make sure we know what is going on here. */ BFD_ASSERT (dynobj != NULL && (h->needs_plt - || h->u.weakdef != NULL + || h->is_weakalias || (h->def_dynamic && h->ref_regular && !h->def_regular))); @@ -2189,12 +2189,12 @@ tilegx_elf_adjust_dynamic_symbol (struct bfd_link_info *info, /* If this is a weak symbol, and there is a real definition, the processor independent code will have arranged for us to see the real definition first, and we can just use the same value. */ - if (h->u.weakdef != NULL) + if (h->is_weakalias) { - BFD_ASSERT (h->u.weakdef->root.type == bfd_link_hash_defined - || h->u.weakdef->root.type == bfd_link_hash_defweak); - h->root.u.def.section = h->u.weakdef->root.u.def.section; - h->root.u.def.value = h->u.weakdef->root.u.def.value; + struct elf_link_hash_entry *def = weakdef (h); + BFD_ASSERT (def->root.type == bfd_link_hash_defined); + h->root.u.def.section = def->root.u.def.section; + h->root.u.def.value = def->root.u.def.value; return TRUE; } diff --git a/bfd/elfxx-x86.c b/bfd/elfxx-x86.c index e58e3d0ebb4..ecb8b9dd106 100644 --- a/bfd/elfxx-x86.c +++ b/bfd/elfxx-x86.c @@ -1765,19 +1765,19 @@ _bfd_x86_elf_adjust_dynamic_symbol (struct bfd_link_info *info, /* If this is a weak symbol, and there is a real definition, the processor independent code will have arranged for us to see the real definition first, and we can just use the same value. */ - if (h->u.weakdef != NULL) + if (h->is_weakalias) { - BFD_ASSERT (h->u.weakdef->root.type == bfd_link_hash_defined - || h->u.weakdef->root.type == bfd_link_hash_defweak); - h->root.u.def.section = h->u.weakdef->root.u.def.section; - h->root.u.def.value = h->u.weakdef->root.u.def.value; + struct elf_link_hash_entry *def = weakdef (h); + BFD_ASSERT (def->root.type == bfd_link_hash_defined); + h->root.u.def.section = def->root.u.def.section; + h->root.u.def.value = def->root.u.def.value; if (ELIMINATE_COPY_RELOCS || info->nocopyreloc || SYMBOL_NO_COPYRELOC (info, eh)) { /* NB: needs_copy is always 0 for i386. */ - h->non_got_ref = h->u.weakdef->non_got_ref; - eh->needs_copy = h->u.weakdef->needs_copy; + h->non_got_ref = def->non_got_ref; + eh->needs_copy = def->needs_copy; } return TRUE; } -- 2.30.2