aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2020-08-03 15:05:37 +0200
committerRichard Biener <rguenther@suse.de>2020-08-03 15:09:20 +0200
commitb32c5d0b72fda2588b4e170e75a9c64e4bf266c7 (patch)
treef44cf2f956326620ccc778762cd09c5310e3ff6a
parent5e97638b0adfb822d3b156c07da27d41091ce137 (diff)
downloadgcc-b32c5d0b72fda2588b4e170e75a9c64e4bf266c7.zip
gcc-b32c5d0b72fda2588b4e170e75a9c64e4bf266c7.tar.gz
gcc-b32c5d0b72fda2588b4e170e75a9c64e4bf266c7.tar.bz2
lto/96385 - avoid unused global UNDEFs in debug objects
Unused global UNDEFs can have side-effects in some circumstances so the following patch avoids them by treating them the same as other to be discarded DEFs - make them local. 2020-08-03 Richard Biener <rguenther@suse.de> PR lto/96385 libiberty/ * simple-object-elf.c (simple_object_elf_copy_lto_debug_sections): Localize global UNDEFs and reuse the prevailing name.
-rw-r--r--libiberty/simple-object-elf.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/libiberty/simple-object-elf.c b/libiberty/simple-object-elf.c
index c62d5bb..7c9d492 100644
--- a/libiberty/simple-object-elf.c
+++ b/libiberty/simple-object-elf.c
@@ -1467,6 +1467,11 @@ simple_object_elf_copy_lto_debug_sections (simple_object_read *sobj,
&& st_shndx < shnum
&& pfnret[st_shndx - 1] == -1)
discard = 1;
+ /* We also need to remove global UNDEFs which can
+ cause link fails later. */
+ else if (st_shndx == SHN_UNDEF
+ && ELF_ST_BIND (*st_info) == STB_GLOBAL)
+ discard = 1;
if (discard)
{