diff options
author | Alan Modra <amodra@gmail.com> | 2017-11-22 17:30:55 +1030 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2017-11-23 22:40:25 +1030 |
commit | 60d67dc84bbc7d73672d297d714f8a4a0547618d (patch) | |
tree | e92f5bc1f65475b85a0c9ddf8902c5dcb770b98d /bfd/elf-bfd.h | |
parent | 9d9c67b06c1bf4c4550e3de0eb575c2bfbe96df9 (diff) | |
download | gdb-60d67dc84bbc7d73672d297d714f8a4a0547618d.zip gdb-60d67dc84bbc7d73672d297d714f8a4a0547618d.tar.gz gdb-60d67dc84bbc7d73672d297d714f8a4a0547618d.tar.bz2 |
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.
Diffstat (limited to 'bfd/elf-bfd.h')
-rw-r--r-- | bfd/elf-bfd.h | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/bfd/elf-bfd.h b/bfd/elf-bfd.h index 954105e..aebfbd9 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) \ |