PR25200, SIGSEGV in _bfd_elf_validate_reloc
authorAlan Modra <amodra@gmail.com>
Mon, 18 Nov 2019 20:59:26 +0000 (07:29 +1030)
committerAlan Modra <amodra@gmail.com>
Mon, 18 Nov 2019 21:05:05 +0000 (07:35 +1030)
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.

bfd/ChangeLog
bfd/elf.c
bfd/reloc.c

index 1a9e64f3f359fb70533433641da0fd5ab7905116..d13d9695ff0243e1b507e02612818059b24a7307 100644 (file)
@@ -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>):
index 88e51c4f7d39c99a6cd9f84199f1bd53e0f2101f..a221bf0d04bd572e6bf1b752339ac42d8c8e3b63 100644 (file)
--- 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;
index ae71f6b0054c53e4594add9c799cc4034dfd9368..cc842d7514f3864eebab9827935d503faf6b404c 100644 (file)
@@ -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;
 }
 
This page took 0.031682 seconds and 4 git commands to generate.