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.
This commit is contained in:
Maciej W. Rozycki 2018-02-05 14:00:21 +00:00
parent 7550610057
commit 2d6dda7161
13 changed files with 67 additions and 1 deletions

View file

@ -0,0 +1,7 @@
#PROG: objcopy
#name: MIPS objcopy .reginfo section size (n32)
#as: -n32 -mips3
#objcopy: --rename-section .foo=.reginfo
#source: mips-reginfo.s
#error: \A[^\n]*: Incorrect `\.reginfo' section size; expected 24, got 4\n
#error: [^\n]*: Bad value\Z

View file

@ -0,0 +1,6 @@
#PROG: objcopy
#name: MIPS objcopy .reginfo section size
#as: -32
#objcopy: --rename-section .foo=.reginfo
#error: \A[^\n]*: Incorrect `\.reginfo' section size; expected 24, got 4\n
#error: [^\n]*: Bad value\Z

View file

@ -0,0 +1,2 @@
.section .foo, "a"
.word 0xdeadbeef

View file

@ -60,3 +60,8 @@ if $has_newabi {
run_dump_test "mips-note-2r-n32"
run_dump_test "mips-note-2r-n64"
}
run_dump_test "mips-reginfo"
if $has_newabi {
run_dump_test "mips-reginfo-n32"
}