public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r9-9340] lto/96385 - avoid unused global UNDEFs in debug objects
@ 2021-04-12 11:23 Richard Biener
  0 siblings, 0 replies; only message in thread
From: Richard Biener @ 2021-04-12 11:23 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:969be2412231d3bdd73300ac32684d416345a029

commit r9-9340-g969be2412231d3bdd73300ac32684d416345a029
Author: Richard Biener <rguenther@suse.de>
Date:   Mon Aug 3 15:05:37 2020 +0200

    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)

Diff:
---
 libiberty/simple-object-elf.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/libiberty/simple-object-elf.c b/libiberty/simple-object-elf.c
index 3d49f339631..a5cf6043dc3 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)
 		{


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-04-12 11:23 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-12 11:23 [gcc r9-9340] lto/96385 - avoid unused global UNDEFs in debug objects Richard Biener

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).