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] PR25200, SIGSEGV in _bfd_elf_validate_reloc
Date: Mon, 18 Nov 2019 22:11:00 -0000	[thread overview]
Message-ID: <94698d0198f4018b2ac248b248868cb7a5c0cc43@gdb-build> (raw)

*** TEST RESULTS FOR COMMIT 94698d0198f4018b2ac248b248868cb7a5c0cc43 ***

commit 94698d0198f4018b2ac248b248868cb7a5c0cc43
Author:     Alan Modra <amodra@gmail.com>
AuthorDate: Tue Nov 19 07:29:26 2019 +1030
Commit:     Alan Modra <amodra@gmail.com>
CommitDate: Tue Nov 19 07:35:05 2019 +1030

    PR25200, SIGSEGV in _bfd_elf_validate_reloc
    
            PR 25200
            * reloc.c (bfd_default_reloc_type_lookup): Don't BFD_FAIL.
            * elf.c (_bfd_elf_validate_reloc): Don't segfault on NULL howto.

diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 1a9e64f3f3..d13d9695ff 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,9 @@
+2019-11-19  Alan Modra  <amodra@gmail.com>
+
+	PR 25200
+	* reloc.c (bfd_default_reloc_type_lookup): Don't BFD_FAIL.
+	* elf.c (_bfd_elf_validate_reloc): Don't segfault on NULL howto.
+
 2019-11-18  Alan Modra  <amodra@gmail.com>
 
 	* elf-bfd.h (struct elf_backend_data <elf_backend_init_file_header>):
diff --git a/bfd/elf.c b/bfd/elf.c
index 88e51c4f7d..a221bf0d04 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -9222,7 +9222,7 @@ _bfd_elf_validate_reloc (bfd *abfd, arelent *areloc)
 
 	  howto = bfd_reloc_type_lookup (abfd, code);
 
-	  if (areloc->howto->pcrel_offset != howto->pcrel_offset)
+	  if (howto && areloc->howto->pcrel_offset != howto->pcrel_offset)
 	    {
 	      if (howto->pcrel_offset)
 		areloc->addend += areloc->address;
diff --git a/bfd/reloc.c b/bfd/reloc.c
index ae71f6b005..cc842d7514 100644
--- a/bfd/reloc.c
+++ b/bfd/reloc.c
@@ -8123,28 +8123,11 @@ DESCRIPTION
 reloc_howto_type *
 bfd_default_reloc_type_lookup (bfd *abfd, bfd_reloc_code_real_type code)
 {
-  switch (code)
-    {
-    case BFD_RELOC_CTOR:
-      /* The type of reloc used in a ctor, which will be as wide as the
-	 address - so either a 64, 32, or 16 bitter.  */
-      switch (bfd_arch_bits_per_address (abfd))
-	{
-	case 64:
-	  BFD_FAIL ();
-	  break;
-	case 32:
-	  return &bfd_howto_32;
-	case 16:
-	  BFD_FAIL ();
-	  break;
-	default:
-	  BFD_FAIL ();
-	}
-      break;
-    default:
-      BFD_FAIL ();
-    }
+  /* Very limited support is provided for relocs in generic targets
+     such as elf32-little.  FIXME: Should we always return NULL?  */
+  if (code == BFD_RELOC_CTOR
+      && bfd_arch_bits_per_address (abfd) == 32)
+    return &bfd_howto_32;
   return NULL;
 }
 


             reply	other threads:[~2019-11-18 22:11 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-18 22:11 gdb-buildbot [this message]
2019-11-18 22:12 ` Failures on Ubuntu-Aarch64-native-gdbserver-m64, branch master gdb-buildbot
2019-11-27  2:31 ` Failures on Fedora-x86_64-m32, " gdb-buildbot
2019-11-27  2:31 ` Failures on Fedora-i686, " gdb-buildbot
2019-11-27  2:32 ` Failures on Fedora-x86_64-m64, " gdb-buildbot
2019-11-27  3:09 ` Failures on Fedora-x86_64-native-gdbserver-m64, " gdb-buildbot
2019-11-27  3:14 ` Failures on Fedora-x86_64-native-extended-gdbserver-m32, " gdb-buildbot
2019-11-27  3:14 ` Failures on Fedora-x86_64-native-extended-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=94698d0198f4018b2ac248b248868cb7a5c0cc43@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).