[binutils-gdb] PR binutils/22875: HPPA/ELF: Also fail with relocation placeholders

Maciej W.Rozycki macro@sourceware.org
Wed Apr 4 01:02:00 GMT 2018


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=8ee55178c22326c3624ad5872dc5382341ddcd2c

commit 8ee55178c22326c3624ad5872dc5382341ddcd2c
Author: Maciej W. Rozycki <macro@mips.com>
Date:   Wed Apr 4 02:00:49 2018 +0100

    PR binutils/22875: HPPA/ELF: Also fail with relocation placeholders
    
    Do not consider R_PARISC_UNIMPLEMENTED placeholder relocation entries of
    the `elf_hppa_howto_table' table valid in `info_to_howto' HPPA handlers.
    Instead issue an unsupported relocation type error and return a NULL
    howto as with relocations whose number is R_PARISC_UNIMPLEMENTED or
    beyond.
    
    	bfd/
    	* elf-hppa.h (elf_hppa_info_to_howto): Also return
    	unsuccessfully for unimplemented relocations.
    	(elf_hppa_info_to_howto_rel): Likewise.

Diff:
---
 bfd/ChangeLog  |  6 ++++++
 bfd/elf-hppa.h | 23 ++++++++++++++++++-----
 2 files changed, 24 insertions(+), 5 deletions(-)

diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index ea2a5ab..8921ab0 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,5 +1,11 @@
 2018-04-04  Maciej W. Rozycki  <macro@mips.com>
 
+	* elf-hppa.h (elf_hppa_info_to_howto): Also return
+	unsuccessfully for unimplemented relocations.
+	(elf_hppa_info_to_howto_rel): Likewise.
+
+2018-04-04  Maciej W. Rozycki  <macro@mips.com>
+
 	* elf32-i860.c (lookup_howto): Add `abfd' parameter.  Set the
 	`bfd_error_bad_value' error and call `_bfd_error_handler' on a
 	howto lookup failure.
diff --git a/bfd/elf-hppa.h b/bfd/elf-hppa.h
index 59c0c4f..f23f788 100644
--- a/bfd/elf-hppa.h
+++ b/bfd/elf-hppa.h
@@ -1026,8 +1026,15 @@ elf_hppa_info_to_howto (bfd *abfd,
 			Elf_Internal_Rela *elf_reloc)
 {
   unsigned int r_type = ELF32_R_TYPE (elf_reloc->r_info);
+  unsigned int type = r_type;
+  reloc_howto_type *howto;
 
-  if (r_type >= (unsigned int) R_PARISC_UNIMPLEMENTED)
+  if (r_type < (unsigned int) R_PARISC_UNIMPLEMENTED)
+    {
+      howto = &elf_hppa_howto_table[r_type];
+      type = howto->type;
+    }
+  if (type >= (unsigned int) R_PARISC_UNIMPLEMENTED)
     {
       /* xgettext:c-format */
       _bfd_error_handler (_("%pB: unsupported relocation type %#x"),
@@ -1035,7 +1042,7 @@ elf_hppa_info_to_howto (bfd *abfd,
       bfd_set_error (bfd_error_bad_value);
       return FALSE;
     }
-  bfd_reloc->howto = &elf_hppa_howto_table[r_type];
+  bfd_reloc->howto = howto;
   return TRUE;
 }
 
@@ -1047,8 +1054,15 @@ elf_hppa_info_to_howto_rel (bfd *abfd,
 			    Elf_Internal_Rela *elf_reloc)
 {
   unsigned int r_type = ELF_R_TYPE (elf_reloc->r_info);
+  unsigned int type = r_type;
+  reloc_howto_type *howto;
 
-  if (r_type >= (unsigned int) R_PARISC_UNIMPLEMENTED)
+  if (r_type < (unsigned int) R_PARISC_UNIMPLEMENTED)
+    {
+      howto = &elf_hppa_howto_table[r_type];
+      type = howto->type;
+    }
+  if (type >= (unsigned int) R_PARISC_UNIMPLEMENTED)
     {
       /* xgettext:c-format */
       _bfd_error_handler (_("%pB: unsupported relocation type %#x"),
@@ -1056,8 +1070,7 @@ elf_hppa_info_to_howto_rel (bfd *abfd,
       bfd_set_error (bfd_error_bad_value);
       return FALSE;
     }
-
-  bfd_reloc->howto = &elf_hppa_howto_table[r_type];
+  bfd_reloc->howto = howto;
   return TRUE;
 }



More information about the Binutils-cvs mailing list