Bug 22845 - -z separate-code doesn't work right
Summary: -z separate-code doesn't work right
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: ld (show other bugs)
Version: 2.31
: P2 normal
Target Milestone: 2.31
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-02-14 00:02 UTC by H.J. Lu
Modified: 2018-03-31 12:35 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description H.J. Lu 2018-02-14 00:02:29 UTC
On x86-64, with

diff --git a/ld/emulparams/elf_x86_64.sh b/ld/emulparams/elf_x86_64.sh
index d8c6e54894..d0d4686fc2 100644
--- a/ld/emulparams/elf_x86_64.sh
+++ b/ld/emulparams/elf_x86_64.sh
@@ -14,6 +14,7 @@ COMMONPAGESIZE="CONSTANT (COMMONPAGESIZE)"
 ARCH="i386:x86-64"
 MACHINE=
 TEMPLATE_NAME=elf32
+SEPARATE_CODE=yes
 GENERATE_SHLIB_SCRIPT=yes
 GENERATE_PIE_SCRIPT=yes
 NO_SMALL_DATA=yes

I got

FAIL: ld-elf/ehdr_start-shared
FAIL: ld-elf/ehdr_start
FAIL: ld-elf/loadaddr1
FAIL: ld-elf/loadaddr2
FAIL: ld-elf/mbind1b
FAIL: ld-elf/mbind1c
FAIL: ld-elf/orphan-region
FAIL: ld-elf/pie
FAIL: ld-elf/pr19162
FAIL: ld-elf/pr22393-1c
FAIL: ld-elf/pr22393-1d
FAIL: ld-elf/pr22423
FAIL: ld-elf/textaddr1
FAIL: ld-elf/textaddr2
FAIL: ld-elf/textaddr4
FAIL: ld-elf/textaddr6
FAIL: PIE preinit array
FAIL: PIE init array
FAIL: PIE fini array
FAIL: PIE init array mixed
FAIL: PIE PR ld/14525
FAIL: Run mbind2b
FAIL: static preinit array
FAIL: static init array
FAIL: static fini array
FAIL: static init array mixed
FAIL: Run indirect5 3
FAIL: Run indirect5 4
FAIL: Run indirect6 3
FAIL: Run indirect6 4
FAIL: indirect5c dynsym
FAIL: indirect5d dynsym
FAIL: indirect6c dynsym
FAIL: indirect6d dynsym
FAIL: Build pr22393-2 (PIE)
FAIL: Run pr18458 with PIE
FAIL: Run pr2404 with PIE
FAIL: Run pr2404 with PIE (-z now)
FAIL: Run pr18718 with PIE (1)
FAIL: Run pr18718 with PIE (3)
FAIL: Run pr18718 with PIC (2)
FAIL: Run pr18718 with PIC (4)
FAIL: Run pr19579
FAIL: Run pr19579 (-z now)
FAIL: Run pr22393-2 (PIE)
FAIL: Run pr22393-2 (static)
FAIL: Run pr19719pie fun defined
FAIL: Build pr22263-1
FAIL: TLS -fpic -shared transitions
FAIL: TLS -fpic -shared transitions without PLT
FAIL: TLS descriptor -fpic -shared transitions
FAIL: TLS -fpic and -fno-pic exec transitions
FAIL: TLS -fpic and -fno-pic exec transitions without PLT
FAIL: TLS descriptor -fpic and -fno-pic exec transitions
FAIL: TLS -fno-pic -shared
FAIL: TLS with global dynamic and descriptors
FAIL: Basic --emit-relocs support
FAIL: Build pr19827
FAIL: ld-i386/protected5
FAIL: TLS with PIE
FAIL: TLS with PIE
FAIL: ld-i386/tlspie3a
FAIL: ld-i386/tlspie3b
FAIL: ld-i386/tlspie3c
FAIL: ld-i386/nogot2
FAIL: ld-i386/lea1b
FAIL: ld-i386/lea1e
FAIL: ld-i386/mov2b
FAIL: ld-i386/load1
FAIL: ld-i386/pr19615
FAIL: ld-i386/pr19636-1a
FAIL: ld-i386/pr19636-1b
FAIL: ld-i386/pr19636-1j
FAIL: ld-i386/pr19636-1k
FAIL: ld-i386/pr19636-2a
FAIL: ld-i386/pr19636-2b
FAIL: ld-i386/pr19636-2c
FAIL: ld-i386/pr19636-3a
FAIL: ld-i386/pr19636-3b
FAIL: ld-i386/pr19636-3c
FAIL: ld-i386/pr19636-3h
FAIL: ld-i386/pr19636-3i
FAIL: ld-i386/pr19636-4a
FAIL: ld-i386/pr19636-4b
FAIL: ld-i386/pr19609-2b
FAIL: ld-i386/undefweakb
FAIL: ld-i386/pr20244-1a
FAIL: ld-i386/pr20244-1b
FAIL: ld-i386/pr20244-1c
FAIL: ld-i386/pr20244-2a
FAIL: ld-i386/pr20244-2b
FAIL: ld-i386/pr20244-2c
FAIL: ld-i386/pr20244-2d
FAIL: ld-i386/pr20244-4a
FAIL: ld-i386/pr20244-4b
FAIL: ld-i386/pr20244-4c
FAIL: ld-i386/pr20253-4b
FAIL: ld-i386/pie1
FAIL: ld-i386/pr22115-1a
FAIL: ld-i386/pr22115-1b
FAIL: ld-i386/pr22135
FAIL: PR ld/13302
FAIL: basic PLT generation (non-PIC, -z now)
FAIL: PR ld/20830 (.plt.got)
FAIL: ld-i386/ibt-plt-1
FAIL: ld-i386/ibt-plt-2a
FAIL: ld-i386/ibt-plt-2b
FAIL: ld-i386/ibt-plt-2c
FAIL: ld-i386/ibt-plt-2d
FAIL: ld-i386/ibt-plt-3a
FAIL: ld-i386/ibt-plt-3b
FAIL: ld-i386/ibt-plt-3c
FAIL: ld-i386/ibt-plt-3d
FAIL: Common symbol override ifunc test 1a
FAIL: Common symbol override ifunc test 1b
FAIL: ld-ifunc/ifunc-1-local-x86
FAIL: ld-ifunc/ifunc-1-x86
FAIL: ld-ifunc/ifunc-2-i386-now
FAIL: ld-ifunc/ifunc-2-local-i386-now
FAIL: ld-ifunc/ifunc-2-local-x86-64-now
FAIL: ld-ifunc/ifunc-2-local-x86-64
FAIL: ld-ifunc/ifunc-2-x86-64-now
FAIL: ld-ifunc/ifunc-2-x86-64
FAIL: ld-ifunc/ifunc-21-i386
FAIL: ld-ifunc/ifunc-21-x86-64
FAIL: ld-ifunc/ifunc-22-i386
FAIL: ld-ifunc/ifunc-22-x86-64
FAIL: ld-ifunc/ifunc-23b-x86
FAIL: ld-ifunc/ifunc-24b-x86
FAIL: ld-ifunc/ifunc-25b-x86
FAIL: ld-ifunc/ifunc-3a-x86
FAIL: ld-ifunc/pr17154-i386-now
FAIL: ld-ifunc/pr17154-i386
FAIL: ld-ifunc/pr17154-x86-64-now
FAIL: ld-ifunc/pr17154-x86-64
FAIL: Run ifunc-main with PIE (-z now)
FAIL: weak undefined
FAIL: weak undefined data
FAIL: missing entry symbol
FAIL: zero p_vaddr
FAIL: weak undefined functions in pie, no dyn undef weak
FAIL: weak undefined functions in pie, dyn undef weak
FAIL: Build mpx4
FAIL: Build mpx3 (-z now)
FAIL: Build mpx4 (-z now)
FAIL: Run mpx1 with -static
FAIL: Run mpx2
FAIL: Run mpx2 with -static
FAIL: ld-x86-64/bnd-ifunc-1
FAIL: ld-x86-64/bnd-ifunc-2
FAIL: ld-x86-64/bnd-plt-1
FAIL: ld-x86-64/bnd-branch-1-now
FAIL: ld-x86-64/bnd-ifunc-1-now
FAIL: ld-x86-64/bnd-ifunc-2-now
FAIL: ld-x86-64/bnd-plt-1-now
FAIL: No PLT (PIE 1e)
FAIL: No PLT (PIE 1f)
FAIL: No PLT (PIE 1g)
FAIL: No PLT (static 1d)
FAIL: No PLT (PIE 1e)
FAIL: No PLT (PIE 1f)
FAIL: No PLT (PIE 1g)
FAIL: Run pr20253-2b
FAIL: Run pr20253-2c
FAIL: Run pr20253-2e
FAIL: Run pr20253-2g
FAIL: TLS GD/LD -> LE transition without PLT (PIE)
FAIL: TLS GD/LD -> LE transition without PLT (PIE, -z now)
FAIL: TLS GD/LD -> LE transition without PLT (static)
FAIL: Run tlsdesc1 with PIE
FAIL: Run tlsdesc1 with PIE (-z now)
FAIL: TLS -fpic -shared transitions
FAIL: TLS -fpic -shared transitions with r15 as GOT base
FAIL: TLS descriptor -fpic -shared transitions
FAIL: TLS -fpic and -fno-pic exec transitions
FAIL: TLS -fpic and -fno-pic exec transitions without PLT
FAIL: TLS descriptor -fpic and -fno-pic exec transitions
FAIL: TLS with global dynamic and descriptors
FAIL: Build pr19827
FAIL: Build pr20550
FAIL: ld-x86-64/protected5
FAIL: TLS LE with PIE
FAIL: TLS with PIE
FAIL: ld-x86-64/tlspie2a
FAIL: ld-x86-64/tlspie2b
FAIL: ld-x86-64/tlspie2c
FAIL: ld-x86-64/nogot2
FAIL: PR ld/14207
FAIL: PIE with undefined symbol
FAIL: ld-x86-64/pie3
FAIL: ld-x86-64/pr19807-1a
FAIL: ld-x86-64/pr19807-1b
FAIL: ld-x86-64/pr19807-2b
FAIL: ld-x86-64/pr19807-2c
FAIL: ld-x86-64/pr19807-2d
FAIL: ld-x86-64/pr19807-2e
FAIL: ld-x86-64/pr20093-1
FAIL: ld-x86-64/pr20093-2
FAIL: ld-x86-64/pr22115-1a
FAIL: ld-x86-64/pr22115-1a-x32
FAIL: ld-x86-64/pr22115-1b
FAIL: ld-x86-64/pr22115-1b-x32
FAIL: ld-x86-64/pr22115-1c
FAIL: ld-x86-64/pr22115-1c-x32
FAIL: ld-x86-64/pr22135
FAIL: ld-x86-64/ilp32-4
FAIL: PR ld/13082-1 (b)
FAIL: PR ld/13082-2 (b)
FAIL: PR ld/13082-3 (b)
FAIL: PR ld/13082-3 (d)
FAIL: PR ld/13082-4 (b)
FAIL: PR ld/13082-5 (b)
FAIL: PR ld/13082-6 (b)
FAIL: ld-x86-64/lea1b
FAIL: ld-x86-64/lea1e
FAIL: ld-x86-64/lea1h
FAIL: ld-x86-64/lea1k
FAIL: ld-x86-64/mov2b
FAIL: ld-x86-64/mov2d
FAIL: ld-x86-64/load1a
FAIL: ld-x86-64/load1b
FAIL: ld-x86-64/load1c
FAIL: ld-x86-64/load1d
FAIL: PR ld/18176
FAIL: ld-x86-64/pr19162
FAIL: ld-x86-64/pr19615
FAIL: ld-x86-64/pr19636-1a
FAIL: ld-x86-64/pr19636-1b
FAIL: ld-x86-64/pr19636-1c
FAIL: ld-x86-64/pr19636-1h
FAIL: ld-x86-64/pr19636-1i
FAIL: ld-x86-64/pr19636-2d
FAIL: ld-x86-64/pr19636-2l
FAIL: ld-x86-64/pr19636-3a
FAIL: ld-x86-64/pr19636-3b
FAIL: ld-x86-64/pr19609-1m
FAIL: ld-x86-64/pr19609-5b
FAIL: ld-x86-64/pr20253-1b
FAIL: ld-x86-64/pr20253-1c
FAIL: ld-x86-64/pr20253-1d
FAIL: ld-x86-64/pr20253-1f
FAIL: ld-x86-64/pr20253-1h
FAIL: ld-x86-64/pr20253-1i
FAIL: ld-x86-64/pr20253-1j
FAIL: ld-x86-64/pr20253-1l
FAIL: ld-x86-64/pr20253-4b
FAIL: ld-x86-64/pr20253-4e
FAIL: Build plt-main with PIE
FAIL: Build copyreloc-main with PIE without -fPIE (1)
FAIL: Build copyreloc-main with PIE without -fPIE (2)
FAIL: Build pr17689 with PIE without -fPIE
FAIL: Build pr17689 with PIE -z now without -fPIE
FAIL: Build pr17827 with PIE without -fPIE
FAIL: Build pr19319
FAIL: Build pr22393-3 (PIE)
FAIL: Build pr22791-1
FAIL: Build pr22791-2
FAIL: Run plt-main with PIE
FAIL: Run copyreloc-main with PIE without -fPIE
FAIL: Run pr17689 with PIE without -fPIE
FAIL: Run pr17689 with PIE -z now without -fPIE
FAIL: Run property 1 (PIE)
FAIL: Run property 1 (static)
FAIL: Run property 2 (PIE)
FAIL: Run property 2 (static)
FAIL: Run property 3 (PIE)
FAIL: Run property 3 (static)
FAIL: Run property 4 (PIE)
FAIL: Run property 4 (static)
FAIL: Run property 5 (PIE)
FAIL: Run property 5 (static)
FAIL: Run pr22001-1a (PIC 2)
FAIL: Run pr22001-1b (PIC 2)
FAIL: Run pr21997-1a (PIC 2)
FAIL: Run pr21997-1b (PIC 2)
FAIL: Run pr22064
FAIL: Run pr22393-3 (PIE)
FAIL: Run pr22393-3 (static)
FAIL: Run pr22791-2
FAIL: Build plt-main with -z bndplt
FAIL: Build plt-main with PIE and -z bndplt
FAIL: Build plt-main with -z bndplt -z now
FAIL: Build plt-main with PIE and -z bndplt -z now
FAIL: Run plt-main with PIE and -z bndplt
FAIL: Run plt-main with PIE and -z bndplt -z now
FAIL: Run pr20800
FAIL: Build plt-main with -z ibtplt
FAIL: Build plt-main with PIE and -z ibtplt
FAIL: Build plt-main with -z ibtplt -z now
FAIL: Build plt-main with PIE and -z ibtplt -z now
FAIL: Build libibtplt-lib.so with -z ibtplt
FAIL: Build libibtplt--now-lib.so with -z ibtplt -z now
FAIL: Run plt-main with PIE and -z ibtplt
FAIL: Run plt-main with PIE and -z ibtplt -z now
FAIL: Run pr19704
FAIL: Run pr19704
FAIL: basic PLT generation (-z now)
FAIL: PR ld/20830 (.plt.got)
FAIL: PR ld/20830 (.plt.got)
FAIL: PR ld/21038 (.plt.got)
FAIL: PR ld/21038 (.plt.sec)
FAIL: PR ld/21038 (.plt.got and .plt.sec)
FAIL: PR ld/20830 (.plt.got, -z now)
FAIL: PR ld/20830 (.plt.got, -z now)
FAIL: PR ld/21038 (.plt.got, -z now)
FAIL: PR ld/21038 (.plt.sec, -z now)
FAIL: PR ld/21038 (.plt.got and .plt.sec, -z now)
FAIL: ld-x86-64/ibt-plt-1
FAIL: ld-x86-64/ibt-plt-1-x32
FAIL: ld-x86-64/ibt-plt-2a
FAIL: ld-x86-64/ibt-plt-2b
FAIL: ld-x86-64/ibt-plt-2c
FAIL: ld-x86-64/ibt-plt-2d
FAIL: ld-x86-64/ibt-plt-2a-x32
FAIL: ld-x86-64/ibt-plt-2b-x32
FAIL: ld-x86-64/ibt-plt-2c-x32
FAIL: ld-x86-64/ibt-plt-2d-x32
FAIL: ld-x86-64/ibt-plt-3a
FAIL: ld-x86-64/ibt-plt-3b
FAIL: ld-x86-64/ibt-plt-3c
FAIL: ld-x86-64/ibt-plt-3d
FAIL: ld-x86-64/ibt-plt-3a-x32
FAIL: ld-x86-64/ibt-plt-3b-x32
FAIL: ld-x86-64/ibt-plt-3c-x32
FAIL: ld-x86-64/ibt-plt-3d-x32

Some failures are expected.  Many are real bugs.
Comment 1 H.J. Lu 2018-02-14 12:19:13 UTC
Static binary died at:

Program received signal SIGSEGV, Segmentation fault.
__libc_setup_tls () at libc-tls.c:122
122	      if (phdr->p_type == PT_TLS)
(gdb) p *phdr
Cannot access memory at address 0x8047034

Program header isn't mapped in:

Elf file type is EXEC (Executable file)
Entry point 0x80487f2
There are 7 program headers, starting at offset 52

Program Headers:
  Type           Offset   VirtAddr   PhysAddr   FileSiz MemSiz  Flg Align
  LOAD           0x001000 0x08048000 0x08048000 0x5de08 0x5de08 R E 0x1000
  LOAD           0x05ee08 0x080a6e08 0x080a6e08 0x22f8b 0x22f8b R   0x1000
  LOAD           0x082b80 0x080cbb80 0x080cbb80 0x013d4 0x01fbc RW  0x1000
  NOTE           0x05ee08 0x080a6e08 0x080a6e08 0x00044 0x00044 R   0x4
  TLS            0x082b80 0x080cbb80 0x080cbb80 0x00010 0x00030 R   0x4
  GNU_STACK      0x000000 0x00000000 0x00000000 0x00000 0x00000 RW  0x10
  GNU_RELRO      0x082b80 0x080cbb80 0x080cbb80 0x00480 0x00480 R   0x1
Comment 2 H.J. Lu 2018-02-14 12:50:15 UTC
Wrong linker script is used.
Comment 3 H.J. Lu 2018-02-14 13:16:04 UTC
With this patch:

https://sourceware.org/ml/binutils/2018-02/msg00212.html

now I got

FAIL: ld-elf/ehdr_start-shared
FAIL: ld-elf/ehdr_start
FAIL: ld-elf/loadaddr1
FAIL: ld-elf/loadaddr2
FAIL: ld-elf/mbind1b
FAIL: ld-elf/mbind1c
FAIL: ld-elf/orphan-region
FAIL: ld-elf/pie
FAIL: ld-elf/pr19162
FAIL: ld-elf/pr22393-1c
FAIL: ld-elf/pr22393-1d
FAIL: ld-elf/pr22423
FAIL: ld-elf/textaddr1
FAIL: ld-elf/textaddr2
FAIL: ld-elf/textaddr4
FAIL: ld-elf/textaddr6
FAIL: PIE preinit array
FAIL: PIE init array
FAIL: PIE fini array
FAIL: PIE init array mixed
FAIL: PIE PR ld/14525
FAIL: Run mbind2b
FAIL: static preinit array
FAIL: static init array
FAIL: static fini array
FAIL: static init array mixed
FAIL: Run indirect5 3
FAIL: Run indirect5 4
FAIL: Run indirect6 3
FAIL: Run indirect6 4
FAIL: indirect5c dynsym
FAIL: indirect5d dynsym
FAIL: indirect6c dynsym
FAIL: indirect6d dynsym
FAIL: Build pr22393-2 (PIE)
FAIL: Run pr18458 with PIE
FAIL: Run pr2404 with PIE
FAIL: Run pr2404 with PIE (-z now)
FAIL: Run pr18718 with PIE (1)
FAIL: Run pr18718 with PIE (3)
FAIL: Run pr18718 with PIC (2)
FAIL: Run pr18718 with PIC (4)
FAIL: Run pr19579
FAIL: Run pr19579 (-z now)
FAIL: Run pr22393-2 (PIE)
FAIL: Run pr22393-2 (static)
FAIL: Run pr19719pie fun defined
FAIL: Build pr22263-1
FAIL: TLS -fpic -shared transitions
FAIL: TLS -fpic -shared transitions without PLT
FAIL: TLS descriptor -fpic -shared transitions
FAIL: TLS -fpic and -fno-pic exec transitions
FAIL: TLS -fpic and -fno-pic exec transitions without PLT
FAIL: TLS descriptor -fpic and -fno-pic exec transitions
FAIL: TLS -fno-pic -shared
FAIL: TLS with global dynamic and descriptors
FAIL: Basic --emit-relocs support
FAIL: Build pr19827
FAIL: ld-i386/protected5
FAIL: TLS with PIE
FAIL: TLS with PIE
FAIL: ld-i386/tlspie3a
FAIL: ld-i386/tlspie3b
FAIL: ld-i386/tlspie3c
FAIL: ld-i386/nogot2
FAIL: ld-i386/lea1b
FAIL: ld-i386/lea1e
FAIL: ld-i386/mov2b
FAIL: ld-i386/load1
FAIL: ld-i386/pr19615
FAIL: ld-i386/pr19636-1a
FAIL: ld-i386/pr19636-1b
FAIL: ld-i386/pr19636-1j
FAIL: ld-i386/pr19636-1k
FAIL: ld-i386/pr19636-2a
FAIL: ld-i386/pr19636-2b
FAIL: ld-i386/pr19636-2c
FAIL: ld-i386/pr19636-3a
FAIL: ld-i386/pr19636-3b
FAIL: ld-i386/pr19636-3c
FAIL: ld-i386/pr19636-3h
FAIL: ld-i386/pr19636-3i
FAIL: ld-i386/pr19636-4a
FAIL: ld-i386/pr19636-4b
FAIL: ld-i386/pr19609-2b
FAIL: ld-i386/undefweakb
FAIL: ld-i386/pr20244-1a
FAIL: ld-i386/pr20244-1b
FAIL: ld-i386/pr20244-1c
FAIL: ld-i386/pr20244-2a
FAIL: ld-i386/pr20244-2b
FAIL: ld-i386/pr20244-2c
FAIL: ld-i386/pr20244-2d
FAIL: ld-i386/pr20244-4a
FAIL: ld-i386/pr20244-4b
FAIL: ld-i386/pr20244-4c
FAIL: ld-i386/pr20253-4b
FAIL: ld-i386/pie1
FAIL: ld-i386/pr22115-1a
FAIL: ld-i386/pr22115-1b
FAIL: ld-i386/pr22135
FAIL: PR ld/13302
FAIL: basic PLT generation (non-PIC, -z now)
FAIL: PR ld/20830 (.plt.got)
FAIL: ld-i386/ibt-plt-1
FAIL: ld-i386/ibt-plt-2a
FAIL: ld-i386/ibt-plt-2b
FAIL: ld-i386/ibt-plt-2c
FAIL: ld-i386/ibt-plt-2d
FAIL: ld-i386/ibt-plt-3a
FAIL: ld-i386/ibt-plt-3b
FAIL: ld-i386/ibt-plt-3c
FAIL: ld-i386/ibt-plt-3d
FAIL: Common symbol override ifunc test 1a
FAIL: Common symbol override ifunc test 1b
FAIL: ld-ifunc/ifunc-1-local-x86
FAIL: ld-ifunc/ifunc-1-x86
FAIL: ld-ifunc/ifunc-2-i386-now
FAIL: ld-ifunc/ifunc-2-local-i386-now
FAIL: ld-ifunc/ifunc-2-local-x86-64-now
FAIL: ld-ifunc/ifunc-2-local-x86-64
FAIL: ld-ifunc/ifunc-2-x86-64-now
FAIL: ld-ifunc/ifunc-2-x86-64
FAIL: ld-ifunc/ifunc-21-i386
FAIL: ld-ifunc/ifunc-21-x86-64
FAIL: ld-ifunc/ifunc-22-i386
FAIL: ld-ifunc/ifunc-22-x86-64
FAIL: ld-ifunc/ifunc-23b-x86
FAIL: ld-ifunc/ifunc-24b-x86
FAIL: ld-ifunc/ifunc-25b-x86
FAIL: ld-ifunc/ifunc-3a-x86
FAIL: ld-ifunc/pr17154-i386-now
FAIL: ld-ifunc/pr17154-i386
FAIL: ld-ifunc/pr17154-x86-64-now
FAIL: ld-ifunc/pr17154-x86-64
FAIL: Run ifunc-main with PIE (-z now)
FAIL: weak undefined
FAIL: weak undefined data
FAIL: missing entry symbol
FAIL: zero p_vaddr
FAIL: weak undefined functions in pie, no dyn undef weak
FAIL: weak undefined functions in pie, dyn undef weak
FAIL: Build mpx4
FAIL: Build mpx3 (-z now)
FAIL: Build mpx4 (-z now)
FAIL: Run mpx1 with -static
FAIL: Run mpx2
FAIL: Run mpx2 with -static
FAIL: ld-x86-64/bnd-ifunc-1
FAIL: ld-x86-64/bnd-ifunc-2
FAIL: ld-x86-64/bnd-plt-1
FAIL: ld-x86-64/bnd-branch-1-now
FAIL: ld-x86-64/bnd-ifunc-1-now
FAIL: ld-x86-64/bnd-ifunc-2-now
FAIL: ld-x86-64/bnd-plt-1-now
FAIL: No PLT (PIE 1e)
FAIL: No PLT (PIE 1f)
FAIL: No PLT (PIE 1g)
FAIL: No PLT (static 1d)
FAIL: No PLT (PIE 1e)
FAIL: No PLT (PIE 1f)
FAIL: No PLT (PIE 1g)
FAIL: Run pr20253-2b
FAIL: Run pr20253-2c
FAIL: Run pr20253-2e
FAIL: Run pr20253-2g
FAIL: TLS GD/LD -> LE transition without PLT (PIE)
FAIL: TLS GD/LD -> LE transition without PLT (PIE, -z now)
FAIL: TLS GD/LD -> LE transition without PLT (static)
FAIL: Run tlsdesc1 with PIE
FAIL: Run tlsdesc1 with PIE (-z now)
FAIL: TLS -fpic -shared transitions
FAIL: TLS -fpic -shared transitions with r15 as GOT base
FAIL: TLS descriptor -fpic -shared transitions
FAIL: TLS -fpic and -fno-pic exec transitions
FAIL: TLS -fpic and -fno-pic exec transitions without PLT
FAIL: TLS descriptor -fpic and -fno-pic exec transitions
FAIL: TLS with global dynamic and descriptors
FAIL: Build pr19827
FAIL: Build pr20550
FAIL: ld-x86-64/protected5
FAIL: TLS LE with PIE
FAIL: TLS with PIE
FAIL: ld-x86-64/tlspie2a
FAIL: ld-x86-64/tlspie2b
FAIL: ld-x86-64/tlspie2c
FAIL: ld-x86-64/nogot2
FAIL: PR ld/14207
FAIL: PIE with undefined symbol
FAIL: ld-x86-64/pie3
FAIL: ld-x86-64/pr19807-1a
FAIL: ld-x86-64/pr19807-1b
FAIL: ld-x86-64/pr19807-2b
FAIL: ld-x86-64/pr19807-2c
FAIL: ld-x86-64/pr19807-2d
FAIL: ld-x86-64/pr19807-2e
FAIL: ld-x86-64/pr20093-1
FAIL: ld-x86-64/pr20093-2
FAIL: ld-x86-64/pr22115-1a
FAIL: ld-x86-64/pr22115-1a-x32
FAIL: ld-x86-64/pr22115-1b
FAIL: ld-x86-64/pr22115-1b-x32
FAIL: ld-x86-64/pr22115-1c
FAIL: ld-x86-64/pr22115-1c-x32
FAIL: ld-x86-64/pr22135
FAIL: ld-x86-64/ilp32-4
FAIL: PR ld/13082-1 (b)
FAIL: PR ld/13082-2 (b)
FAIL: PR ld/13082-3 (b)
FAIL: PR ld/13082-3 (d)
FAIL: PR ld/13082-4 (b)
FAIL: PR ld/13082-5 (b)
FAIL: PR ld/13082-6 (b)
FAIL: ld-x86-64/lea1b
FAIL: ld-x86-64/lea1e
FAIL: ld-x86-64/lea1h
FAIL: ld-x86-64/lea1k
FAIL: ld-x86-64/mov2b
FAIL: ld-x86-64/mov2d
FAIL: ld-x86-64/load1a
FAIL: ld-x86-64/load1b
FAIL: ld-x86-64/load1c
FAIL: ld-x86-64/load1d
FAIL: PR ld/18176
FAIL: ld-x86-64/pr19162
FAIL: ld-x86-64/pr19615
FAIL: ld-x86-64/pr19636-1a
FAIL: ld-x86-64/pr19636-1b
FAIL: ld-x86-64/pr19636-1c
FAIL: ld-x86-64/pr19636-1h
FAIL: ld-x86-64/pr19636-1i
FAIL: ld-x86-64/pr19636-2d
FAIL: ld-x86-64/pr19636-2l
FAIL: ld-x86-64/pr19636-3a
FAIL: ld-x86-64/pr19636-3b
FAIL: ld-x86-64/pr19609-1m
FAIL: ld-x86-64/pr19609-5b
FAIL: ld-x86-64/pr20253-1b
FAIL: ld-x86-64/pr20253-1c
FAIL: ld-x86-64/pr20253-1d
FAIL: ld-x86-64/pr20253-1f
FAIL: ld-x86-64/pr20253-1h
FAIL: ld-x86-64/pr20253-1i
FAIL: ld-x86-64/pr20253-1j
FAIL: ld-x86-64/pr20253-1l
FAIL: ld-x86-64/pr20253-4b
FAIL: ld-x86-64/pr20253-4e
FAIL: Build plt-main with PIE
FAIL: Build copyreloc-main with PIE without -fPIE (1)
FAIL: Build copyreloc-main with PIE without -fPIE (2)
FAIL: Build pr17689 with PIE without -fPIE
FAIL: Build pr17689 with PIE -z now without -fPIE
FAIL: Build pr17827 with PIE without -fPIE
FAIL: Build pr19319
FAIL: Build pr22393-3 (PIE)
FAIL: Build pr22791-1
FAIL: Build pr22791-2
FAIL: Build pr22842
FAIL: Run plt-main with PIE
FAIL: Run copyreloc-main with PIE without -fPIE
FAIL: Run pr17689 with PIE without -fPIE
FAIL: Run pr17689 with PIE -z now without -fPIE
FAIL: Run property 1 (PIE)
FAIL: Run property 1 (static)
FAIL: Run property 2 (PIE)
FAIL: Run property 2 (static)
FAIL: Run property 3 (PIE)
FAIL: Run property 3 (static)
FAIL: Run property 4 (PIE)
FAIL: Run property 4 (static)
FAIL: Run property 5 (PIE)
FAIL: Run property 5 (static)
FAIL: Run pr22001-1a (PIC 2)
FAIL: Run pr22001-1b (PIC 2)
FAIL: Run pr21997-1a (PIC 2)
FAIL: Run pr21997-1b (PIC 2)
FAIL: Run pr22064
FAIL: Run pr22393-3 (PIE)
FAIL: Run pr22393-3 (static)
FAIL: Run pr22791-2
FAIL: Build pr22842
FAIL: Build plt-main with -z bndplt
FAIL: Build plt-main with PIE and -z bndplt
FAIL: Build plt-main with -z bndplt -z now
FAIL: Build plt-main with PIE and -z bndplt -z now
FAIL: Run plt-main with PIE and -z bndplt
FAIL: Run plt-main with PIE and -z bndplt -z now
FAIL: Run pr20800
FAIL: Build plt-main with -z ibtplt
FAIL: Build plt-main with PIE and -z ibtplt
FAIL: Build plt-main with -z ibtplt -z now
FAIL: Build plt-main with PIE and -z ibtplt -z now
FAIL: Build libibtplt-lib.so with -z ibtplt
FAIL: Build libibtplt--now-lib.so with -z ibtplt -z now
FAIL: Run plt-main with PIE and -z ibtplt
FAIL: Run plt-main with PIE and -z ibtplt -z now
FAIL: Run pr19704
FAIL: Run pr19704
FAIL: basic PLT generation (-z now)
FAIL: PR ld/20830 (.plt.got)
FAIL: PR ld/20830 (.plt.got)
FAIL: PR ld/21038 (.plt.got)
FAIL: PR ld/21038 (.plt.sec)
FAIL: PR ld/21038 (.plt.got and .plt.sec)
FAIL: PR ld/20830 (.plt.got, -z now)
FAIL: PR ld/20830 (.plt.got, -z now)
FAIL: PR ld/21038 (.plt.got, -z now)
FAIL: PR ld/21038 (.plt.sec, -z now)
FAIL: PR ld/21038 (.plt.got and .plt.sec, -z now)
FAIL: ld-x86-64/ibt-plt-1
FAIL: ld-x86-64/ibt-plt-1-x32
FAIL: ld-x86-64/ibt-plt-2a
FAIL: ld-x86-64/ibt-plt-2b
FAIL: ld-x86-64/ibt-plt-2c
FAIL: ld-x86-64/ibt-plt-2d
FAIL: ld-x86-64/ibt-plt-2a-x32
FAIL: ld-x86-64/ibt-plt-2b-x32
FAIL: ld-x86-64/ibt-plt-2c-x32
FAIL: ld-x86-64/ibt-plt-2d-x32
FAIL: ld-x86-64/ibt-plt-3a
FAIL: ld-x86-64/ibt-plt-3b
FAIL: ld-x86-64/ibt-plt-3c
FAIL: ld-x86-64/ibt-plt-3d
FAIL: ld-x86-64/ibt-plt-3a-x32
FAIL: ld-x86-64/ibt-plt-3b-x32
FAIL: ld-x86-64/ibt-plt-3c-x32
FAIL: ld-x86-64/ibt-plt-3d-x32
Comment 4 H.J. Lu 2018-02-16 03:58:55 UTC
FAIL: ld-elf/eh4

[hjl@gnu-tools-1 ld]$ /export/build/gnu/binutils/build-x86_64-linux/ld/../gas/as-new  --defsym ALIGN=3 --64  -o tmpdir/eh4.o /export/gnu/import/git/sources/binutils-gdb/ld/testsuite/ld-elf/eh4.s
[hjl@gnu-tools-1 ld]$ /export/build/gnu/binutils/build-x86_64-linux/ld/../gas/as-new  --defsym ALIGN=3 --64  -o tmpdir/eh4a.o /export/gnu/import/git/sources/binutils-gdb/ld/testsuite/ld-elf/eh4a.s
[hjl@gnu-tools-1 ld]$ ld -z separate-code  -z norelro  -L/export/gnu/import/git/sources/binutils-gdb/ld/testsuite/ld-elf  -melf_x86_64 -shared -Ttext 0x400 -o tmpdir/dump tmpdir/eh4.o tmpdir/eh4a.o 
ld: section .eh_frame LMA [0000000000200000,0000000000200073] overlaps section .plt LMA [0000000000200000,000000000020001f]
[hjl@gnu-tools-1 ld]$ 

-Ttext 0x400 doesn't work with -z separate-code.
Comment 5 Sourceware Commits 2018-02-16 23:46:58 UTC
The master branch has been updated by Alan Modra <amodra@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=325ba6fb34be799c885fad9287d883e86b835c84

commit 325ba6fb34be799c885fad9287d883e86b835c84
Author: Alan Modra <amodra@gmail.com>
Date:   Sat Feb 17 09:21:17 2018 +1030

    Ignore degenerate PT_LOAD segments
    
    Fixes a failure triggered by -z separate-code.  p_memsz is tested
    rather than p_filesz for objcopy --only-keep-debug where p_filesz is
    set to zero.
    
    	PR 22845
    	* elf.c (assign_file_positions_for_non_load_sections): Ignore
    	degenerate zero size PT_LOAD segments when finding one overlapping
    	the PT_GNU_RELRO segment.
Comment 6 Sourceware Commits 2018-02-17 13:32:14 UTC
The master branch has been updated by H.J. Lu <hjl@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=92d9e363b5ab7f96a2c8e6d3ae86cf8cc91dca9d

commit 92d9e363b5ab7f96a2c8e6d3ae86cf8cc91dca9d
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Sat Feb 17 05:30:13 2018 -0800

    ld-elf/eh4: Pass -z max-page-size=0x200000 -z noseparate-code to ld
    
    -z separate-code creates separate code LOAD segment, aligns it to the
    maximum page size and places .plt section before .text section.  But
    ld-elf/eh4 passes -Ttext 0x400 to linker to place .text section at
    address 0x400, which is impossible for linker to accomplish:
    
    $ ld -shared -Ttext 0x400 -z separate-code -o x.so eh4.o
    ld: section .eh_frame LMA [0000000000200000,000000000020006b] overlaps section .plt LMA [0000000000200000,000000000020001f]
    
    Since ld-elf/eh4 also checks exact addresses, this patch passes
    -z max-page-size=0x200000 -z noseparate-code to ld.
    
    	PR ld/22845
    	* ld-elf/eh4.d: Pass -z max-page-size=0x200000 -z noseparate-code
    	to ld.
Comment 7 Sourceware Commits 2018-02-17 13:44:32 UTC
The master branch has been updated by H.J. Lu <hjl@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=34b00afa0396871f762190b8c436d2a5bf91c9e1

commit 34b00afa0396871f762190b8c436d2a5bf91c9e1
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Sat Feb 17 05:37:37 2018 -0800

    ld: Add -z separate-code test for zero size section
    
    	PR ld/22845
    	* testsuite/ld-elf/binutils.exp (tls_opts): Add tests for
    	"-z noseparate-code" and "-z separate-code".
Comment 8 Sourceware Commits 2018-02-17 23:00:59 UTC
The master branch has been updated by H.J. Lu <hjl@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=d85502cffa5e41db6f2f2e1ba11d4285918dccdb

commit d85502cffa5e41db6f2f2e1ba11d4285918dccdb
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Sat Feb 17 14:54:16 2018 -0800

    ld-elf/ehdr_start: Pass --build-id to ld
    
    ld-elf/ehdr_start fails with -z separate-code.  Since there is no data
    LOAD segment before code LOAD segment:
    
    There are 2 program headers, starting at offset 64
    
    Program Headers:
      Type           Offset   VirtAddr           PhysAddr           FileSiz  MemSiz   Flg Align
      LOAD           0x200000 0x0000000000600000 0x0000000000600000 0x000010 0x000010 R E 0x200000
      LOAD           0x400000 0x0000000000800000 0x0000000000800000 0x000008 0x000008 R   0x200000
    
     Section to Segment mapping:
      Segment Sections...
       00     .text
       01     .rodata
    
    the program header isn't included in any LOAD segment.  As the result,
    reference to __ehdr_start is resolved to zero.  Pass --build-id to ld
    to add a data LOAD segment before code LOAD segment to put the program
    header in the  data LOAD segment.
    
    	PR ld/22845
    	* testsuite/ld-elf/ehdr_start.d: Pass --build-id to ld.
Comment 9 Sourceware Commits 2018-02-19 03:23:19 UTC
The master branch has been updated by Alan Modra <amodra@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=dbc88fc14992c556b94e77de563a8f7abcb0b653

commit dbc88fc14992c556b94e77de563a8f7abcb0b653
Author: Alan Modra <amodra@gmail.com>
Date:   Mon Feb 19 09:52:53 2018 +1030

    PT_LOAD and PT_GNU_RELRO segment overlap
    
    Commit 325ba6fb34 excluded degenerate zero length PT_LOAD segments,
    but that only fixed part of the problem, which was that the load
    segment limits were not calculated properly.
    
    	PR 22845
    	* elf.c (IS_TBSS): Define.
    	(_bfd_elf_map_sections_to_segments): Use IS_TBSS.
    	(assign_file_positions_for_non_load_sections): Revert last change.
    	Properly calculate load segment limits to compare against relro limits.
Comment 10 Sourceware Commits 2018-02-19 13:08:54 UTC
The master branch has been updated by H.J. Lu <hjl@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=f61f94ec1bf9cb3d32b38a90a1f5c2d58ececbfb

commit f61f94ec1bf9cb3d32b38a90a1f5c2d58ececbfb
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Mon Feb 19 05:07:33 2018 -0800

    ld: Add -z separate-code tests to frame.exp
    
    On x86, "-z separate-code" leads to assertion fail at bfd/elf.c:5917.
    Alsp skip tests if -shared isn't supported.
    
    	PR ld/22845
    	* testsuite/ld-elf/frame.exp: Skip if -shared isn't supported.
    	Add tests for "-z noseparate-code" and "-z separate-code".
    	Remove unsupported -shared check.
Comment 11 H.J. Lu 2018-02-19 13:13:46 UTC
Fixed.