aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2020-08-03 15:05:37 +0200
committerRichard Biener <rguenther@suse.de>2021-04-26 11:29:47 +0200
commite6a720bf5b1328ff018880063ae3d1e777e5b61d (patch)
treebc09fb0eecafb533bfa886be1d7eb44c7eefdffc
parentd0669d6ac82726cd751b73c7fb04194b446dfd49 (diff)
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. (cherry picked from commit b32c5d0b72fda2588b4e170e75a9c64e4bf266c7)
-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 0505c1dc001..3732e8fbfcc 100644
--- a/libiberty/simple-object-elf.c
+++ b/libiberty/simple-object-elf.c
@@ -1446,6 +1446,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)
{