binutils-gdb/ld/testsuite
H.J. Lu 241e64e3b4 x86: Add a GNU_PROPERTY_X86_ISA_1_USED note if needed
When -z separate-code, which is enabled by default for Linux/x86, is
used to create executable, ld won't place any data in the code-only
PT_LOAD segment.  If there are no data sections placed before the
code-only PT_LOAD segment, the program headers won't be mapped into
any PT_LOAD segment.  When the executable tries to access it (based
on the program header address passed in AT_PHDR), it will lead to
segfault.  This patch inserts a GNU_PROPERTY_X86_ISA_1_USED note if
there may be no data sections before the text section so that the
first PT_LOAD segment won't be code-only and will contain the program
header.

Testcases are adjusted to either pass "-z noseparate-code" to ld or
discard the .note.gnu.property section.  A Linux/x86 run-time test is
added.

bfd/

	PR ld/23428
	* elfxx-x86.c (_bfd_x86_elf_link_setup_gnu_properties): If the
	separate code program header is needed, make sure that the first
	read-only PT_LOAD segment has no code by adding a
	GNU_PROPERTY_X86_ISA_1_USED note.

ld/

	PR ld/23428
	* testsuite/ld-elf/linux-x86.S: New file.
	* testsuite/ld-elf/linux-x86.exp: Likewise.
	* testsuite/ld-elf/pr23428.c: Likewise.
	* testsuite/ld-elf/sec64k.exp: Pass "-z noseparate-code" to ld
	for Linux/x86 targets.
	* testsuite/ld-i386/abs-iamcu.d: Likewise.
	* testsuite/ld-i386/abs.d: Likewise.
	* testsuite/ld-i386/pr12718.d: Likewise.
	* testsuite/ld-i386/pr12921.d: Likewise.
	* testsuite/ld-x86-64/abs-k1om.d: Likewise.
	* testsuite/ld-x86-64/abs-l1om.d: Likewise.
	* testsuite/ld-x86-64/abs.d: Likewise.
	* testsuite/ld-x86-64/pr12718.d: Likewise.
	* testsuite/ld-x86-64/pr12921.d: Likewise.
	* testsuite/ld-linkonce/zeroeh.ld: Discard .note.gnu.property
	section.
	* testsuite/ld-scripts/print-memory-usage.t: Likewise.
	* testsuite/ld-scripts/size-2.t: Likewise.
	* testsuite/lib/ld-lib.exp (run_ld_link_exec_tests): Use ld
	to create executable if language is "asm".
2018-07-20 09:19:00 -07:00
..
config
ld-aarch64 [PATCH, LD, AArch64] Fix ifunc testisms 2018-07-20 16:35:37 +01:00
ld-alpha Define various symbols conditionally in shared libraries 2018-06-08 20:17:34 +09:30
ld-arc
ld-arm [ARM] Update bfd's Tag_CPU_arch knowledge 2018-07-02 11:22:20 +01:00
ld-auto-import
ld-avr
ld-bootstrap Fix parens in ld bootstrap.exp 2018-06-26 21:28:05 +09:30
ld-cdtest
ld-checks
ld-cris ELF dynsyms 2018-06-14 11:32:01 +09:30
ld-crx
ld-cygwin
ld-d10v
ld-discard xgate testsuite fixes 2018-07-10 23:59:59 +09:30
ld-elf x86: Add a GNU_PROPERTY_X86_ISA_1_USED note if needed 2018-07-20 09:19:00 -07:00
ld-elfcomm
ld-elfvers
ld-elfvsb
ld-elfweak
ld-fastcall
ld-frv Define various symbols conditionally in shared libraries 2018-06-08 20:17:34 +09:30
ld-gc Revise "ld testsuite use of notarget" 2018-07-11 16:39:04 +09:30
ld-h8300
ld-i386 x86: Add a GNU_PROPERTY_X86_ISA_1_USED note if needed 2018-07-20 09:19:00 -07:00
ld-ia64 Define various symbols conditionally in shared libraries 2018-06-08 20:17:34 +09:30
ld-ifunc [PATCH, LD, AArch64] Fix ifunc testisms 2018-07-20 16:35:37 +01:00
ld-libs
ld-linkonce x86: Add a GNU_PROPERTY_X86_ISA_1_USED note if needed 2018-07-20 09:19:00 -07:00
ld-m68hc11
ld-m68k Define various symbols conditionally in shared libraries 2018-06-08 20:17:34 +09:30
ld-mep
ld-metag Define various symbols conditionally in shared libraries 2018-06-08 20:17:34 +09:30
ld-mips-elf MIPS/LD/testsuite: Correct mips-elf.exp test ABI/emul/endian arrangement 2018-07-12 20:01:44 +01:00
ld-misc ld testsuite use of notarget 2018-07-10 23:58:29 +09:30
ld-mmix
ld-mn10300
ld-msp430-elf
ld-nds32
ld-nios2
ld-pe ld testsuite use of notarget 2018-07-10 23:58:29 +09:30
ld-pie
ld-plugin ld: Set non_ir_ref_regular for --undefined SYMBOL 2018-07-04 06:29:13 -07:00
ld-powerpc Error for mismatched powerpc ABI tags 2018-07-05 10:21:37 +09:30
ld-pru
ld-riscv-elf
ld-s12z
ld-s390 S/390: Improve partial relro support for 64 bit 2018-07-18 13:20:06 +02:00
ld-scripts x86: Add a GNU_PROPERTY_X86_ISA_1_USED note if needed 2018-07-20 09:19:00 -07:00
ld-selective
ld-sh Define various symbols conditionally in shared libraries 2018-06-08 20:17:34 +09:30
ld-shared
ld-size
ld-sparc Define various symbols conditionally in shared libraries 2018-06-08 20:17:34 +09:30
ld-spu
ld-srec
ld-tic6x
ld-tilegx
ld-tilepro
ld-undefined
ld-unique ld testsuite use of notarget 2018-07-10 23:58:29 +09:30
ld-v850
ld-vax-elf
ld-visium
ld-vxworks
ld-x86-64 x86: Add a GNU_PROPERTY_X86_ISA_1_USED note if needed 2018-07-20 09:19:00 -07:00
ld-xc16x
ld-xstormy16
ld-xtensa
ld-z8k
lib x86: Add a GNU_PROPERTY_X86_ISA_1_USED note if needed 2018-07-20 09:19:00 -07:00
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