diff options
author | Alan Modra <amodra@gmail.com> | 2017-10-20 09:36:20 +1030 |
---|---|---|
committer | Alan Modra <amodra@gcc.gnu.org> | 2017-10-20 09:36:20 +1030 |
commit | ebd208bf7b4e8265738cf774549842f3895739ac (patch) | |
tree | 4b1c24d5264cc33e69ddff9c62f34b72142e02a1 /libiberty | |
parent | ef9eec0b599d533b58e29fe0c0bf6435e5368378 (diff) | |
download | gcc-ebd208bf7b4e8265738cf774549842f3895739ac.zip gcc-ebd208bf7b4e8265738cf774549842f3895739ac.tar.gz gcc-ebd208bf7b4e8265738cf774549842f3895739ac.tar.bz2 |
PR82575, lto debugobj references __gnu_lto_slim, ld test liblto-17 fails
If __gnu_lto_slim is global, undefined, default visibility in the
early debug object, then it finds its way into .dynsym when creating
shared libraries. __gnu_lto_slim in a symbol table (.dynsym or
.symtab) signals nm and other binutils that the object is an LTO
object needing a plugin, but that isn't the case for the ld liblti-17
tests. So, make __gnu_lto_slim hidden to prevent it becoming
dynamic. Further, make it weak because some linkers may warn on
finding an undefined global non-default visibility symbol.
PR lto/82575
* simple-object-elf.c (simple_object_elf_copy_lto_debug_sections):
Make discarded non-local symbols weak and hidden.
From-SVN: r253914
Diffstat (limited to 'libiberty')
-rw-r--r-- | libiberty/ChangeLog | 6 | ||||
-rw-r--r-- | libiberty/simple-object-elf.c | 21 |
2 files changed, 21 insertions, 6 deletions
diff --git a/libiberty/ChangeLog b/libiberty/ChangeLog index f1f0103..46dc0fa 100644 --- a/libiberty/ChangeLog +++ b/libiberty/ChangeLog @@ -1,3 +1,9 @@ +2017-10-20 Alan Modra <amodra@gmail.com> + + PR lto/82575 + * simple-object-elf.c (simple_object_elf_copy_lto_debug_sections): + Make discarded non-local symbols weak and hidden. + 2017-10-18 Jakub Jelinek <jakub@redhat.com> PR lto/82598 diff --git a/libiberty/simple-object-elf.c b/libiberty/simple-object-elf.c index c394924..1afd3eb 100644 --- a/libiberty/simple-object-elf.c +++ b/libiberty/simple-object-elf.c @@ -236,8 +236,10 @@ typedef struct #define STB_LOCAL 0 /* Local symbol */ #define STB_GLOBAL 1 /* Global symbol */ +#define STB_WEAK 2 /* Weak global */ #define STV_DEFAULT 0 /* Visibility is specified by binding type */ +#define STV_HIDDEN 2 /* Can only be seen inside currect component */ /* Functions to fetch and store different ELF types, depending on the endianness and size. */ @@ -1365,18 +1367,25 @@ simple_object_elf_copy_lto_debug_sections (simple_object_read *sobj, { /* Make discarded symbols undefined and unnamed in case it is local. */ - if (ELF_ST_BIND (*st_info) == STB_LOCAL) - ELF_SET_FIELD (type_functions, ei_class, Sym, - ent, st_name, Elf_Word, 0); + int bind = ELF_ST_BIND (*st_info); + if (bind == STB_LOCAL) + { + ELF_SET_FIELD (type_functions, ei_class, Sym, + ent, st_name, Elf_Word, 0); + *st_other = STV_DEFAULT; + } + else + { + bind = STB_WEAK; + *st_other = STV_HIDDEN; + } + *st_info = ELF_ST_INFO (bind, STT_NOTYPE); ELF_SET_FIELD (type_functions, ei_class, Sym, ent, st_value, Elf_Addr, 0); ELF_SET_FIELD (type_functions, ei_class, Sym, ent, st_size, Elf_Word, 0); ELF_SET_FIELD (type_functions, ei_class, Sym, ent, st_shndx, Elf_Half, SHN_UNDEF); - *st_info = ELF_ST_INFO (ELF_ST_BIND (*st_info), - STT_NOTYPE); - *st_other = STV_DEFAULT; } } XDELETEVEC (strings); |