aboutsummaryrefslogtreecommitdiff
path: root/bfd
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2018-12-18 09:20:06 +1030
committerAlan Modra <amodra@gmail.com>2018-12-18 10:47:02 +1030
commit7af5d5c4dda26ac36ee2ff42af8f39a10382cc41 (patch)
treeea96ed2204aee3212b07516b827b30a0b779192f /bfd
parentc5ebe0ff706521b4a5fb66a5e764031825276ad5 (diff)
downloadgdb-7af5d5c4dda26ac36ee2ff42af8f39a10382cc41.zip
gdb-7af5d5c4dda26ac36ee2ff42af8f39a10382cc41.tar.gz
gdb-7af5d5c4dda26ac36ee2ff42af8f39a10382cc41.tar.bz2
PR23980, assertion fail
All of the backend relocate_section functions that interpret reloc numbers assuming the input file is of the expected type (ie. same as output or very similar) really ought to be checking input file type. Not many do, and those that do currently just assert. This patch replaces the assertion with a more graceful exit. PR 23980 * elf32-i386.c (elf_i386_relocate_section): Exit with wrong format error rather than asserting input file is as expected. * elf32-s390.c (elf_s390_relocate_section): Likewise. * elf32-sh.c (sh_elf_relocate_section): Likewise. * elf32-xtensa.c (elf_xtensa_relocate_section): Likewise. * elf64-ppc.c (ppc64_elf_relocate_section): Likewise. * elf64-s390.c (elf_s390_relocate_section): Likewise. * elf64-x86-64.c (elf_x86_64_relocate_section): Likewise. * elf32-ppc.c (ppc_elf_relocate_section): Exit with wrong format error if input file is not ppc32 ELF.
Diffstat (limited to 'bfd')
-rw-r--r--bfd/ChangeLog14
-rw-r--r--bfd/elf32-i386.c6
-rw-r--r--bfd/elf32-ppc.c6
-rw-r--r--bfd/elf32-s390.c6
-rw-r--r--bfd/elf32-sh.c6
-rw-r--r--bfd/elf32-xtensa.c6
-rw-r--r--bfd/elf64-ppc.c6
-rw-r--r--bfd/elf64-s390.c6
-rw-r--r--bfd/elf64-x86-64.c6
9 files changed, 55 insertions, 7 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index f8e936f..8fcdb59 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,6 +1,20 @@
2018-12-18 Alan Modra <amodra@gmail.com>
PR 23980
+ * elf32-i386.c (elf_i386_relocate_section): Exit with wrong format
+ error rather than asserting input file is as expected.
+ * elf32-s390.c (elf_s390_relocate_section): Likewise.
+ * elf32-sh.c (sh_elf_relocate_section): Likewise.
+ * elf32-xtensa.c (elf_xtensa_relocate_section): Likewise.
+ * elf64-ppc.c (ppc64_elf_relocate_section): Likewise.
+ * elf64-s390.c (elf_s390_relocate_section): Likewise.
+ * elf64-x86-64.c (elf_x86_64_relocate_section): Likewise.
+ * elf32-ppc.c (ppc_elf_relocate_section): Exit with wrong format
+ error if input file is not ppc32 ELF.
+
+2018-12-18 Alan Modra <amodra@gmail.com>
+
+ PR 23980
* elf64-ppc.c (ppc64_elf_hide_symbol): Check hash table type
before referencing ppc64-only fields of hash entries.
diff --git a/bfd/elf32-i386.c b/bfd/elf32-i386.c
index 1774717..7fe6afb 100644
--- a/bfd/elf32-i386.c
+++ b/bfd/elf32-i386.c
@@ -2028,7 +2028,11 @@ elf_i386_relocate_section (bfd *output_bfd,
if (htab == NULL)
return FALSE;
- BFD_ASSERT (is_x86_elf (input_bfd, htab));
+ if (!is_x86_elf (input_bfd, htab))
+ {
+ bfd_set_error (bfd_error_wrong_format);
+ return FALSE;
+ }
symtab_hdr = &elf_symtab_hdr (input_bfd);
sym_hashes = elf_sym_hashes (input_bfd);
diff --git a/bfd/elf32-ppc.c b/bfd/elf32-ppc.c
index 6b6043a..2f69965 100644
--- a/bfd/elf32-ppc.c
+++ b/bfd/elf32-ppc.c
@@ -7025,6 +7025,12 @@ ppc_elf_relocate_section (bfd *output_bfd,
(bfd_link_relocatable (info)) ? " (relocatable)" : "");
#endif
+ if (!is_ppc_elf (input_bfd))
+ {
+ bfd_set_error (bfd_error_wrong_format);
+ return FALSE;
+ }
+
got2 = bfd_get_section_by_name (input_bfd, ".got2");
/* Initialize howto table if not already done. */
diff --git a/bfd/elf32-s390.c b/bfd/elf32-s390.c
index 448c64d..75db448 100644
--- a/bfd/elf32-s390.c
+++ b/bfd/elf32-s390.c
@@ -2165,7 +2165,11 @@ elf_s390_relocate_section (bfd *output_bfd,
Elf_Internal_Rela *rel;
Elf_Internal_Rela *relend;
- BFD_ASSERT (is_s390_elf (input_bfd));
+ if (!is_s390_elf (input_bfd))
+ {
+ bfd_set_error (bfd_error_wrong_format);
+ return FALSE;
+ }
htab = elf_s390_hash_table (info);
symtab_hdr = &elf_symtab_hdr (input_bfd);
diff --git a/bfd/elf32-sh.c b/bfd/elf32-sh.c
index 1b39109..bcfcec7 100644
--- a/bfd/elf32-sh.c
+++ b/bfd/elf32-sh.c
@@ -3510,7 +3510,11 @@ sh_elf_relocate_section (bfd *output_bfd, struct bfd_link_info *info,
unsigned isec_segment, got_segment, plt_segment, check_segment[2];
bfd_boolean fdpic_p = FALSE;
- BFD_ASSERT (is_sh_elf (input_bfd));
+ if (!is_sh_elf (input_bfd))
+ {
+ bfd_set_error (bfd_error_wrong_format);
+ return FALSE;
+ }
htab = sh_elf_hash_table (info);
if (htab != NULL)
diff --git a/bfd/elf32-xtensa.c b/bfd/elf32-xtensa.c
index de960cd..05db733 100644
--- a/bfd/elf32-xtensa.c
+++ b/bfd/elf32-xtensa.c
@@ -2459,7 +2459,11 @@ elf_xtensa_relocate_section (bfd *output_bfd,
if (!xtensa_default_isa)
xtensa_default_isa = xtensa_isa_init (0, 0);
- BFD_ASSERT (is_xtensa_elf (input_bfd));
+ if (!is_xtensa_elf (input_bfd))
+ {
+ bfd_set_error (bfd_error_wrong_format);
+ return FALSE;
+ }
htab = elf_xtensa_hash_table (info);
if (htab == NULL)
diff --git a/bfd/elf64-ppc.c b/bfd/elf64-ppc.c
index 31a3edf..2f4cfaa 100644
--- a/bfd/elf64-ppc.c
+++ b/bfd/elf64-ppc.c
@@ -13360,7 +13360,11 @@ ppc64_elf_relocate_section (bfd *output_bfd,
if (input_section->owner == htab->params->stub_bfd)
return TRUE;
- BFD_ASSERT (is_ppc64_elf (input_bfd));
+ if (!is_ppc64_elf (input_bfd))
+ {
+ bfd_set_error (bfd_error_wrong_format);
+ return FALSE;
+ }
local_got_ents = elf_local_got_ents (input_bfd);
TOCstart = elf_gp (output_bfd);
diff --git a/bfd/elf64-s390.c b/bfd/elf64-s390.c
index c2a2955..b05df50 100644
--- a/bfd/elf64-s390.c
+++ b/bfd/elf64-s390.c
@@ -2119,7 +2119,11 @@ elf_s390_relocate_section (bfd *output_bfd,
Elf_Internal_Rela *rel;
Elf_Internal_Rela *relend;
- BFD_ASSERT (is_s390_elf (input_bfd));
+ if (!is_s390_elf (input_bfd))
+ {
+ bfd_set_error (bfd_error_wrong_format);
+ return FALSE;
+ }
htab = elf_s390_hash_table (info);
if (htab == NULL)
diff --git a/bfd/elf64-x86-64.c b/bfd/elf64-x86-64.c
index 4dcab43..8e886b0 100644
--- a/bfd/elf64-x86-64.c
+++ b/bfd/elf64-x86-64.c
@@ -2389,7 +2389,11 @@ elf_x86_64_relocate_section (bfd *output_bfd,
if (htab == NULL)
return FALSE;
- BFD_ASSERT (is_x86_elf (input_bfd, htab));
+ if (!is_x86_elf (input_bfd, htab))
+ {
+ bfd_set_error (bfd_error_wrong_format);
+ return FALSE;
+ }
plt_entry_size = htab->plt.plt_entry_size;
symtab_hdr = &elf_symtab_hdr (input_bfd);