Commit ebd208bf by Alan Modra Committed by Alan Modra

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
parent ef9eec0b
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> 2017-10-18 Jakub Jelinek <jakub@redhat.com>
PR lto/82598 PR lto/82598
......
...@@ -236,8 +236,10 @@ typedef struct ...@@ -236,8 +236,10 @@ typedef struct
#define STB_LOCAL 0 /* Local symbol */ #define STB_LOCAL 0 /* Local symbol */
#define STB_GLOBAL 1 /* Global 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_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 /* Functions to fetch and store different ELF types, depending on the
endianness and size. */ endianness and size. */
...@@ -1365,18 +1367,25 @@ simple_object_elf_copy_lto_debug_sections (simple_object_read *sobj, ...@@ -1365,18 +1367,25 @@ simple_object_elf_copy_lto_debug_sections (simple_object_read *sobj,
{ {
/* Make discarded symbols undefined and unnamed /* Make discarded symbols undefined and unnamed
in case it is local. */ in case it is local. */
if (ELF_ST_BIND (*st_info) == STB_LOCAL) int bind = ELF_ST_BIND (*st_info);
ELF_SET_FIELD (type_functions, ei_class, Sym, if (bind == STB_LOCAL)
ent, st_name, Elf_Word, 0); {
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, ELF_SET_FIELD (type_functions, ei_class, Sym,
ent, st_value, Elf_Addr, 0); ent, st_value, Elf_Addr, 0);
ELF_SET_FIELD (type_functions, ei_class, Sym, ELF_SET_FIELD (type_functions, ei_class, Sym,
ent, st_size, Elf_Word, 0); ent, st_size, Elf_Word, 0);
ELF_SET_FIELD (type_functions, ei_class, Sym, ELF_SET_FIELD (type_functions, ei_class, Sym,
ent, st_shndx, Elf_Half, SHN_UNDEF); 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); XDELETEVEC (strings);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment