From 9637f6ef78ecc63d9fca3ccffe825fb8e908a575 Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Sun, 2 Sep 2012 12:17:27 +0000 Subject: [PATCH] Add hdynamic to elf_link_hash_table for _DYNAMIC * elf-bfd.h (elf_link_hash_table): Add hdynamic for the _DYNAMIC symbol. * elflink.c (_bfd_elf_link_create_dynamic_sections): Set hdynamic. * elf-m10300.c (_bfd_mn10300_elf_finish_dynamic_symbol): Check hdynamic instead of "_DYNAMIC". * elf32-arm.c (elf32_arm_finish_dynamic_symbol): Likewise. * elf32-cr16.c (elf32_arm_finish_dynamic_symbol): Likewise. * elf32-cris.c (elf_cris_finish_dynamic_symbol): Likewise. * elf32-hppa.c (elf32_hppa_finish_dynamic_symbol): Likewise. * elf32-i386.c (elf_i386_convert_mov_to_lea): Likewise. * elf32-lm32.c (lm32_elf_finish_dynamic_symbol): Likewise. * elf32-m32r.c (m32r_elf_finish_dynamic_symbol): Likewise. * elf32-s390.c (elf_s390_finish_dynamic_symbol): Likewise. * elf32-sh.c (sh_elf_finish_dynamic_symbol): Likewise. * elf32-tic6x.c (elf32_tic6x_finish_dynamic_symbol): Likewise. * elf32-tilepro.c (tilepro_elf_finish_dynamic_symbol): Likewise. * elf32-vax.c (elf_vax_finish_dynamic_symbol): Likewise. * elf32-xtensa.c (elf_xtensa_finish_dynamic_symbol): Likewise. * elf64-aarch64.c elf64_aarch64_finish_dynamic_symbol(): Likewise. * elf64-alpha.c (elf64_alpha_finish_dynamic_symbol): Likewise. * elf64-ia64-vms.c (elf64_ia64_finish_dynamic_symbol): Likewise. * elf64-s390.c (elf_s390_finish_dynamic_symbol): Likewise. * elf64-sh64.c (sh64_elf64_finish_dynamic_symbol): Likewise. * elf64-x86-64.c (elf_x86_64_convert_mov_to_lea): Likewise. * elfnn-ia64.c (elfNN_ia64_finish_dynamic_symbol): Likewise. * elfxx-mips.c (_bfd_mips_elf_finish_dynamic_symbol): Likewise. * elfxx-sparc.c (_bfd_sparc_elf_finish_dynamic_symbol): Likewise. * elfxx-tilegx.c (tilegx_elf_finish_dynamic_symbol): Likewise. * elf32-microblaze.c (microblaze_elf_finish_dynamic_symbol): Check hdynamic, hgot, hplt instead of _DYNAMIC, _GLOBAL_OFFSET_TABLE_, _PROCEDURE_LINKAGE_TABLE_. * elf32-score.c (s3_bfd_score_elf_finish_dynamic_symbol): Likewise. * elf32-score7.c (s7_bfd_score_elf_finish_dynamic_symbol): Likewise. --- bfd/ChangeLog | 40 ++++++++++++++++++++++++++++++++++++++++ bfd/elf-bfd.h | 3 +++ bfd/elf-m10300.c | 2 +- bfd/elf32-arm.c | 2 +- bfd/elf32-cr16.c | 2 +- bfd/elf32-cris.c | 2 +- bfd/elf32-hppa.c | 4 +--- bfd/elf32-i386.c | 2 +- bfd/elf32-lm32.c | 3 +-- bfd/elf32-m32r.c | 3 +-- bfd/elf32-microblaze.c | 6 +++--- bfd/elf32-s390.c | 2 +- bfd/elf32-score.c | 3 ++- bfd/elf32-score7.c | 3 ++- bfd/elf32-sh.c | 2 +- bfd/elf32-tic6x.c | 2 +- bfd/elf32-tilepro.c | 2 +- bfd/elf32-vax.c | 2 +- bfd/elf32-xtensa.c | 2 +- bfd/elf64-aarch64.c | 2 +- bfd/elf64-alpha.c | 2 +- bfd/elf64-ia64-vms.c | 2 +- bfd/elf64-s390.c | 2 +- bfd/elf64-sh64.c | 2 +- bfd/elf64-x86-64.c | 2 +- bfd/elflink.c | 5 ++++- bfd/elfnn-ia64.c | 2 +- bfd/elfxx-mips.c | 2 +- bfd/elfxx-sparc.c | 2 +- bfd/elfxx-tilegx.c | 2 +- 30 files changed, 78 insertions(+), 34 deletions(-) diff --git a/bfd/ChangeLog b/bfd/ChangeLog index d545c1d0e1..ee9937244e 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,43 @@ +2012-09-02 H.J. Lu + + * elf-bfd.h (elf_link_hash_table): Add hdynamic for the + _DYNAMIC symbol. + + * elflink.c (_bfd_elf_link_create_dynamic_sections): Set + hdynamic. + + * elf-m10300.c (_bfd_mn10300_elf_finish_dynamic_symbol): Check + hdynamic instead of "_DYNAMIC". + * elf32-arm.c (elf32_arm_finish_dynamic_symbol): Likewise. + * elf32-cr16.c (elf32_arm_finish_dynamic_symbol): Likewise. + * elf32-cris.c (elf_cris_finish_dynamic_symbol): Likewise. + * elf32-hppa.c (elf32_hppa_finish_dynamic_symbol): Likewise. + * elf32-i386.c (elf_i386_convert_mov_to_lea): Likewise. + * elf32-lm32.c (lm32_elf_finish_dynamic_symbol): Likewise. + * elf32-m32r.c (m32r_elf_finish_dynamic_symbol): Likewise. + * elf32-s390.c (elf_s390_finish_dynamic_symbol): Likewise. + * elf32-sh.c (sh_elf_finish_dynamic_symbol): Likewise. + * elf32-tic6x.c (elf32_tic6x_finish_dynamic_symbol): Likewise. + * elf32-tilepro.c (tilepro_elf_finish_dynamic_symbol): Likewise. + * elf32-vax.c (elf_vax_finish_dynamic_symbol): Likewise. + * elf32-xtensa.c (elf_xtensa_finish_dynamic_symbol): Likewise. + * elf64-aarch64.c elf64_aarch64_finish_dynamic_symbol(): Likewise. + * elf64-alpha.c (elf64_alpha_finish_dynamic_symbol): Likewise. + * elf64-ia64-vms.c (elf64_ia64_finish_dynamic_symbol): Likewise. + * elf64-s390.c (elf_s390_finish_dynamic_symbol): Likewise. + * elf64-sh64.c (sh64_elf64_finish_dynamic_symbol): Likewise. + * elf64-x86-64.c (elf_x86_64_convert_mov_to_lea): Likewise. + * elfnn-ia64.c (elfNN_ia64_finish_dynamic_symbol): Likewise. + * elfxx-mips.c (_bfd_mips_elf_finish_dynamic_symbol): Likewise. + * elfxx-sparc.c (_bfd_sparc_elf_finish_dynamic_symbol): Likewise. + * elfxx-tilegx.c (tilegx_elf_finish_dynamic_symbol): Likewise. + + * elf32-microblaze.c (microblaze_elf_finish_dynamic_symbol): Check + hdynamic, hgot, hplt instead of _DYNAMIC, _GLOBAL_OFFSET_TABLE_, + _PROCEDURE_LINKAGE_TABLE_. + * elf32-score.c (s3_bfd_score_elf_finish_dynamic_symbol): Likewise. + * elf32-score7.c (s7_bfd_score_elf_finish_dynamic_symbol): Likewise. + 2012-08-31 H.J. Lu * elf32-i386.c (elf_i386_convert_mov_to_lea): Don't optimize diff --git a/bfd/elf-bfd.h b/bfd/elf-bfd.h index e57528ea0f..12250365a4 100644 --- a/bfd/elf-bfd.h +++ b/bfd/elf-bfd.h @@ -498,6 +498,9 @@ struct elf_link_hash_table /* The _PROCEDURE_LINKAGE_TABLE_ symbol. */ struct elf_link_hash_entry *hplt; + /* The _DYNAMIC symbol. */ + struct elf_link_hash_entry *hdynamic; + /* A pointer to information used to merge SEC_MERGE sections. */ void *merge_info; diff --git a/bfd/elf-m10300.c b/bfd/elf-m10300.c index 709ea161eb..b44a4b475b 100644 --- a/bfd/elf-m10300.c +++ b/bfd/elf-m10300.c @@ -5395,7 +5395,7 @@ _bfd_mn10300_elf_finish_dynamic_symbol (bfd * output_bfd, } /* Mark _DYNAMIC and _GLOBAL_OFFSET_TABLE_ as absolute. */ - if (streq (h->root.root.string, "_DYNAMIC") + if (h == elf_hash_table (info)->hdynamic || h == elf_hash_table (info)->hgot) sym->st_shndx = SHN_ABS; diff --git a/bfd/elf32-arm.c b/bfd/elf32-arm.c index a287fbbe56..633bb648a7 100644 --- a/bfd/elf32-arm.c +++ b/bfd/elf32-arm.c @@ -14003,7 +14003,7 @@ elf32_arm_finish_dynamic_symbol (bfd * output_bfd, /* Mark _DYNAMIC and _GLOBAL_OFFSET_TABLE_ as absolute. On VxWorks, the _GLOBAL_OFFSET_TABLE_ symbol is not absolute: it is relative to the ".got" section. */ - if (strcmp (h->root.root.string, "_DYNAMIC") == 0 + if (h == htab->root.hdynamic || (!htab->vxworks_p && h == htab->root.hgot)) sym->st_shndx = SHN_ABS; diff --git a/bfd/elf32-cr16.c b/bfd/elf32-cr16.c index 97fa5691e6..46769f55b5 100644 --- a/bfd/elf32-cr16.c +++ b/bfd/elf32-cr16.c @@ -2698,7 +2698,7 @@ _bfd_cr16_elf_finish_dynamic_symbol (bfd * output_bfd, } /* Mark _DYNAMIC and _GLOBAL_OFFSET_TABLE_ as absolute. */ - if (strcmp (h->root.root.string, "_DYNAMIC") == 0 + if (h == elf_hash_table (info)->hdynamic || h == elf_hash_table (info)->hgot) sym->st_shndx = SHN_ABS; diff --git a/bfd/elf32-cris.c b/bfd/elf32-cris.c index c9316ee195..33afc63f16 100644 --- a/bfd/elf32-cris.c +++ b/bfd/elf32-cris.c @@ -2288,7 +2288,7 @@ elf_cris_finish_dynamic_symbol (bfd *output_bfd, } /* Mark _DYNAMIC and _GLOBAL_OFFSET_TABLE_ as absolute. */ - if (strcmp (h->root.root.string, "_DYNAMIC") == 0 + if (h == elf_hash_table (info)->hdynamic || h == elf_hash_table (info)->hgot) sym->st_shndx = SHN_ABS; diff --git a/bfd/elf32-hppa.c b/bfd/elf32-hppa.c index dc3053ce07..7ec06c775f 100644 --- a/bfd/elf32-hppa.c +++ b/bfd/elf32-hppa.c @@ -4442,9 +4442,7 @@ elf32_hppa_finish_dynamic_symbol (bfd *output_bfd, } /* Mark _DYNAMIC and _GLOBAL_OFFSET_TABLE_ as absolute. */ - if (eh_name (eh)[0] == '_' - && (strcmp (eh_name (eh), "_DYNAMIC") == 0 - || eh == htab->etab.hgot)) + if (eh == htab->etab.hdynamic || eh == htab->etab.hgot) { sym->st_shndx = SHN_ABS; } diff --git a/bfd/elf32-i386.c b/bfd/elf32-i386.c index eab963c2b4..25e3a33122 100644 --- a/bfd/elf32-i386.c +++ b/bfd/elf32-i386.c @@ -2635,7 +2635,7 @@ elf_i386_convert_mov_to_lea (bfd *abfd, asection *sec, optimizing _DYNAMIC since ld.so may use its link-time address. */ if (h->def_regular && h->type != STT_GNU_IFUNC - && strcmp (h->root.root.string, "_DYNAMIC") != 0 + && h != htab->elf.hdynamic && SYMBOL_REFERENCES_LOCAL (link_info, h) && bfd_get_8 (input_bfd, contents + irel->r_offset - 2) == 0x8b) diff --git a/bfd/elf32-lm32.c b/bfd/elf32-lm32.c index 8d530a4cf3..f40536c295 100644 --- a/bfd/elf32-lm32.c +++ b/bfd/elf32-lm32.c @@ -1745,8 +1745,7 @@ lm32_elf_finish_dynamic_symbol (bfd *output_bfd, } /* Mark some specially defined symbols as absolute. */ - if (strcmp (h->root.root.string, "_DYNAMIC") == 0 - || h == htab->root.hgot) + if (h == htab->root.hdynamic || h == htab->root.hgot) sym->st_shndx = SHN_ABS; return TRUE; diff --git a/bfd/elf32-m32r.c b/bfd/elf32-m32r.c index e3e3bb051b..70ddaab205 100644 --- a/bfd/elf32-m32r.c +++ b/bfd/elf32-m32r.c @@ -3295,8 +3295,7 @@ m32r_elf_finish_dynamic_symbol (bfd *output_bfd, } /* Mark some specially defined symbols as absolute. */ - if (strcmp (h->root.root.string, "_DYNAMIC") == 0 - || h == htab->root.hgot) + if (h == htab->root.hdynamic || h == htab->root.hgot) sym->st_shndx = SHN_ABS; return TRUE; diff --git a/bfd/elf32-microblaze.c b/bfd/elf32-microblaze.c index 27b569e839..c0004248a2 100644 --- a/bfd/elf32-microblaze.c +++ b/bfd/elf32-microblaze.c @@ -2882,9 +2882,9 @@ microblaze_elf_finish_dynamic_symbol (bfd *output_bfd, } /* Mark some specially defined symbols as absolute. */ - if (strcmp (h->root.root.string, "_DYNAMIC") == 0 - || strcmp (h->root.root.string, "_GLOBAL_OFFSET_TABLE_") == 0 - || strcmp (h->root.root.string, "_PROCEDURE_LINKAGE_TABLE_") == 0) + if (h == htab->elf.hdynamic + || h == htab->elf.hgot + || h == htab->elf.hplt) sym->st_shndx = SHN_ABS; return TRUE; diff --git a/bfd/elf32-s390.c b/bfd/elf32-s390.c index 8d654d5486..039de3afd2 100644 --- a/bfd/elf32-s390.c +++ b/bfd/elf32-s390.c @@ -3703,7 +3703,7 @@ elf_s390_finish_dynamic_symbol (bfd *output_bfd, } /* Mark some specially defined symbols as absolute. */ - if (strcmp (h->root.root.string, "_DYNAMIC") == 0 + if (h == htab->elf.hdynamic || h == htab->elf.hgot || h == htab->elf.hplt) sym->st_shndx = SHN_ABS; diff --git a/bfd/elf32-score.c b/bfd/elf32-score.c index 01a602b1a4..7b16ea2d15 100644 --- a/bfd/elf32-score.c +++ b/bfd/elf32-score.c @@ -3537,7 +3537,8 @@ s3_bfd_score_elf_finish_dynamic_symbol (bfd *output_bfd, /* Mark _DYNAMIC and _GLOBAL_OFFSET_TABLE_ as absolute. */ name = h->root.root.string; - if (strcmp (name, "_DYNAMIC") == 0 || strcmp (name, "_GLOBAL_OFFSET_TABLE_") == 0) + if (h == elf_hash_table (info)->hdynamic + || h == elf_hash_table (info)->hgot) sym->st_shndx = SHN_ABS; else if (strcmp (name, "_DYNAMIC_LINK") == 0) { diff --git a/bfd/elf32-score7.c b/bfd/elf32-score7.c index 3615a1e7b5..30bfe3928a 100644 --- a/bfd/elf32-score7.c +++ b/bfd/elf32-score7.c @@ -3345,7 +3345,8 @@ s7_bfd_score_elf_finish_dynamic_symbol (bfd *output_bfd, /* Mark _DYNAMIC and _GLOBAL_OFFSET_TABLE_ as absolute. */ name = h->root.root.string; - if (strcmp (name, "_DYNAMIC") == 0 || strcmp (name, "_GLOBAL_OFFSET_TABLE_") == 0) + if (h == elf_hash_table (info)->hdynamic + || h == elf_hash_table (info)->hgot) sym->st_shndx = SHN_ABS; else if (strcmp (name, "_DYNAMIC_LINK") == 0) { diff --git a/bfd/elf32-sh.c b/bfd/elf32-sh.c index cbd00aa640..df4affd682 100644 --- a/bfd/elf32-sh.c +++ b/bfd/elf32-sh.c @@ -7157,7 +7157,7 @@ sh_elf_finish_dynamic_symbol (bfd *output_bfd, struct bfd_link_info *info, /* Mark _DYNAMIC and _GLOBAL_OFFSET_TABLE_ as absolute. On VxWorks, _GLOBAL_OFFSET_TABLE_ is not absolute: it is relative to the ".got" section. */ - if (strcmp (h->root.root.string, "_DYNAMIC") == 0 + if (h == htab->root.hdynamic || (!htab->vxworks_p && h == htab->root.hgot)) sym->st_shndx = SHN_ABS; diff --git a/bfd/elf32-tic6x.c b/bfd/elf32-tic6x.c index dbe2c16ebe..ef0d1555a9 100644 --- a/bfd/elf32-tic6x.c +++ b/bfd/elf32-tic6x.c @@ -1903,7 +1903,7 @@ elf32_tic6x_finish_dynamic_symbol (bfd * output_bfd, } /* Mark _DYNAMIC and _GLOBAL_OFFSET_TABLE_ as absolute. */ - if (strcmp (h->root.root.string, "_DYNAMIC") == 0 + if (h == elf_hash_table (info)->hdynamic || h == elf_hash_table (info)->hgot) sym->st_shndx = SHN_ABS; diff --git a/bfd/elf32-tilepro.c b/bfd/elf32-tilepro.c index aa2dfd616e..cbb65c6b1a 100644 --- a/bfd/elf32-tilepro.c +++ b/bfd/elf32-tilepro.c @@ -3787,7 +3787,7 @@ tilepro_elf_finish_dynamic_symbol (bfd *output_bfd, } /* Mark some specially defined symbols as absolute. */ - if (strcmp (h->root.root.string, "_DYNAMIC") == 0 + if (h == htab->elf.hdynamic || (h == htab->elf.hgot || h == htab->elf.hplt)) sym->st_shndx = SHN_ABS; diff --git a/bfd/elf32-vax.c b/bfd/elf32-vax.c index 6258d96097..3fbc289570 100644 --- a/bfd/elf32-vax.c +++ b/bfd/elf32-vax.c @@ -1908,7 +1908,7 @@ elf_vax_finish_dynamic_symbol (bfd *output_bfd, struct bfd_link_info *info, } /* Mark _DYNAMIC and _GLOBAL_OFFSET_TABLE_ as absolute. */ - if (strcmp (h->root.root.string, "_DYNAMIC") == 0 + if (h == elf_hash_table (info)->hdynamic || h == elf_hash_table (info)->hgot) sym->st_shndx = SHN_ABS; diff --git a/bfd/elf32-xtensa.c b/bfd/elf32-xtensa.c index 2de9480db8..797979f11a 100644 --- a/bfd/elf32-xtensa.c +++ b/bfd/elf32-xtensa.c @@ -3135,7 +3135,7 @@ elf_xtensa_finish_dynamic_symbol (bfd *output_bfd ATTRIBUTE_UNUSED, } /* Mark _DYNAMIC and _GLOBAL_OFFSET_TABLE_ as absolute. */ - if (strcmp (h->root.root.string, "_DYNAMIC") == 0 + if (h == elf_hash_table (info)->hdynamic || h == elf_hash_table (info)->hgot) sym->st_shndx = SHN_ABS; diff --git a/bfd/elf64-aarch64.c b/bfd/elf64-aarch64.c index 629907403c..648ca7fd1f 100644 --- a/bfd/elf64-aarch64.c +++ b/bfd/elf64-aarch64.c @@ -6590,7 +6590,7 @@ elf64_aarch64_finish_dynamic_symbol (bfd *output_bfd, /* Mark _DYNAMIC and _GLOBAL_OFFSET_TABLE_ as absolute. SYM may be NULL for local symbols. */ if (sym != NULL - && (strcmp (h->root.root.string, "_DYNAMIC") == 0 + && (h == elf_hash_table (info)->hdynamic || h == elf_hash_table (info)->hgot)) sym->st_shndx = SHN_ABS; diff --git a/bfd/elf64-alpha.c b/bfd/elf64-alpha.c index deb03c183c..c18c37a7a5 100644 --- a/bfd/elf64-alpha.c +++ b/bfd/elf64-alpha.c @@ -4902,7 +4902,7 @@ elf64_alpha_finish_dynamic_symbol (bfd *output_bfd, struct bfd_link_info *info, } /* Mark some specially defined symbols as absolute. */ - if (strcmp (h->root.root.string, "_DYNAMIC") == 0 + if (h == elf_hash_table (info)->hdynamic || h == elf_hash_table (info)->hgot || h == elf_hash_table (info)->hplt) sym->st_shndx = SHN_ABS; diff --git a/bfd/elf64-ia64-vms.c b/bfd/elf64-ia64-vms.c index f723068a68..85a61928e2 100644 --- a/bfd/elf64-ia64-vms.c +++ b/bfd/elf64-ia64-vms.c @@ -4030,7 +4030,7 @@ elf64_ia64_finish_dynamic_symbol (bfd *output_bfd, } /* Mark some specially defined symbols as absolute. */ - if (strcmp (h->root.root.string, "_DYNAMIC") == 0 + if (h == ia64_info->root.hdynamic || h == ia64_info->root.hgot || h == ia64_info->root.hplt) sym->st_shndx = SHN_ABS; diff --git a/bfd/elf64-s390.c b/bfd/elf64-s390.c index 8512fc0700..c8b57f46ac 100644 --- a/bfd/elf64-s390.c +++ b/bfd/elf64-s390.c @@ -3506,7 +3506,7 @@ do_glob_dat: } /* Mark some specially defined symbols as absolute. */ - if (strcmp (h->root.root.string, "_DYNAMIC") == 0 + if (h == htab->elf.hdynamic || h == htab->elf.hgot || h == htab->elf.hplt) sym->st_shndx = SHN_ABS; diff --git a/bfd/elf64-sh64.c b/bfd/elf64-sh64.c index ce5436d0d9..3e6d081f77 100644 --- a/bfd/elf64-sh64.c +++ b/bfd/elf64-sh64.c @@ -3769,7 +3769,7 @@ sh64_elf64_finish_dynamic_symbol (bfd *output_bfd, } /* Mark _DYNAMIC and _GLOBAL_OFFSET_TABLE_ as absolute. */ - if (strcmp (h->root.root.string, "_DYNAMIC") == 0 + if (h == elf_hash_table (info)->hdynamic || h == elf_hash_table (info)->hgot) sym->st_shndx = SHN_ABS; diff --git a/bfd/elf64-x86-64.c b/bfd/elf64-x86-64.c index 9edc5aea3b..7daecb4ddf 100644 --- a/bfd/elf64-x86-64.c +++ b/bfd/elf64-x86-64.c @@ -2672,7 +2672,7 @@ elf_x86_64_convert_mov_to_lea (bfd *abfd, asection *sec, address. */ if (h->def_regular && h->type != STT_GNU_IFUNC - && strcmp (h->root.root.string, "_DYNAMIC") != 0 + && h != htab->elf.hdynamic && SYMBOL_REFERENCES_LOCAL (link_info, h) && bfd_get_8 (input_bfd, contents + irel->r_offset - 2) == 0x8b) diff --git a/bfd/elflink.c b/bfd/elflink.c index 3ef3f9bf5f..9446e7d2ea 100644 --- a/bfd/elflink.c +++ b/bfd/elflink.c @@ -187,6 +187,7 @@ _bfd_elf_link_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info) flagword flags; asection *s; const struct elf_backend_data *bed; + struct elf_link_hash_entry *h; if (! is_elf_hash_table (info->hash)) return FALSE; @@ -254,7 +255,9 @@ _bfd_elf_link_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info) section. We don't want to define it if there is no .dynamic section, since on some ELF platforms the start up code examines it to decide how to initialize the process. */ - if (!_bfd_elf_define_linkage_sym (abfd, info, s, "_DYNAMIC")) + h = _bfd_elf_define_linkage_sym (abfd, info, s, "_DYNAMIC"); + elf_hash_table (info)->hdynamic = h; + if (h == NULL) return FALSE; if (info->emit_hash) diff --git a/bfd/elfnn-ia64.c b/bfd/elfnn-ia64.c index e6abb79524..afa1e0448d 100644 --- a/bfd/elfnn-ia64.c +++ b/bfd/elfnn-ia64.c @@ -4586,7 +4586,7 @@ elfNN_ia64_finish_dynamic_symbol (bfd *output_bfd, } /* Mark some specially defined symbols as absolute. */ - if (strcmp (h->root.root.string, "_DYNAMIC") == 0 + if (h == ia64_info->root.hdynamic || h == ia64_info->root.hgot || h == ia64_info->root.hplt) sym->st_shndx = SHN_ABS; diff --git a/bfd/elfxx-mips.c b/bfd/elfxx-mips.c index 9c3f37290b..15a32c1434 100644 --- a/bfd/elfxx-mips.c +++ b/bfd/elfxx-mips.c @@ -10129,7 +10129,7 @@ _bfd_mips_elf_finish_dynamic_symbol (bfd *output_bfd, /* Mark _DYNAMIC and _GLOBAL_OFFSET_TABLE_ as absolute. */ name = h->root.root.string; - if (strcmp (name, "_DYNAMIC") == 0 + if (h == elf_hash_table (info)->hdynamic || h == elf_hash_table (info)->hgot) sym->st_shndx = SHN_ABS; else if (strcmp (name, "_DYNAMIC_LINK") == 0 diff --git a/bfd/elfxx-sparc.c b/bfd/elfxx-sparc.c index e14afaf970..9811d17b06 100644 --- a/bfd/elfxx-sparc.c +++ b/bfd/elfxx-sparc.c @@ -4511,7 +4511,7 @@ _bfd_sparc_elf_finish_dynamic_symbol (bfd *output_bfd, _GLOBAL_OFFSET_TABLE_ is not absolute: it is relative to the ".got" section. Likewise _PROCEDURE_LINKAGE_TABLE_ and ".plt". */ if (sym != NULL - && (strcmp (h->root.root.string, "_DYNAMIC") == 0 + && (h == htab->elf.hdynamic || (!htab->is_vxworks && (h == htab->elf.hgot || h == htab->elf.hplt)))) sym->st_shndx = SHN_ABS; diff --git a/bfd/elfxx-tilegx.c b/bfd/elfxx-tilegx.c index c0daf18bd4..3bcdd3a8d3 100644 --- a/bfd/elfxx-tilegx.c +++ b/bfd/elfxx-tilegx.c @@ -4185,7 +4185,7 @@ tilegx_elf_finish_dynamic_symbol (bfd *output_bfd, } /* Mark some specially defined symbols as absolute. */ - if (strcmp (h->root.root.string, "_DYNAMIC") == 0 + if (h == htab->elf.hdynamic || (h == htab->elf.hgot || h == htab->elf.hplt)) sym->st_shndx = SHN_ABS; -- 2.34.1