ld: Remove PF_X from PT_PHDR segment
It was reasonable to mark PT_PHDR segment with PF_X for compatibility with UnixWare and Solaris linkers 20 years ago. But it is inappropriate today when the primary OS of GNU ld is Linux. This patch removes PF_X from PT_PHDR segment as gold does. Tested natively on Linux/x86 as well as crosss-binutils for alpha-linux, ia64-linux, powerpc64-linux, powerpc-linux, s390-linux, s390x-linux, sparc64-linux and sparc-linux. bfd/ PR ld/22423 * elf.c (_bfd_elf_map_sections_to_segments): Remove PF_X from PT_PHDR segment. ld/ PR ld/22423 * testsuite/ld-alpha/tlsbin.rd: Replace "R E " with "R +" for PT_PHDR segment. * testsuite/ld-alpha/tlsbinr.rd: Likewise. * testsuite/ld-ia64/tlsbin.rd: Likewise. * testsuite/ld-powerpc/tlsexe.r: Likewise. * testsuite/ld-powerpc/tlsexe32.r: Likewise. * testsuite/ld-powerpc/tlsexetoc.r: Likewise. * testsuite/ld-s390/tlsbin.rd: Likewise. * testsuite/ld-s390/tlsbin_64.rd: Likewise. * testsuite/ld-sparc/tlssunbin32.rd: Likewise. * testsuite/ld-sparc/tlssunbin64.rd: Likewise. * testsuite/ld-elf/pr22423.d: New test.
This commit is contained in:
parent
53892e6d23
commit
f882209d9a
14 changed files with 41 additions and 12 deletions
|
@ -1,3 +1,9 @@
|
||||||
|
2017-11-12 H.J. Lu <hongjiu.lu@intel.com>
|
||||||
|
|
||||||
|
PR ld/22423
|
||||||
|
* elf.c (_bfd_elf_map_sections_to_segments): Remove PF_X from
|
||||||
|
PT_PHDR segment.
|
||||||
|
|
||||||
2017-11-12 Alan Modra <amodra@gmail.com>
|
2017-11-12 Alan Modra <amodra@gmail.com>
|
||||||
|
|
||||||
* elflink.c (elf_link_add_object_symbols): Ignore anything but
|
* elflink.c (elf_link_add_object_symbols): Ignore anything but
|
||||||
|
|
|
@ -4610,8 +4610,7 @@ _bfd_elf_map_sections_to_segments (bfd *abfd, struct bfd_link_info *info)
|
||||||
goto error_return;
|
goto error_return;
|
||||||
m->next = NULL;
|
m->next = NULL;
|
||||||
m->p_type = PT_PHDR;
|
m->p_type = PT_PHDR;
|
||||||
/* FIXME: UnixWare and Solaris set PF_X, Irix 5 does not. */
|
m->p_flags = PF_R;
|
||||||
m->p_flags = PF_R | PF_X;
|
|
||||||
m->p_flags_valid = 1;
|
m->p_flags_valid = 1;
|
||||||
m->includes_phdrs = 1;
|
m->includes_phdrs = 1;
|
||||||
linker_created_pt_phdr_segment = TRUE;
|
linker_created_pt_phdr_segment = TRUE;
|
||||||
|
|
16
ld/ChangeLog
16
ld/ChangeLog
|
@ -1,3 +1,19 @@
|
||||||
|
2017-11-12 H.J. Lu <hongjiu.lu@intel.com>
|
||||||
|
|
||||||
|
PR ld/22423
|
||||||
|
* testsuite/ld-alpha/tlsbin.rd: Replace "R E " with "R +" for
|
||||||
|
PT_PHDR segment.
|
||||||
|
* testsuite/ld-alpha/tlsbinr.rd: Likewise.
|
||||||
|
* testsuite/ld-ia64/tlsbin.rd: Likewise.
|
||||||
|
* testsuite/ld-powerpc/tlsexe.r: Likewise.
|
||||||
|
* testsuite/ld-powerpc/tlsexe32.r: Likewise.
|
||||||
|
* testsuite/ld-powerpc/tlsexetoc.r: Likewise.
|
||||||
|
* testsuite/ld-s390/tlsbin.rd: Likewise.
|
||||||
|
* testsuite/ld-s390/tlsbin_64.rd: Likewise.
|
||||||
|
* testsuite/ld-sparc/tlssunbin32.rd: Likewise.
|
||||||
|
* testsuite/ld-sparc/tlssunbin64.rd: Likewise.
|
||||||
|
* testsuite/ld-elf/pr22423.d: New test.
|
||||||
|
|
||||||
2017-11-12 H.J. Lu <hongjiu.lu@intel.com>
|
2017-11-12 H.J. Lu <hongjiu.lu@intel.com>
|
||||||
|
|
||||||
* emulparams/elf32_x86_64.sh (TINY_READONLY_SECTION): Renamed
|
* emulparams/elf32_x86_64.sh (TINY_READONLY_SECTION): Renamed
|
||||||
|
|
|
@ -35,7 +35,7 @@ There are [0-9]+ program headers, starting at offset [0-9]+
|
||||||
|
|
||||||
Program Headers:
|
Program Headers:
|
||||||
Type +Offset +VirtAddr +PhysAddr +FileSiz +MemSiz +Flg Align
|
Type +Offset +VirtAddr +PhysAddr +FileSiz +MemSiz +Flg Align
|
||||||
PHDR +0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ 0x0+150 R E 0x8
|
PHDR +0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ 0x0+150 R +0x8
|
||||||
INTERP +0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ R +0x1
|
INTERP +0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ R +0x1
|
||||||
.*Requesting program interpreter.*
|
.*Requesting program interpreter.*
|
||||||
LOAD +0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ R E 0x10000
|
LOAD +0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ R E 0x10000
|
||||||
|
|
|
@ -35,7 +35,7 @@ There are [0-9]+ program headers, starting at offset [0-9]+
|
||||||
|
|
||||||
Program Headers:
|
Program Headers:
|
||||||
+Type +Offset +VirtAddr +PhysAddr +FileSiz +MemSiz +Flg Align
|
+Type +Offset +VirtAddr +PhysAddr +FileSiz +MemSiz +Flg Align
|
||||||
+PHDR +0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ R E 0x8
|
+PHDR +0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ R +0x8
|
||||||
+INTERP +0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ R +0x1
|
+INTERP +0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ R +0x1
|
||||||
.*Requesting program interpreter.*
|
.*Requesting program interpreter.*
|
||||||
+LOAD +0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ R E 0x10000
|
+LOAD +0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ R E 0x10000
|
||||||
|
|
8
ld/testsuite/ld-elf/pr22423.d
Normal file
8
ld/testsuite/ld-elf/pr22423.d
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
#source: start.s
|
||||||
|
#readelf: -l -W
|
||||||
|
#ld: -pie
|
||||||
|
#target: *-*-linux* *-*-gnu*
|
||||||
|
|
||||||
|
#...
|
||||||
|
+PHDR +0x[0-9a-f]+ +0x[0-9a-f]+ +0x[0-9a-f]+ +0x[0-9a-f]+ +0x[0-9a-f]+ +R +0x[48]?
|
||||||
|
#pass
|
|
@ -36,7 +36,7 @@ There are [0-9]+ program headers, starting at offset [0-9]+
|
||||||
|
|
||||||
Program Headers:
|
Program Headers:
|
||||||
+Type +Offset +VirtAddr +PhysAddr +FileSiz +MemSiz +Flg Align
|
+Type +Offset +VirtAddr +PhysAddr +FileSiz +MemSiz +Flg Align
|
||||||
+PHDR +0x0+40 0x40+40 0x40+40 0x0+188 0x0+188 R E 0x8
|
+PHDR +0x0+40 0x40+40 0x40+40 0x0+188 0x0+188 R +0x8
|
||||||
+INTERP +0x0+1c8 0x40+1c8 0x40+1c8 0x[0-9a-f]+ 0x[0-9a-f]+ R +0x1
|
+INTERP +0x0+1c8 0x40+1c8 0x40+1c8 0x[0-9a-f]+ 0x[0-9a-f]+ R +0x1
|
||||||
.*Requesting program interpreter.*
|
.*Requesting program interpreter.*
|
||||||
+LOAD +0x0+ 0x40+ 0x40+ 0x0+1[0-9a-f]+ 0x0+1[0-9a-f]+ R E 0x10000
|
+LOAD +0x0+ 0x40+ 0x40+ 0x0+1[0-9a-f]+ 0x0+1[0-9a-f]+ R E 0x10000
|
||||||
|
|
|
@ -34,7 +34,7 @@ There are [0-9]+ program headers, starting at offset [0-9]+
|
||||||
|
|
||||||
Program Headers:
|
Program Headers:
|
||||||
+Type +Offset +VirtAddr +PhysAddr +FileSiz +MemSiz +Flg Align
|
+Type +Offset +VirtAddr +PhysAddr +FileSiz +MemSiz +Flg Align
|
||||||
+PHDR +0x0+40 0x0+10000040 0x0+10000040 0x0+150 0x0+150 R E 0x8
|
+PHDR +0x0+40 0x0+10000040 0x0+10000040 0x0+150 0x0+150 R +0x8
|
||||||
+INTERP +0x0+190 0x0+10000190 0x0+10000190 0x0+11 0x0+11 R +0x1
|
+INTERP +0x0+190 0x0+10000190 0x0+10000190 0x0+11 0x0+11 R +0x1
|
||||||
+\[Requesting program interpreter: .*\]
|
+\[Requesting program interpreter: .*\]
|
||||||
+LOAD .* R E 0x10000
|
+LOAD .* R E 0x10000
|
||||||
|
|
|
@ -33,7 +33,7 @@ There are [0-9]+ program headers, starting at offset [0-9]+
|
||||||
|
|
||||||
Program Headers:
|
Program Headers:
|
||||||
+Type +Offset +VirtAddr +PhysAddr +FileSiz MemSiz +Flg Align
|
+Type +Offset +VirtAddr +PhysAddr +FileSiz MemSiz +Flg Align
|
||||||
+PHDR +0x000034 0x01800034 0x01800034 0x000c0 0x000c0 R E 0x4
|
+PHDR +0x000034 0x01800034 0x01800034 0x000c0 0x000c0 R +0x4
|
||||||
+INTERP +0x0000f4 0x018000f4 0x018000f4 0x00011 0x00011 R +0x1
|
+INTERP +0x0000f4 0x018000f4 0x018000f4 0x00011 0x00011 R +0x1
|
||||||
+\[Requesting program interpreter: .*\]
|
+\[Requesting program interpreter: .*\]
|
||||||
+LOAD .* R E 0x10000
|
+LOAD .* R E 0x10000
|
||||||
|
|
|
@ -34,7 +34,7 @@ There are [0-9]+ program headers, starting at offset [0-9]+
|
||||||
|
|
||||||
Program Headers:
|
Program Headers:
|
||||||
+Type +Offset +VirtAddr +PhysAddr +FileSiz +MemSiz +Flg Align
|
+Type +Offset +VirtAddr +PhysAddr +FileSiz +MemSiz +Flg Align
|
||||||
+PHDR +0x0+40 0x0+10000040 0x0+10000040 0x0+150 0x0+150 R E 0x8
|
+PHDR +0x0+40 0x0+10000040 0x0+10000040 0x0+150 0x0+150 R +0x8
|
||||||
+INTERP +0x0+190 0x0+10000190 0x0+10000190 0x0+11 0x0+11 R +0x1
|
+INTERP +0x0+190 0x0+10000190 0x0+10000190 0x0+11 0x0+11 R +0x1
|
||||||
+\[Requesting program interpreter: .*\]
|
+\[Requesting program interpreter: .*\]
|
||||||
+LOAD .* R E 0x10000
|
+LOAD .* R E 0x10000
|
||||||
|
|
|
@ -34,7 +34,7 @@ There are [0-9]+ program headers, starting at offset [0-9]+
|
||||||
|
|
||||||
Program Headers:
|
Program Headers:
|
||||||
+Type +Offset +VirtAddr +PhysAddr +FileSiz +MemSiz +Flg Align
|
+Type +Offset +VirtAddr +PhysAddr +FileSiz +MemSiz +Flg Align
|
||||||
+PHDR +0x0+34 0x0+400034 0x0+400034 0x0+c0 0x0+c0 R E 0x4
|
+PHDR +0x0+34 0x0+400034 0x0+400034 0x0+c0 0x0+c0 R +0x4
|
||||||
+INTERP +0x0+f4 0x0+4000f4 0x0+4000f4 0x0+d 0x0+d R +0x1
|
+INTERP +0x0+f4 0x0+4000f4 0x0+4000f4 0x0+d 0x0+d R +0x1
|
||||||
.*Requesting program interpreter.*
|
.*Requesting program interpreter.*
|
||||||
+LOAD .* R E 0x1000
|
+LOAD .* R E 0x1000
|
||||||
|
|
|
@ -34,7 +34,7 @@ There are [0-9]+ program headers, starting at offset [0-9]+
|
||||||
|
|
||||||
Program Headers:
|
Program Headers:
|
||||||
+Type +Offset +VirtAddr +PhysAddr +FileSiz +MemSiz +Flg Align
|
+Type +Offset +VirtAddr +PhysAddr +FileSiz +MemSiz +Flg Align
|
||||||
+PHDR +0x0+40 0x0+1000040 0x0+1000040 0x0+150 0x0+150 R E 0x8
|
+PHDR +0x0+40 0x0+1000040 0x0+1000040 0x0+150 0x0+150 R +0x8
|
||||||
+INTERP +0x0+190 0x0+1000190 0x0+1000190 0x0+f 0x0+f R +0x1
|
+INTERP +0x0+190 0x0+1000190 0x0+1000190 0x0+f 0x0+f R +0x1
|
||||||
.*Requesting program interpreter.*
|
.*Requesting program interpreter.*
|
||||||
+LOAD .* R E 0x1000
|
+LOAD .* R E 0x1000
|
||||||
|
|
|
@ -30,7 +30,7 @@ There are [0-9]+ program headers, starting at offset [0-9]+
|
||||||
|
|
||||||
Program Headers:
|
Program Headers:
|
||||||
+Type +Offset +VirtAddr +PhysAddr +FileSiz MemSiz +Flg Align
|
+Type +Offset +VirtAddr +PhysAddr +FileSiz MemSiz +Flg Align
|
||||||
+PHDR +0x0+34 0x0+10034 0x0+10034 0x0+c0 0x0+c0 R E 0x4
|
+PHDR +0x0+34 0x0+10034 0x0+10034 0x0+c0 0x0+c0 R +0x4
|
||||||
+INTERP +0x0+f4 0x0+100f4 0x0+100f4 0x0+11 0x0+11 R +0x1
|
+INTERP +0x0+f4 0x0+100f4 0x0+100f4 0x0+11 0x0+11 R +0x1
|
||||||
.*Requesting program interpreter.*
|
.*Requesting program interpreter.*
|
||||||
+LOAD .* R E 0x10000
|
+LOAD .* R E 0x10000
|
||||||
|
|
|
@ -30,7 +30,7 @@ There are [0-9]+ program headers, starting at offset [0-9]+
|
||||||
|
|
||||||
Program Headers:
|
Program Headers:
|
||||||
+Type +Offset +VirtAddr +PhysAddr +FileSiz +MemSiz +Flg Align
|
+Type +Offset +VirtAddr +PhysAddr +FileSiz +MemSiz +Flg Align
|
||||||
+PHDR +0x0+40 0x0+100040 0x0+100040 0x0+150 0x0+150 R E 0x8
|
+PHDR +0x0+40 0x0+100040 0x0+100040 0x0+150 0x0+150 R +0x8
|
||||||
+INTERP +0x0+190 0x0+100190 0x0+100190 0x0+19 0x0+19 R +0x1
|
+INTERP +0x0+190 0x0+100190 0x0+100190 0x0+19 0x0+19 R +0x1
|
||||||
.*Requesting program interpreter.*
|
.*Requesting program interpreter.*
|
||||||
+LOAD .* R E 0x100000
|
+LOAD .* R E 0x100000
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue