[lld] r282814 - Don't depend on lld creating space for the headers.

Rafael Espindola via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 29 17:06:25 PDT 2016


Author: rafael
Date: Thu Sep 29 19:06:24 2016
New Revision: 282814

URL: http://llvm.org/viewvc/llvm-project?rev=282814&view=rev
Log:
Don't depend on lld creating space for the headers.

Currently lld will implicitly reserve space for the headers. This is
not the case is bfd, where it is the script responsibility to use
SIZEOF_HEADERS. This means that a script not using SIZEOF_HEADERS and
expecting the address of the first section to be 0 would fail with lld.

I am fixing that is the next commit. This one just makes the tests
explicitly use SIZEOF_HEADERS to avoid the dependency on the current
behaviour.

Modified:
    lld/trunk/test/ELF/arm-thumb-interwork-thunk.s
    lld/trunk/test/ELF/arm-thumb-narrow-branch-check.s
    lld/trunk/test/ELF/linkerscript/align-empty.s
    lld/trunk/test/ELF/linkerscript/common.s
    lld/trunk/test/ELF/linkerscript/data-segment-relro.s
    lld/trunk/test/ELF/linkerscript/discard-interp.s
    lld/trunk/test/ELF/linkerscript/double-bss.s
    lld/trunk/test/ELF/linkerscript/extend-pt-load.s
    lld/trunk/test/ELF/linkerscript/merge-sections.s
    lld/trunk/test/ELF/linkerscript/orphan-align.s
    lld/trunk/test/ELF/linkerscript/repsection-symbol.s
    lld/trunk/test/ELF/linkerscript/sections-keep.s
    lld/trunk/test/ELF/linkerscript/sort2.s
    lld/trunk/test/ELF/linkerscript/symbol-conflict.s
    lld/trunk/test/ELF/linkerscript/symbol-only.s
    lld/trunk/test/ELF/linkerscript/symbols-synthetic.s
    lld/trunk/test/ELF/linkerscript/tbss.s
    lld/trunk/test/ELF/phdr-align.s

Modified: lld/trunk/test/ELF/arm-thumb-interwork-thunk.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/arm-thumb-interwork-thunk.s?rev=282814&r1=282813&r2=282814&view=diff
==============================================================================
--- lld/trunk/test/ELF/arm-thumb-interwork-thunk.s (original)
+++ lld/trunk/test/ELF/arm-thumb-interwork-thunk.s Thu Sep 29 19:06:24 2016
@@ -1,5 +1,6 @@
 // RUN: llvm-mc -filetype=obj -triple=armv7a-none-linux-gnueabi %s -o %t
 // RUN: echo "SECTIONS { \
+// RUN:       . = SIZEOF_HEADERS; \
 // RUN:       .R_ARM_JUMP24_callee_1 : { *(.R_ARM_JUMP24_callee_low) } \
 // RUN:       .R_ARM_THM_JUMP_callee_1 : { *(.R_ARM_THM_JUMP_callee_low)} \
 // RUN:       .text : { *(.text) } \

Modified: lld/trunk/test/ELF/arm-thumb-narrow-branch-check.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/arm-thumb-narrow-branch-check.s?rev=282814&r1=282813&r2=282814&view=diff
==============================================================================
--- lld/trunk/test/ELF/arm-thumb-narrow-branch-check.s (original)
+++ lld/trunk/test/ELF/arm-thumb-narrow-branch-check.s Thu Sep 29 19:06:24 2016
@@ -1,5 +1,6 @@
 // RUN: llvm-mc -filetype=obj -triple=thumbv7a-none-linux-gnueabi %s -o %t
 // RUN: echo "SECTIONS { \
+// RUN:          . = SIZEOF_HEADERS; \
 // RUN:          .R_ARM_PC11_1 : { *(.R_ARM_PC11_1) } \
 // RUN:          .caller : { *(.caller) } \
 // RUN:          .R_ARM_PC11_2 : { *(.R_ARM_PC11_2) } \

Modified: lld/trunk/test/ELF/linkerscript/align-empty.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/linkerscript/align-empty.s?rev=282814&r1=282813&r2=282814&view=diff
==============================================================================
--- lld/trunk/test/ELF/linkerscript/align-empty.s (original)
+++ lld/trunk/test/ELF/linkerscript/align-empty.s Thu Sep 29 19:06:24 2016
@@ -2,6 +2,7 @@
 # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
 
 # RUN: echo "SECTIONS { \
+# RUN:  . = SIZEOF_HEADERS; \
 # RUN:  abc : { } \
 # RUN:  . = ALIGN(0x1000); \
 # RUN:  foo : { *(foo) } \

Modified: lld/trunk/test/ELF/linkerscript/common.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/linkerscript/common.s?rev=282814&r1=282813&r2=282814&view=diff
==============================================================================
--- lld/trunk/test/ELF/linkerscript/common.s (original)
+++ lld/trunk/test/ELF/linkerscript/common.s Thu Sep 29 19:06:24 2016
@@ -1,6 +1,6 @@
 # REQUIRES: x86
 # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
-# RUN: echo "SECTIONS { .common : { *(COMMON) } }" > %t.script
+# RUN: echo "SECTIONS { . = SIZEOF_HEADERS; .common : { *(COMMON) } }" > %t.script
 # RUN: ld.lld -o %t1 --script %t.script %t
 # RUN: llvm-readobj -s -t %t1 | FileCheck %s
 

Modified: lld/trunk/test/ELF/linkerscript/data-segment-relro.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/linkerscript/data-segment-relro.s?rev=282814&r1=282813&r2=282814&view=diff
==============================================================================
--- lld/trunk/test/ELF/linkerscript/data-segment-relro.s (original)
+++ lld/trunk/test/ELF/linkerscript/data-segment-relro.s Thu Sep 29 19:06:24 2016
@@ -4,6 +4,7 @@
 # RUN: ld.lld -shared %t2.o -o %t2.so
 
 # RUN: echo "SECTIONS { \
+# RUN:  . = SIZEOF_HEADERS; \
 # RUN:  .plt  : { *(.plt) } \
 # RUN:  .text : { *(.text) } \
 # RUN:  . = DATA_SEGMENT_ALIGN (CONSTANT (MAXPAGESIZE), CONSTANT (COMMONPAGESIZE)); \

Modified: lld/trunk/test/ELF/linkerscript/discard-interp.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/linkerscript/discard-interp.s?rev=282814&r1=282813&r2=282814&view=diff
==============================================================================
--- lld/trunk/test/ELF/linkerscript/discard-interp.s (original)
+++ lld/trunk/test/ELF/linkerscript/discard-interp.s Thu Sep 29 19:06:24 2016
@@ -2,7 +2,7 @@
 // RUN: llvm-mc -filetype=obj -triple=i686-unknown-linux %p/../Inputs/shared.s -o %t2.o
 // RUN: ld.lld -shared %t2.o -o %t2.so
 // RUN: echo "PHDRS { text PT_LOAD FILEHDR PHDRS; } \
-// RUN:       SECTIONS { .text : { *(.text) } : text }" > %t.script
+// RUN:       SECTIONS { . = SIZEOF_HEADERS; .text : { *(.text) } : text }" > %t.script
 // RUN: ld.lld -dynamic-linker /lib64/ld-linux-x86-64.so.2 -rpath foo -rpath bar --script %t.script --export-dynamic %t.o %t2.so -o %t
 // RUN: llvm-readobj -s %t | FileCheck %s
 

Modified: lld/trunk/test/ELF/linkerscript/double-bss.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/linkerscript/double-bss.s?rev=282814&r1=282813&r2=282814&view=diff
==============================================================================
--- lld/trunk/test/ELF/linkerscript/double-bss.s (original)
+++ lld/trunk/test/ELF/linkerscript/double-bss.s Thu Sep 29 19:06:24 2016
@@ -1,6 +1,6 @@
 # REQUIRES: x86
 # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
-# RUN: echo "SECTIONS { .text : { *(.text*) } }" > %t.script
+# RUN: echo "SECTIONS { . = SIZEOF_HEADERS; .text : { *(.text*) } }" > %t.script
 # RUN: ld.lld -o %t1 --script %t.script %t
 # RUN: llvm-objdump -section-headers %t1 | FileCheck %s
 # CHECK:      .bss          00000004 0000000000000122 BSS

Modified: lld/trunk/test/ELF/linkerscript/extend-pt-load.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/linkerscript/extend-pt-load.s?rev=282814&r1=282813&r2=282814&view=diff
==============================================================================
--- lld/trunk/test/ELF/linkerscript/extend-pt-load.s (original)
+++ lld/trunk/test/ELF/linkerscript/extend-pt-load.s Thu Sep 29 19:06:24 2016
@@ -7,6 +7,7 @@
 # First, run a test with no such section.
 
 # RUN: echo "SECTIONS { \
+# RUN:  . = SIZEOF_HEADERS; \
 # RUN:	.dynsym : {  } \
 # RUN:	.hash : {  } \
 # RUN:	.dynstr : {  } \
@@ -27,6 +28,7 @@
 # cover the padding bits created by ALIGN.
 
 # RUN: echo "SECTIONS { \
+# RUN:  . = SIZEOF_HEADERS; \
 # RUN:	.dynsym : {  } \
 # RUN:	.hash : {  } \
 # RUN:	.dynstr : {  } \
@@ -49,6 +51,7 @@
 # of the section. That is, handle the above like the following test.
 
 # RUN: echo "SECTIONS { \
+# RUN:  . = SIZEOF_HEADERS; \
 # RUN:	.dynsym : {  } \
 # RUN:	.hash : {  } \
 # RUN:	.dynstr : {  } \

Modified: lld/trunk/test/ELF/linkerscript/merge-sections.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/linkerscript/merge-sections.s?rev=282814&r1=282813&r2=282814&view=diff
==============================================================================
--- lld/trunk/test/ELF/linkerscript/merge-sections.s (original)
+++ lld/trunk/test/ELF/linkerscript/merge-sections.s Thu Sep 29 19:06:24 2016
@@ -1,7 +1,10 @@
 # REQUIRES: x86
 # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
 
-# RUN: echo "SECTIONS {.foo : { begin = .; *(.foo.*) end = .;} }" > %t.script
+# RUN: echo "SECTIONS { \
+# RUN:   . = SIZEOF_HEADERS; \
+# RUN:   .foo : { begin = .; *(.foo.*) end = .;} \
+# RUN: }" > %t.script
 # RUN: ld.lld -o %t1 --script %t.script %t -shared
 # RUN: llvm-readobj -s -t %t1 | FileCheck %s
 

Modified: lld/trunk/test/ELF/linkerscript/orphan-align.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/linkerscript/orphan-align.s?rev=282814&r1=282813&r2=282814&view=diff
==============================================================================
--- lld/trunk/test/ELF/linkerscript/orphan-align.s (original)
+++ lld/trunk/test/ELF/linkerscript/orphan-align.s Thu Sep 29 19:06:24 2016
@@ -1,6 +1,7 @@
 # REQUIRES: x86
 # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o
 # RUN: echo "SECTIONS { \
+# RUN:         . = SIZEOF_HEADERS; \
 # RUN:         .text : { *(.text) } \
 # RUN:         . = ALIGN(0x1000); \
 # RUN:         .data.rel.ro : { *(.data.rel.ro) } \

Modified: lld/trunk/test/ELF/linkerscript/repsection-symbol.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/linkerscript/repsection-symbol.s?rev=282814&r1=282813&r2=282814&view=diff
==============================================================================
--- lld/trunk/test/ELF/linkerscript/repsection-symbol.s (original)
+++ lld/trunk/test/ELF/linkerscript/repsection-symbol.s Thu Sep 29 19:06:24 2016
@@ -2,6 +2,8 @@
 # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
 
 # RUN: echo "SECTIONS { \
+# RUN:   . = SIZEOF_HEADERS; \
+# RUN:   .text : { *(.text) } \
 # RUN:   .foo : {foo1 = .;  *(.foo.*) foo2 = .;  *(.bar) foo3 = .;} \
 # RUN: }" > %t.script
 # RUN: ld.lld -o %t1 --script %t.script %t -shared

Modified: lld/trunk/test/ELF/linkerscript/sections-keep.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/linkerscript/sections-keep.s?rev=282814&r1=282813&r2=282814&view=diff
==============================================================================
--- lld/trunk/test/ELF/linkerscript/sections-keep.s (original)
+++ lld/trunk/test/ELF/linkerscript/sections-keep.s Thu Sep 29 19:06:24 2016
@@ -34,6 +34,7 @@
 ## first one doesn't have KEEP, the second one does. If section that have
 ## KEEP is the first in order then section is NOT collected.
 # RUN: echo "SECTIONS { \
+# RUN:  . = SIZEOF_HEADERS; \
 # RUN:  .keep : { KEEP(*(.keep)) } \
 # RUN:  .nokeep : { *(.keep) }}" > %t.script
 # RUN: ld.lld --gc-sections -o %t1 --script %t.script %t
@@ -53,6 +54,7 @@
 ## bfd keeps it. Our current behavior is compatible with bfd although
 ## we can choose either way.
 # RUN: echo "SECTIONS { \
+# RUN:  . = SIZEOF_HEADERS; \
 # RUN:  .nokeep : { *(.keep) } \
 # RUN:  .keep : { KEEP(*(.keep)) }}" > %t.script
 # RUN: ld.lld --gc-sections -o %t1 --script %t.script %t

Modified: lld/trunk/test/ELF/linkerscript/sort2.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/linkerscript/sort2.s?rev=282814&r1=282813&r2=282814&view=diff
==============================================================================
--- lld/trunk/test/ELF/linkerscript/sort2.s (original)
+++ lld/trunk/test/ELF/linkerscript/sort2.s Thu Sep 29 19:06:24 2016
@@ -6,9 +6,9 @@
 # RUN: llvm-objdump -s %t1 | FileCheck %s
 
 # CHECK:  Contents of section .abc:
-# CHECK:   00e8 01000000 00000000 02000000 00000000
-# CHECK:   00f8 03000000 00000000 04000000 00000000
-# CHECK:   0108 06000000 00000000 05000000 00000000
+# CHECK:   01000000 00000000 02000000 00000000
+# CHECK:   03000000 00000000 04000000 00000000
+# CHECK:   06000000 00000000 05000000 00000000
 
 # RUN: echo "SECTIONS { \
 # RUN:   .abc : { *(SORT(.foo.* EXCLUDE_FILE (*file1.o) .bar.*) .bar.*) } \

Modified: lld/trunk/test/ELF/linkerscript/symbol-conflict.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/linkerscript/symbol-conflict.s?rev=282814&r1=282813&r2=282814&view=diff
==============================================================================
--- lld/trunk/test/ELF/linkerscript/symbol-conflict.s (original)
+++ lld/trunk/test/ELF/linkerscript/symbol-conflict.s Thu Sep 29 19:06:24 2016
@@ -1,7 +1,7 @@
 # REQUIRES: x86
 # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
 
-# RUN: echo "SECTIONS {.text : {*(.text.*)} end = .;}" > %t.script
+# RUN: echo "SECTIONS { . = SIZEOF_HEADERS; .text : {*(.text.*)} end = .;}" > %t.script
 # RUN: ld.lld -o %t1 --script %t.script %t
 # RUN: llvm-objdump -t %t1 | FileCheck %s
 # CHECK: 00000000000000e9         *ABS*    00000000 end

Modified: lld/trunk/test/ELF/linkerscript/symbol-only.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/linkerscript/symbol-only.s?rev=282814&r1=282813&r2=282814&view=diff
==============================================================================
--- lld/trunk/test/ELF/linkerscript/symbol-only.s (original)
+++ lld/trunk/test/ELF/linkerscript/symbol-only.s Thu Sep 29 19:06:24 2016
@@ -2,6 +2,7 @@
 # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
 
 # RUN: echo "SECTIONS { \
+# RUN:  . = SIZEOF_HEADERS; \
 # RUN:  abc : { foo = .; } \
 # RUN:  . = ALIGN(0x1000); \
 # RUN:  bar : { *(bar) } \

Modified: lld/trunk/test/ELF/linkerscript/symbols-synthetic.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/linkerscript/symbols-synthetic.s?rev=282814&r1=282813&r2=282814&view=diff
==============================================================================
--- lld/trunk/test/ELF/linkerscript/symbols-synthetic.s (original)
+++ lld/trunk/test/ELF/linkerscript/symbols-synthetic.s Thu Sep 29 19:06:24 2016
@@ -4,6 +4,7 @@
 # is not location counter but offset from the beginning of output
 # section .foo
 # RUN: echo "SECTIONS { \
+# RUN:          . = SIZEOF_HEADERS; \
 # RUN:          .foo : { \
 # RUN:              begin_foo = .; \
 # RUN:              PROVIDE(_begin_sec = .); \

Modified: lld/trunk/test/ELF/linkerscript/tbss.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/linkerscript/tbss.s?rev=282814&r1=282813&r2=282814&view=diff
==============================================================================
--- lld/trunk/test/ELF/linkerscript/tbss.s (original)
+++ lld/trunk/test/ELF/linkerscript/tbss.s Thu Sep 29 19:06:24 2016
@@ -1,6 +1,11 @@
 # REQUIRES: x86
 # RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
-# RUN: echo "SECTIONS { foo : { *(foo) } bar : { *(bar) } }" > %t.script
+# RUN: echo "SECTIONS { \
+# RUN:   . = SIZEOF_HEADERS; \
+# RUN:   .text : { *(.text) } \
+# RUN:   foo : { *(foo) } \
+# RUN:   bar : { *(bar) } \
+# RUN: }" > %t.script
 # RUN: ld.lld -T %t.script %t.o -o %t
 # RUN: llvm-readobj -s %t | FileCheck %s
 

Modified: lld/trunk/test/ELF/phdr-align.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/phdr-align.s?rev=282814&r1=282813&r2=282814&view=diff
==============================================================================
--- lld/trunk/test/ELF/phdr-align.s (original)
+++ lld/trunk/test/ELF/phdr-align.s Thu Sep 29 19:06:24 2016
@@ -2,6 +2,7 @@
 # RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
 
 # RUN: echo "SECTIONS { \
+# RUN:  . = SIZEOF_HEADERS; \
 # RUN:  .bss : { *(.bss) } \
 # RUN:  .data : { *(.data) } \
 # RUN:  .text : { *(.text) } }" > %t.script




More information about the llvm-commits mailing list