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 Align eh_frame FDEs according to their encoding 2017-03-05 14:49:54 +10:30
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 Run more ld tests when not native 2017-01-02 23:48:08 +10:30
ld-cdtest Run more ld tests when not native 2017-01-02 23:48:08 +10:30
ld-checks ld-checks: tweak overflow checks. 2017-03-15 10:23:19 +01:00
ld-cris Fix for PR ld/16044: elf32-cris.c h->plt.refcount inconsistency 2017-03-28 23:43:09 +02:00
ld-crx
ld-cygwin Run more ld tests when not native 2017-01-02 23:48:08 +10:30
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 Run more ld tests when not native 2017-01-02 23:48:08 +10:30
ld-elfvers Add -rpath-link to various tests 2017-01-03 12:36:02 +10:30
ld-elfvsb Pass $NOPIE_CFLAGS to ELF visibility tests 2017-06-22 12:53:39 -07:00
ld-elfweak Add -rpath-link to various tests 2017-01-03 12:36:02 +10:30
ld-fastcall Run more ld tests when not native 2017-01-02 23:48:08 +10:30
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 Run more ld tests when not native 2017-01-02 23:48:08 +10:30
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 Run more ld tests when not native 2017-01-02 23:48:08 +10:30
ld-nds32 Fix address violation when disassembling a corrupt binary. 2017-06-14 16:50:03 +01:00
ld-nios2 Run more ld tests when not native 2017-01-02 23:48:08 +10:30
ld-pe pe/coff: handle weak defined symbol for gc-sections. 2017-04-07 10:03:17 +02:00
ld-pie Don't run C tests in ld testsuite unless we have a C compiler 2017-01-03 11:47:47 +10:30
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 Run more ld tests when not native 2017-01-02 23:48:08 +10:30
ld-sh Run more ld tests when not native 2017-01-02 23:48:08 +10:30
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 Run more ld tests when not native 2017-01-02 23:48:08 +10:30
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 Run more ld tests when not native 2017-01-02 23:48:08 +10:30
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 Run more ld tests when not native 2017-01-02 23:48:08 +10:30
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