public inbox for gdb-testers@sourceware.org
help / color / mirror / Atom feed
From: gdb-buildbot@sergiodj.net
To: gdb-testers@sourceware.org
Subject: [binutils-gdb] Bogus "final link failed" messages
Date: Sun, 13 Oct 2019 04:56:00 -0000	[thread overview]
Message-ID: <847d518374be1c73b812e312a26341115d3f6f5a@gdb-build> (raw)

*** TEST RESULTS FOR COMMIT 847d518374be1c73b812e312a26341115d3f6f5a ***

commit 847d518374be1c73b812e312a26341115d3f6f5a
Author:     Alan Modra <amodra@gmail.com>
AuthorDate: Mon Oct 7 13:37:23 2019 +1030
Commit:     Alan Modra <amodra@gmail.com>
CommitDate: Mon Oct 7 13:37:23 2019 +1030

    Bogus "final link failed" messages
    
    This patch is a result of noticing messages like the following:
    tmpdir/tls32.o: in function `_start':
    (.text+0x1c): unresolvable R_PPC_REL24 relocation against symbol `__tls_get_addr_opt'
    ./ld-new: final link failed: symbol needs debug section which does not exist
    
    The "needs debug section" comes from attempting to use debug info to
    find source line information to print the first error message.  That
    error isn't of interest to the user, and any previous bfd_error value
    which might be of interest is overwritten.  So save and restore
    bfd_error around the fancy error reporting code.
    
    That still doesn't leave us with a clean bfd_error.  Now we get
    ./ld-new: final link failed: nonrepresentable section on output
    An unresolvable relocation surely doesn't mean there is some bfd
    section that ld doesn't know how to output!  Digging into that showed
    a _bfd_elf_section_from_bfd_section failure attempting to find an elf
    section correcsponding to ".interp".  So don't go looking for elf
    sections on linker created bfd sections.
    
    And then fix the linker testsuite which expected the bogus message..
    
    bfd/
            * elflink.c (elf_fixup_link_order): Don't attempt to find
            an elf_section for linker created bfd sections.
    ld/
            * ldmisc.c (vfinfo): Save and restore bfd_error around bfd
            function calls that might set it.
            * testsuite/ld-elf/indirect.exp: Don't expect "nonrepresentable
            section" message.

diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index b691d58571..607f37cfb2 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,8 @@
+2019-10-07  Alan Modra  <amodra@gmail.com>
+
+	* elflink.c (elf_fixup_link_order): Don't attempt to find
+	an elf_section for linker created bfd sections.
+
 2019-10-07  Alan Modra  <amodra@gmail.com>
 
 	* elf32-ppc.c (ppc_elf_tls_optimize): Don't process R_PPC_TLSLD
diff --git a/bfd/elflink.c b/bfd/elflink.c
index 371c0969e6..395d96d6cf 100644
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -11535,7 +11535,8 @@ elf_fixup_link_order (bfd *abfd, asection *o)
 	{
 	  s = p->u.indirect.section;
 	  sub = s->owner;
-	  if (bfd_get_flavour (sub) == bfd_target_elf_flavour
+	  if ((s->flags & SEC_LINKER_CREATED) == 0
+	      && bfd_get_flavour (sub) == bfd_target_elf_flavour
 	      && elf_elfheader (sub)->e_ident[EI_CLASS] == bed->s->elfclass
 	      && (elfsec = _bfd_elf_section_from_bfd_section (sub, s))
 	      && elfsec < elf_numsections (sub)
diff --git a/ld/ChangeLog b/ld/ChangeLog
index a3fd84f1bd..ddec8c79ce 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,3 +1,10 @@
+2019-10-07  Alan Modra  <amodra@gmail.com>
+
+	* ldmisc.c (vfinfo): Save and restore bfd_error around bfd
+	function calls that might set it.
+	* testsuite/ld-elf/indirect.exp: Don't expect "nonrepresentable
+	section" message.
+
 2019-10-07  Alan Modra  <amodra@gmail.com>
 
 	* testsuite/ld-powerpc/tlsexe.r: Adjust for added TLSMARK symbol.
diff --git a/ld/ldmisc.c b/ld/ldmisc.c
index 848e227b05..2e53d64598 100644
--- a/ld/ldmisc.c
+++ b/ld/ldmisc.c
@@ -322,6 +322,7 @@ vfinfo (FILE *fp, const char *fmt, va_list ap, bfd_boolean is_warning)
 		unsigned int linenumber;
 		bfd_boolean discard_last;
 		bfd_boolean done;
+		bfd_error_type last_bfd_error = bfd_get_error ();
 
 		abfd = args[arg_no].reladdr.abfd;
 		section = args[arg_no].reladdr.sec;
@@ -406,6 +407,7 @@ vfinfo (FILE *fp, const char *fmt, va_list ap, bfd_boolean is_warning)
 		  }
 		if (!done)
 		  lfinfo (fp, "(%pA+0x%v)", section, offset);
+		bfd_set_error (last_bfd_error);
 
 		if (discard_last)
 		  {
diff --git a/ld/testsuite/ld-elf/indirect.exp b/ld/testsuite/ld-elf/indirect.exp
index 1acb556dba..6f1fed34e7 100644
--- a/ld/testsuite/ld-elf/indirect.exp
+++ b/ld/testsuite/ld-elf/indirect.exp
@@ -123,11 +123,10 @@ set testname "Indirect symbol 1b"
 set cmd "$ld -e start -o tmpdir/indirect1 tmpdir/indirect1a.o tmpdir/libindirect1c.so tmpdir/indirect1b.o"
 check_link_message "$cmd" [list $string1 $string] "$testname"
 
-set string ": final link failed: nonrepresentable section on output"
 set string2 ": no symbol version section for versioned symbol \`foo@FOO\'"
 set testname "Indirect symbol 2"
 set cmd "$ld -shared  -o tmpdir/indirect2.so tmpdir/indirect2.o"
-check_link_message "$cmd" [list $string2 $string] "$testname"
+check_link_message "$cmd" [list $string2] "$testname"
 
 global NOPIE_CFLAGS NOPIE_LDFLAGS
 


             reply	other threads:[~2019-10-13  4:56 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-13  4:56 gdb-buildbot [this message]
2019-10-13  4:56 ` Failures on Ubuntu-Aarch64-m64, branch master gdb-buildbot
2019-10-13  6:30 ` Failures on Ubuntu-Aarch64-native-extended-gdbserver-m64, " gdb-buildbot
2019-10-13  7:14 ` Failures on Ubuntu-Aarch64-native-gdbserver-m64, " gdb-buildbot
2019-10-18  5:42 ` Failures on Fedora-i686, " gdb-buildbot
2019-10-18  7:40 ` Failures on Fedora-x86_64-m32, " gdb-buildbot
2019-10-18  7:45 ` Failures on Fedora-x86_64-m64, " gdb-buildbot
2019-10-18  8:54 ` Failures on Fedora-x86_64-native-extended-gdbserver-m32, " gdb-buildbot
2019-10-18  9:00 ` Failures on Fedora-x86_64-native-extended-gdbserver-m64, " gdb-buildbot
2019-10-18  9:56 ` Failures on Fedora-x86_64-native-gdbserver-m32, " gdb-buildbot
2019-10-18 10:01 ` Failures on Fedora-x86_64-native-gdbserver-m64, " gdb-buildbot

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=847d518374be1c73b812e312a26341115d3f6f5a@gdb-build \
    --to=gdb-buildbot@sergiodj.net \
    --cc=gdb-testers@sourceware.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).