diff options
author | H.J. Lu <hjl.tools@gmail.com> | 2018-06-08 12:41:31 -0700 |
---|---|---|
committer | H.J. Lu <hjl.tools@gmail.com> | 2018-06-08 12:41:54 -0700 |
commit | ecf99cc09236316db27fd8ffaedca864f81ea081 (patch) | |
tree | 17aa0ad69fbb3bf1877c24c2bfcc77421a94db4c /bfd/elfxx-x86.c | |
parent | aeab512851bf6ed623d1c6c4305b6ce05e51a10c (diff) | |
download | gdb-ecf99cc09236316db27fd8ffaedca864f81ea081.zip gdb-ecf99cc09236316db27fd8ffaedca864f81ea081.tar.gz gdb-ecf99cc09236316db27fd8ffaedca864f81ea081.tar.bz2 |
ld/x86: Remove hidden _edata, __bss_start, and _end
There is no need to put hidden _edata, __bss_start, and _end in dynamic
symbol table in shared libraries.
bfd/
PR ld/23161
* elfxx-x86.c (elf_x86_hide_linker_defined): New function.
(_bfd_x86_elf_link_check_relocs): Use it to hide hidden
__bss_start, _end and _edata in shared libraries.
ld/
PR ld/23161
* testsuite/ld-elf/pr23161d.rd: Remove local _edata, __bss_start,
and _end from dynamic symbol table.
Diffstat (limited to 'bfd/elfxx-x86.c')
-rw-r--r-- | bfd/elfxx-x86.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/bfd/elfxx-x86.c b/bfd/elfxx-x86.c index 3a7573f..827bb6c 100644 --- a/bfd/elfxx-x86.c +++ b/bfd/elfxx-x86.c @@ -876,6 +876,27 @@ elf_x86_linker_defined (struct bfd_link_info *info, const char *name) } } +/* Hide a linker-defined symbol, NAME, with hidden visibility. */ + +static void +elf_x86_hide_linker_defined (struct bfd_link_info *info, + const char *name) +{ + struct elf_link_hash_entry *h; + + h = elf_link_hash_lookup (elf_hash_table (info), name, + FALSE, FALSE, FALSE); + if (h == NULL) + return; + + while (h->root.type == bfd_link_hash_indirect) + h = (struct elf_link_hash_entry *) h->root.u.i.link; + + if (ELF_ST_VISIBILITY (h->other) == STV_INTERNAL + || ELF_ST_VISIBILITY (h->other) == STV_HIDDEN) + _bfd_elf_link_hash_hide_symbol (info, h, TRUE); +} + bfd_boolean _bfd_x86_elf_link_check_relocs (bfd *abfd, struct bfd_link_info *info) { @@ -916,6 +937,14 @@ _bfd_x86_elf_link_check_relocs (bfd *abfd, struct bfd_link_info *info) elf_x86_linker_defined (info, "_end"); elf_x86_linker_defined (info, "_edata"); } + else + { + /* Hide hidden __bss_start, _end and _edata in shared + libraries. */ + elf_x86_hide_linker_defined (info, "__bss_start"); + elf_x86_hide_linker_defined (info, "_end"); + elf_x86_hide_linker_defined (info, "_edata"); + } } } |