aboutsummaryrefslogtreecommitdiff
path: root/bfd/elfxx-mips.c
diff options
context:
space:
mode:
authorMaciej W. Rozycki <macro@mips.com>2018-02-05 14:00:21 +0000
committerMaciej W. Rozycki <macro@mips.com>2018-02-05 14:00:21 +0000
commit2d6dda71611ba6cc16fe2bd21ac816d5f7d1e74d (patch)
tree64d139184ccc165a25a68a53f01467a1a127ebd9 /bfd/elfxx-mips.c
parent7550610057c51d47e3815ef93893d4f4faa7e03d (diff)
downloadgdb-2d6dda71611ba6cc16fe2bd21ac816d5f7d1e74d.zip
gdb-2d6dda71611ba6cc16fe2bd21ac816d5f7d1e74d.tar.gz
gdb-2d6dda71611ba6cc16fe2bd21ac816d5f7d1e74d.tar.bz2
MIPS/BFD: Correctly report unsupported `.reginfo' section size
Report an error when an unsupported `.reginfo' section size is found in `_bfd_mips_elf_section_processing', removing an assertion that triggers at elfxx-mips.c:7105 in GAS when assembling input like: .section .reginfo .word 0xdeadbeef and in `objcopy --rename-section' when renaming an incorrectly sized section to `.reginfo'. bfd/ * elfxx-mips.c (_bfd_mips_elf_section_processing): For SHT_MIPS_REGINFO sections don't assert the correct size and report an error instead. binutils/ * testsuite/binutils-all/mips/mips-reginfo.d: New test. * testsuite/binutils-all/mips/mips-reginfo-n32.d: New test. * testsuite/binutils-all/mips/mips-reginfo.s: New test source. * testsuite/binutils-all/mips/mips.exp: Run the new tests. gas/ * testsuite/gas/mips/reginfo-2.d: New test. * testsuite/gas/mips/reginfo-2-n32.d: New test. * testsuite/gas/mips/reginfo-2.l: New test stderr output. * testsuite/gas/mips/reginfo-2.s: New test source. * testsuite/gas/mips/mips.exp: Run the new tests.
Diffstat (limited to 'bfd/elfxx-mips.c')
-rw-r--r--bfd/elfxx-mips.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/bfd/elfxx-mips.c b/bfd/elfxx-mips.c
index 2854013..ab65894 100644
--- a/bfd/elfxx-mips.c
+++ b/bfd/elfxx-mips.c
@@ -7102,9 +7102,18 @@ _bfd_mips_elf_section_processing (bfd *abfd, Elf_Internal_Shdr *hdr)
{
bfd_byte buf[4];
- BFD_ASSERT (hdr->sh_size == sizeof (Elf32_External_RegInfo));
BFD_ASSERT (hdr->contents == NULL);
+ if (hdr->sh_size != sizeof (Elf32_External_RegInfo))
+ {
+ _bfd_error_handler
+ (_("%B: Incorrect `.reginfo' section size; expected %Lu, got %Lu"),
+ abfd, (bfd_size_type) sizeof (Elf32_External_RegInfo),
+ hdr->sh_size);
+ bfd_set_error (bfd_error_bad_value);
+ return FALSE;
+ }
+
if (bfd_seek (abfd,
hdr->sh_offset + sizeof (Elf32_External_RegInfo) - 4,
SEEK_SET) != 0)