From: Alan Modra Date: Thu, 19 Oct 2017 23:06:20 +0000 (+1030) Subject: PR82575, lto debugobj references __gnu_lto_slim, ld test liblto-17 fails X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=ebd208bf7b4e8265738cf774549842f3895739ac;p=gcc.git 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 --- diff --git a/libiberty/ChangeLog b/libiberty/ChangeLog index f1f010327b0..46dc0fa7e04 100644 --- a/libiberty/ChangeLog +++ b/libiberty/ChangeLog @@ -1,3 +1,9 @@ +2017-10-20 Alan Modra + + 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 PR lto/82598 diff --git a/libiberty/simple-object-elf.c b/libiberty/simple-object-elf.c index c39492439d0..1afd3ebc951 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);