public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc(refs/vendors/redhat/heads/gcc-8-branch)] lto/96385 - avoid unused global UNDEFs in debug objects
Date: Fri, 14 May 2021 14:54:45 +0000 (GMT)	[thread overview]
Message-ID: <20210514145445.D60843949F32@sourceware.org> (raw)

https://gcc.gnu.org/g:098a5d0349a0a8285970f4e0141a8de4e63ded52

commit 098a5d0349a0a8285970f4e0141a8de4e63ded52
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 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)
 		{


                 reply	other threads:[~2021-05-14 14:54 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210514145445.D60843949F32@sourceware.org \
    --to=jakub@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).