[Bug ld/22845] -z separate-code doesn't work right

2018-03-31 Thread jeremip11 at gmail dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=22845

Jeremi  changed:

   What|Removed |Added

 CC||jeremip11 at gmail dot com

-- 
You are receiving this mail because:
You are on the CC list for the bug.
___
bug-binutils mailing list
bug-binutils@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-binutils


[Bug ld/22845] -z separate-code doesn't work right

2018-02-19 Thread hjl.tools at gmail dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=22845

H.J. Lu  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution|--- |FIXED
   Target Milestone|--- |2.31

--- Comment #11 from H.J. Lu  ---
Fixed.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
___
bug-binutils mailing list
bug-binutils@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-binutils


[Bug ld/22845] -z separate-code doesn't work right

2018-02-19 Thread cvs-commit at gcc dot gnu.org
https://sourceware.org/bugzilla/show_bug.cgi?id=22845

--- Comment #10 from cvs-commit at gcc dot gnu.org  ---
The master branch has been updated by H.J. Lu :

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

commit f61f94ec1bf9cb3d32b38a90a1f5c2d58ececbfb
Author: H.J. Lu 
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.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
___
bug-binutils mailing list
bug-binutils@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-binutils


[Bug ld/22845] -z separate-code doesn't work right

2018-02-18 Thread cvs-commit at gcc dot gnu.org
https://sourceware.org/bugzilla/show_bug.cgi?id=22845

--- Comment #9 from cvs-commit at gcc dot gnu.org  ---
The master branch has been updated by Alan Modra :

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

commit dbc88fc14992c556b94e77de563a8f7abcb0b653
Author: Alan Modra 
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.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
___
bug-binutils mailing list
bug-binutils@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-binutils


[Bug ld/22845] -z separate-code doesn't work right

2018-02-17 Thread cvs-commit at gcc dot gnu.org
https://sourceware.org/bugzilla/show_bug.cgi?id=22845

--- Comment #8 from cvs-commit at gcc dot gnu.org  ---
The master branch has been updated by H.J. Lu :

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

commit d85502cffa5e41db6f2f2e1ba11d4285918dccdb
Author: H.J. Lu 
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   0x20 0x0060 0x0060 0x10
0x10 R E 0x20
  LOAD   0x40 0x0080 0x0080 0x08
0x08 R   0x20

 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.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
___
bug-binutils mailing list
bug-binutils@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-binutils


[Bug ld/22845] -z separate-code doesn't work right

2018-02-17 Thread cvs-commit at gcc dot gnu.org
https://sourceware.org/bugzilla/show_bug.cgi?id=22845

--- Comment #7 from cvs-commit at gcc dot gnu.org  ---
The master branch has been updated by H.J. Lu :

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

commit 34b00afa0396871f762190b8c436d2a5bf91c9e1
Author: H.J. Lu 
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".

-- 
You are receiving this mail because:
You are on the CC list for the bug.
___
bug-binutils mailing list
bug-binutils@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-binutils


[Bug ld/22845] -z separate-code doesn't work right

2018-02-17 Thread cvs-commit at gcc dot gnu.org
https://sourceware.org/bugzilla/show_bug.cgi?id=22845

--- Comment #6 from cvs-commit at gcc dot gnu.org  ---
The master branch has been updated by H.J. Lu :

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

commit 92d9e363b5ab7f96a2c8e6d3ae86cf8cc91dca9d
Author: H.J. Lu 
Date:   Sat Feb 17 05:30:13 2018 -0800

ld-elf/eh4: Pass -z max-page-size=0x20 -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 [0020,0020006b] overlaps
section .plt LMA [0020,0020001f]

Since ld-elf/eh4 also checks exact addresses, this patch passes
-z max-page-size=0x20 -z noseparate-code to ld.

PR ld/22845
* ld-elf/eh4.d: Pass -z max-page-size=0x20 -z noseparate-code
to ld.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
___
bug-binutils mailing list
bug-binutils@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-binutils


[Bug ld/22845] -z separate-code doesn't work right

2018-02-16 Thread cvs-commit at gcc dot gnu.org
https://sourceware.org/bugzilla/show_bug.cgi?id=22845

--- Comment #5 from cvs-commit at gcc dot gnu.org  ---
The master branch has been updated by Alan Modra :

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

commit 325ba6fb34be799c885fad9287d883e86b835c84
Author: Alan Modra 
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.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
___
bug-binutils mailing list
bug-binutils@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-binutils


[Bug ld/22845] -z separate-code doesn't work right

2018-02-15 Thread hjl.tools at gmail dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=22845

--- Comment #4 from H.J. Lu  ---
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 [0020,00200073] overlaps section
.plt LMA [0020,0020001f]
[hjl@gnu-tools-1 ld]$ 

-Ttext 0x400 doesn't work with -z separate-code.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
___
bug-binutils mailing list
bug-binutils@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-binutils


[Bug ld/22845] -z separate-code doesn't work right

2018-02-14 Thread hjl.tools at gmail dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=22845

--- Comment #3 from H.J. Lu  ---
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 

[Bug ld/22845] -z separate-code doesn't work right

2018-02-14 Thread hjl.tools at gmail dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=22845

--- Comment #2 from H.J. Lu  ---
Wrong linker script is used.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
___
bug-binutils mailing list
bug-binutils@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-binutils


[Bug ld/22845] -z separate-code doesn't work right

2018-02-14 Thread hjl.tools at gmail dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=22845

--- Comment #1 from H.J. Lu  ---
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
  TLS0x082b80 0x080cbb80 0x080cbb80 0x00010 0x00030 R   0x4
  GNU_STACK  0x00 0x 0x 0x0 0x0 RW  0x10
  GNU_RELRO  0x082b80 0x080cbb80 0x080cbb80 0x00480 0x00480 R   0x1

-- 
You are receiving this mail because:
You are on the CC list for the bug.
___
bug-binutils mailing list
bug-binutils@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-binutils