diff options
author | Roland McGrath <mcgrathr@google.com> | 2013-11-19 10:54:00 -0800 |
---|---|---|
committer | Roland McGrath <mcgrathr@google.com> | 2013-11-19 10:54:00 -0800 |
commit | c2763e270c6627e55ac7a75ed3c0a717fbca9bd0 (patch) | |
tree | 832667bc181fa2fc7640c1a1e5084b86261ace12 /ld/emultempl | |
parent | 03e621be975dacc9cec9f5782698bdb098f6a49c (diff) | |
download | gdb-c2763e270c6627e55ac7a75ed3c0a717fbca9bd0.zip gdb-c2763e270c6627e55ac7a75ed3c0a717fbca9bd0.tar.gz gdb-c2763e270c6627e55ac7a75ed3c0a717fbca9bd0.tar.bz2 |
Fix references to __ehdr_start when it cannot be defined
ld/
* emultempl/elf32.em (gld${EMULATION_NAME}_before_allocation):
Don't use bfd_elf_record_link_assignment to mark __ehdr_start
hidden. Instead, just do it directly here, and only if it was
referenced but not defined.
ld/testsuite/
* ld-elf/ehdr_start-userdef.t: New file.
* ld-elf/ehdr_start-userdef.d: New file.
* ld-elf/ehdr_start-strongref.s: New file.
* ld-elf/ehdr_start-missing.t: New file.
* ld-elf/ehdr_start-missing.d: New file.
* ld-elf/ehdr_start-weak.d: New file.
* ld-mips-elf/ehdr_start-2.nd: Expect __ehdr_start to be global.
Diffstat (limited to 'ld/emultempl')
-rw-r--r-- | ld/emultempl/elf32.em | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/ld/emultempl/elf32.em b/ld/emultempl/elf32.em index 682f5e5..9a2fe89 100644 --- a/ld/emultempl/elf32.em +++ b/ld/emultempl/elf32.em @@ -1487,10 +1487,25 @@ gld${EMULATION_NAME}_before_allocation (void) /* Make __ehdr_start hidden if it has been referenced, to prevent the symbol from being dynamic. */ - if (!bfd_elf_record_link_assignment (link_info.output_bfd, &link_info, - "__ehdr_start", TRUE, TRUE)) - einfo ("%P%F: failed to record assignment to %s: %E\n", - "__ehdr_start"); + if (!link_info.relocatable) + { + 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; + } + } /* If we are going to make any variable assignments, we need to let the ELF backend know about them in case the variables are |