binutils-gdb/ld/testsuite
Maciej W. Rozycki e54cb31aa3 MIPS/LD: Fix a segfault from ELF `e_flags' access with non-ELF output BFD
Fix a commit 861fb55ab5 ("Defer allocation of R_MIPS_REL32 GOT
slots"), <https://sourceware.org/ml/binutils/2008-08/msg00096.html>,
regression and a more recent:

FAIL: ld-unique/pr21529

new LD test case failure, observed with all the relevant MIPS targets
whenever the linker is invoked with one or more ELF inputs and the
output format set to `binary'.

The culprit is a segmentation fault caused in `mips_before_allocation'
by a null pointer dereference, where an attempt is made to access the
ELF file header's `e_flags' member, for the purpose of determining
whether to produce a PLT and copy relocations, without first checking
that the output BFD is ELF.  The `e_flags' member is stored in BFD's
private data pointed to by `tdep', which in the case of the `binary' BFD
is null, causing the segmentation fault.  With other non-ELF BFDs such
as SREC `tdep' is not null and consequently no crash may happen and in
that case random data will be interpreted as it was `e_flags'.

Disable the access to `e_flags' then and all the associated checks and
consequently never produce a PLT and copy relocations if output is not a
MIPS ELF BFD, matching `_bfd_mips_elf_merge_private_bfd_data' that does
not process `e_flags' in that case either and therefore does not let us
decide here anyway if all the input objects included in the link are
suitable for use with a PLT and copy relocations.

	ld/
	* emultempl/mipself.em (mips_before_allocation): Avoid ELF
	processing if not MIPS ELF.
	* testsuite/ld-mips-elf/binary.d: New test.
	* testsuite/ld-mips-elf/binary.ld: New test linker script.
	* testsuite/ld-mips-elf/binary.s: New test source.
	* testsuite/ld-mips-elf/mips-elf.exp: Run the new test.
2017-07-07 17:58:03 +01:00
..
config x86: Add run-time tests for -mtls-dialect=gnu2 2017-04-28 12:42:18 -07:00
ld-aarch64 [AArch64] Use SYMBOL_REFERENCES_LOCAL in one symbol check 2017-06-16 14:20:38 +01:00
ld-alpha
ld-arc [ARC] Fixed TLS for IE model. 2017-06-08 19:00:36 +02:00
ld-arm [ARM] Add linker support for ARMv8-R 2017-06-24 10:48:08 +01:00
ld-auto-import
ld-avr Fix PR 13402 2017-06-27 14:47:02 +05:30
ld-bootstrap
ld-cdtest
ld-checks
ld-cris
ld-crx
ld-cygwin
ld-d10v
ld-discard
ld-elf LD: Fix .startof.SECNAME/.sizeof.SECNAME tests for MIPS/IRIX 2017-06-26 16:15:15 +01:00
ld-elfcomm
ld-elfvers
ld-elfvsb Pass $NOPIE_CFLAGS to ELF visibility tests 2017-06-22 12:53:39 -07:00
ld-elfweak
ld-fastcall
ld-frv
ld-gc Pass $NOPIE_CFLAGS and $NOPIE_LDFLAGS to more ELF tests 2017-06-22 09:53:33 -07:00
ld-h8300
ld-i386 i386: Add hidden weak undefined tests 2017-06-22 15:13:15 -07:00
ld-ia64
ld-ifunc x86: Dump local IFUNC functions in the map file 2017-06-08 03:53:43 -07:00
ld-libs
ld-linkonce
ld-m68hc11
ld-m68k
ld-mep
ld-metag
ld-mips-elf MIPS/LD: Fix a segfault from ELF `e_flags' access with non-ELF output BFD 2017-07-07 17:58:03 +01:00
ld-misc
ld-mmix
ld-mn10300
ld-nds32 Fix address violation when disassembling a corrupt binary. 2017-06-14 16:50:03 +01:00
ld-nios2
ld-pe
ld-pie
ld-plugin Handle symbol defined in IR and referenced in DSO 2017-04-20 07:48:35 -07:00
ld-powerpc Make ppc476 testcases more robust 2017-07-07 23:53:18 +09:30
ld-pru
ld-s390
ld-scripts Pass $NOPIE_CFLAGS to NOCROSSREFS tests 2017-06-21 14:57:53 -07:00
ld-selective
ld-sh
ld-shared Pass $NOPIE_CFLAGS and $NOPIE_LDFLAGS to more ELF tests 2017-06-22 09:53:33 -07:00
ld-size Pass $NOPIE_LDFLAGS size tests 2017-06-21 14:45:57 -07:00
ld-sparc ld: fix regressions with rett instructions in sparc tests. 2017-04-24 05:31:31 -07:00
ld-spu
ld-srec Pass $NOPIE_LDFLAGS size tests 2017-06-21 14:45:57 -07:00
ld-tic6x
ld-tilegx
ld-tilepro
ld-undefined Implement -z dynamic-undefined-weak 2017-04-19 20:39:52 +09:30
ld-unique Fix a number of pr21529 testcase failures 2017-06-07 17:56:46 +09:30
ld-v850
ld-vax-elf
ld-versados
ld-visium
ld-vxworks
ld-x86-64 x86: Support Intel Shadow Stack with SHSTK property 2017-06-22 05:50:31 -07:00
ld-xc16x
ld-xstormy16
ld-xtensa
ld-z8k
lib is_underscore_target for ld-elf tests 2017-06-18 11:56:19 +09:30
ChangeLog-2004
ChangeLog-2005
ChangeLog-2006
ChangeLog-2007
ChangeLog-2008
ChangeLog-2009
ChangeLog-2010
ChangeLog-2011
ChangeLog-2012
ChangeLog-2013
ChangeLog-2014
ChangeLog-2015
ChangeLog-9303