binutils-gdb/ld/emultempl
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
..
README Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
aarch64elf.em Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
aix.em Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
alphaelf.em Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
arclinux.em Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
armcoff.em Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
armelf.em Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
astring.sed
avrelf.em Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
beos.em Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
bfin.em Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
cr16elf.em Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
crxelf.em Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
elf-generic.em Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
elf32.em Don't attach linker created section to --just-syms bfd 2017-06-26 09:10:22 +09:30
epiphanyelf_4x4.em Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
genelf.em Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
generic.em Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
gld960.em Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
gld960c.em Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
hppaelf.em Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
ia64elf.em Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
irix.em Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
linux.em Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
lnk960.em Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
m68hc1xelf.em Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
m68kcoff.em Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
m68kelf.em Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
metagelf.em Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
mipself.em MIPS/LD: Fix a segfault from ELF `e_flags' access with non-ELF output BFD 2017-07-07 17:58:03 +01:00
mmix-elfnmmo.em Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
mmixelf.em Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
mmo.em Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
msp430.em Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
nds32elf.em Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
needrelax.em Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
netbsd.em Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
nios2elf.em Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
ostring.sed
pe.em Don't compare boolean values against TRUE or FALSE 2017-05-18 14:59:33 +09:30
pep.em Don't compare boolean values against TRUE or FALSE 2017-05-18 14:59:33 +09:30
ppc32elf.em Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
ppc64elf.em PPC64_OPT_LOCALENTRY 2017-06-01 22:47:32 +09:30
pruelf.em Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
riscvelf.em Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
rxelf.em Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
s390.em S/390: Add support for pgste marker 2017-06-23 08:00:46 +02:00
scoreelf.em Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
sh64elf.em Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
solaris2.em Solaris2/LD: Fix anonymous version script acceptance bug 2017-01-24 12:53:52 +00:00
spu_icache.S
spu_icache.o_c Regenerate spu overlay and icache manager files 2014-11-04 22:36:13 +10:30
spu_ovl.S Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
spu_ovl.o_c Regenerate spu_ovl.o_c 2016-10-15 12:53:57 +10:30
spuelf.em Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
sunos.em Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
tic6xdsbt.em Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
ticoff.em Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
v850elf.em Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
vanilla.em Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
vms.em Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
vxworks.em Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
xtensaelf.em Don't compare boolean values against TRUE or FALSE 2017-05-18 14:59:33 +09:30
z80.em Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30

README

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

The files in this directory are sourced by genscripts.sh, after
setting some variables to substitute in, to produce
C source files that contain jump tables for each emulation.

Copyright (C) 2012-2017 Free Software Foundation, Inc.

Copying and distribution of this file, with or without modification,
are permitted in any medium without royalty provided the copyright
notice and this notice are preserved.