]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
PR82575, lto debugobj references __gnu_lto_slim, ld test liblto-17 fails
authoramodra <amodra@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 19 Oct 2017 23:06:20 +0000 (23:06 +0000)
committeramodra <amodra@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 19 Oct 2017 23:06:20 +0000 (23:06 +0000)
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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@253914 138bc75d-0d04-0410-961f-82ee72b054a4

libiberty/ChangeLog
libiberty/simple-object-elf.c

index f1f010327b065faddad862af937b899e18106d28..46dc0fa7e04c26ada8d404f1da34b074a71a62eb 100644 (file)
@@ -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
index c39492439d099372f1d76e5b14d0015484bc3a5a..1afd3ebc951dd4ecfe1f3a6d6a620297c4ec747e 100644 (file)
@@ -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);