diff options
author | Alan Modra <amodra@gmail.com> | 2017-10-12 09:01:54 +1030 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2017-10-12 13:13:06 +1030 |
commit | 559192d89d743834951fc386530c6bc7f89b358d (patch) | |
tree | 2241baec8776cc3e5dd1b4e0948ed8161abac1f5 | |
parent | f5233a1611d7d459a762b5fa93d7594a6965971f (diff) | |
download | gdb-559192d89d743834951fc386530c6bc7f89b358d.zip gdb-559192d89d743834951fc386530c6bc7f89b358d.tar.gz gdb-559192d89d743834951fc386530c6bc7f89b358d.tar.bz2 |
_bfd_elf_link_hash_hide_symbol calls in generic ELF code
This function shouldn't be called directly, except from backend code.
bfd/
* elflink.c (_bfd_elf_adjust_dynamic_symbol): Call
elf_backend_hide_symbol, not _bfd_elf_link_hash_hide_symbol.
(bfd_elf_define_start_stop): Likewise.
ld/
* emultempl/elf32.em (before_allocation): Call
elf_backend_hide_symbol, not _bfd_elf_link_hash_hide_symbol.
Formatting.
-rw-r--r-- | bfd/ChangeLog | 6 | ||||
-rw-r--r-- | bfd/elflink.c | 14 | ||||
-rw-r--r-- | ld/ChangeLog | 6 | ||||
-rw-r--r-- | ld/emultempl/elf32.em | 66 |
4 files changed, 54 insertions, 38 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 1af3560..fbcb11a 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,5 +1,11 @@ 2017-10-12 Alan Modra <amodra@gmail.com> + * elflink.c (_bfd_elf_adjust_dynamic_symbol): Call + elf_backend_hide_symbol, not _bfd_elf_link_hash_hide_symbol. + (bfd_elf_define_start_stop): Likewise. + +2017-10-12 Alan Modra <amodra@gmail.com> + * elf32-nds32.c (nds32_elf_size_dynamic_sections): Set .interp when executable rather than non-PIC. * elf32-score.c (s3_bfd_score_elf_size_dynamic_sections): Likewise. diff --git a/bfd/elflink.c b/bfd/elflink.c index 1a99058..b1b5ca7 100644 --- a/bfd/elflink.c +++ b/bfd/elflink.c @@ -2808,7 +2808,7 @@ static bfd_boolean _bfd_elf_adjust_dynamic_symbol (struct elf_link_hash_entry *h, void *data) { struct elf_info_failed *eif = (struct elf_info_failed *) data; - bfd *dynobj; + struct elf_link_hash_table *htab; const struct elf_backend_data *bed; if (! is_elf_hash_table (eif->info->hash)) @@ -2822,10 +2822,13 @@ _bfd_elf_adjust_dynamic_symbol (struct elf_link_hash_entry *h, void *data) if (! _bfd_elf_fix_symbol_flags (h, eif)) return FALSE; + htab = elf_hash_table (eif->info); + bed = get_elf_backend_data (htab->dynobj); + if (h->root.type == bfd_link_hash_undefweak) { if (eif->info->dynamic_undefined_weak == 0) - _bfd_elf_link_hash_hide_symbol (eif->info, h, TRUE); + (*bed->elf_backend_hide_symbol) (eif->info, h, TRUE); else if (eif->info->dynamic_undefined_weak > 0 && h->ref_regular && ELF_ST_VISIBILITY (h->other) == STV_DEFAULT @@ -2921,9 +2924,6 @@ _bfd_elf_adjust_dynamic_symbol (struct elf_link_hash_entry *h, void *data) (_("warning: type and size of dynamic symbol `%s' are not defined"), h->root.root.string); - dynobj = elf_hash_table (eif->info)->dynobj; - bed = get_elf_backend_data (dynobj); - if (! (*bed->elf_backend_adjust_dynamic_symbol) (eif->info, h)) { eif->failed = TRUE; @@ -14284,7 +14284,9 @@ bfd_elf_define_start_stop (struct bfd_link_info *info, if (symbol[0] == '.') { /* .startof. and .sizeof. symbols are local. */ - _bfd_elf_link_hash_hide_symbol (info, h, TRUE); + const struct elf_backend_data *bed; + bed = get_elf_backend_data (info->output_bfd); + (*bed->elf_backend_hide_symbol) (info, h, TRUE); } else if (ELF_ST_VISIBILITY (h->other) == STV_DEFAULT) h->other = (h->other & ~ELF_ST_VISIBILITY (-1)) | STV_PROTECTED; diff --git a/ld/ChangeLog b/ld/ChangeLog index 43fa479..0ae8134 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,3 +1,9 @@ +2017-10-12 Alan Modra <amodra@gmail.com> + + * emultempl/elf32.em (before_allocation): Call + elf_backend_hide_symbol, not _bfd_elf_link_hash_hide_symbol. + Formatting. + 2017-10-11 H.J. Lu <hongjiu.lu@intel.com> * PR ld/22269 diff --git a/ld/emultempl/elf32.em b/ld/emultempl/elf32.em index 0ee02bd..e6cf968 100644 --- a/ld/emultempl/elf32.em +++ b/ld/emultempl/elf32.em @@ -527,7 +527,7 @@ gld${EMULATION_NAME}_search_needed (const char *path, /* PR 20535: Support the same pseudo-environment variables that are supported by ld.so. Namely, $ORIGIN, $LIB and $PLATFORM. - Since there can be more than one occurrence of these tokens in + Since there can be more than one occurrence of these tokens in the path we loop until no more are found. Since we might not be able to substitute some of the tokens we maintain an offset into the filename for where we should begin our scan. */ @@ -664,8 +664,8 @@ gld${EMULATION_NAME}_search_needed (const char *path, /* Restore the path separator. */ * end = '/'; - /* PR 20784: Make sure that we resume the scan - *after* the token that we could not replace. */ + /* PR 20784: Make sure that we resume the scan *after* + the token that we could not replace. */ offset = (var + 1) - filename; } @@ -1701,34 +1701,36 @@ gld${EMULATION_NAME}_before_allocation (void) /* Make __ehdr_start hidden if it has been referenced, to prevent the symbol from being dynamic. */ if (!bfd_link_relocatable (&link_info)) - { - struct elf_link_hash_entry *h - = elf_link_hash_lookup (elf_hash_table (&link_info), "__ehdr_start", - FALSE, FALSE, TRUE); - - /* Only adjust the export class if the symbol was referenced - and not defined, otherwise leave it alone. */ - if (h != NULL - && (h->root.type == bfd_link_hash_new - || h->root.type == bfd_link_hash_undefined - || h->root.type == bfd_link_hash_undefweak - || h->root.type == bfd_link_hash_common)) - { - _bfd_elf_link_hash_hide_symbol (&link_info, h, TRUE); - if (ELF_ST_VISIBILITY (h->other) != STV_INTERNAL) - h->other = (h->other & ~ELF_ST_VISIBILITY (-1)) | STV_HIDDEN; - /* Don't leave the symbol undefined. Undefined hidden - symbols typically won't have dynamic relocations, but - we most likely will need dynamic relocations for - __ehdr_start if we are building a PIE or shared - library. */ - ehdr_start = h; - ehdr_start_save = h->root; - h->root.type = bfd_link_hash_defined; - h->root.u.def.section = bfd_abs_section_ptr; - h->root.u.def.value = 0; - } - } + { + struct elf_link_hash_table *htab = elf_hash_table (&link_info); + struct elf_link_hash_entry *h + = elf_link_hash_lookup (htab, "__ehdr_start", FALSE, FALSE, TRUE); + + /* Only adjust the export class if the symbol was referenced + and not defined, otherwise leave it alone. */ + if (h != NULL + && (h->root.type == bfd_link_hash_new + || h->root.type == bfd_link_hash_undefined + || h->root.type == bfd_link_hash_undefweak + || h->root.type == bfd_link_hash_common)) + { + const struct elf_backend_data *bed; + bed = get_elf_backend_data (link_info.output_bfd); + (*bed->elf_backend_hide_symbol) (&link_info, h, TRUE); + if (ELF_ST_VISIBILITY (h->other) != STV_INTERNAL) + h->other = (h->other & ~ELF_ST_VISIBILITY (-1)) | STV_HIDDEN; + /* Don't leave the symbol undefined. Undefined hidden + symbols typically won't have dynamic relocations, but + we most likely will need dynamic relocations for + __ehdr_start if we are building a PIE or shared + library. */ + ehdr_start = h; + ehdr_start_save = h->root; + h->root.type = bfd_link_hash_defined; + h->root.u.def.section = bfd_abs_section_ptr; + h->root.u.def.value = 0; + } + } /* If we are going to make any variable assignments, we need to let the ELF backend know about them in case the variables are @@ -1931,7 +1933,7 @@ gld${EMULATION_NAME}_open_dynamic_archive filename we recorded earlier. */ if (!entry->flags.full_name_provided) - filename = lbasename (entry->filename); + filename = lbasename (entry->filename); bfd_elf_set_dt_needed_name (entry->the_bfd, filename); } |