[PATCH] bfd: Fix 64-bit relocation handling for a.out
authorGunther Nikl <gnikl@justmail.de>
Tue, 12 May 2020 11:18:09 +0000 (12:18 +0100)
committerNick Clifton <nickc@redhat.com>
Tue, 12 May 2020 11:18:09 +0000 (12:18 +0100)
* aoutx.h (NAME (aout, swap_std_reloc_out)): Reject an unsupported
relocation size.

bfd/ChangeLog
bfd/aoutx.h

index 78527378867102b9ef38e8effa0e9728cd01e8c1..34932e777f9954d49738a0d323ef4df6a800f190 100644 (file)
@@ -1,3 +1,8 @@
+2020-05-12  Gunther Nikl  <gnikl@justmail.de>
+
+       * aoutx.h (NAME (aout, swap_std_reloc_out)): Reject an unsupported
+       relocation size.
+
 2020-05-11  Alan Modra  <amodra@gmail.com>
 
        * elf64-ppc.c (xlate_pcrel_opt): Handle lxvp and stxvp.
index d5457461ab0c37381c57b0a8cee46fdb5ed0bda9..9ffb3fe8610ec2bb63fd8c0454bbb7e4c7afe126 100644 (file)
@@ -1946,10 +1946,22 @@ NAME (aout, swap_std_reloc_out) (bfd *abfd,
 
   BFD_ASSERT (g->howto != NULL);
 
-  if (bfd_get_reloc_size (g->howto) != 8)
-    r_length = g->howto->size; /* Size as a power of two.  */
-  else
-    r_length = 3;
+  switch (bfd_get_reloc_size (g->howto))
+    {
+    default:
+      _bfd_error_handler (_("%pB: unsupported AOUT relocation size: %d"),
+                         abfd, bfd_get_reloc_size (g->howto));
+      bfd_set_error (bfd_error_bad_value);
+      return;
+    case 1:
+    case 2:
+    case 4:
+      r_length = g->howto->size;       /* Size as a power of two.  */
+      break;
+    case 8:
+      r_length = 3;
+      break;
+    }
 
   r_pcrel  = (int) g->howto->pc_relative; /* Relative to PC?  */
   /* XXX This relies on relocs coming from a.out files.  */
This page took 0.027464 seconds and 4 git commands to generate.