[lld] r327410 - [ELF] - Represent tests as linker scripts instead of asm.

George Rimar via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 13 08:47:14 PDT 2018


Author: grimar
Date: Tue Mar 13 08:47:14 2018
New Revision: 327410

URL: http://llvm.org/viewvc/llvm-project?rev=327410&view=rev
Log:
[ELF] - Represent tests as linker scripts instead of asm.

This follows recently started direction and sometimes
allows to fully get rid from `echo` calls.

I'll rename changed files to *.test in a follow-up.

Modified:
    lld/trunk/test/ELF/linkerscript/bss-fill.s
    lld/trunk/test/ELF/linkerscript/common-filespec.s
    lld/trunk/test/ELF/linkerscript/constructor.s
    lld/trunk/test/ELF/linkerscript/double-bss.s
    lld/trunk/test/ELF/linkerscript/empty-tls.s
    lld/trunk/test/ELF/linkerscript/exidx-crash.s
    lld/trunk/test/ELF/linkerscript/expr-invalid-sec.s
    lld/trunk/test/ELF/linkerscript/header-addr.s
    lld/trunk/test/ELF/linkerscript/header-phdr.s
    lld/trunk/test/ELF/linkerscript/implicit-program-header.s
    lld/trunk/test/ELF/linkerscript/lazy-symbols.s
    lld/trunk/test/ELF/linkerscript/locationcountererr.s
    lld/trunk/test/ELF/linkerscript/memory-at.s
    lld/trunk/test/ELF/linkerscript/no-pt-load.s
    lld/trunk/test/ELF/linkerscript/non-absolute2.s
    lld/trunk/test/ELF/linkerscript/openbsd-bootdata.s
    lld/trunk/test/ELF/linkerscript/openbsd-wxneeded.s
    lld/trunk/test/ELF/linkerscript/orphan-first-cmd.s
    lld/trunk/test/ELF/linkerscript/outputarch.s
    lld/trunk/test/ELF/linkerscript/page-size-align.s
    lld/trunk/test/ELF/linkerscript/parse-section-in-addr.s
    lld/trunk/test/ELF/linkerscript/rosegment.s
    lld/trunk/test/ELF/linkerscript/sort-constructors.s
    lld/trunk/test/ELF/linkerscript/start-end.s
    lld/trunk/test/ELF/linkerscript/symbol-only-flags.s
    lld/trunk/test/ELF/linkerscript/symbol-only.s
    lld/trunk/test/ELF/linkerscript/symbols-non-alloc.s
    lld/trunk/test/ELF/linkerscript/unused-synthetic2.s

Modified: lld/trunk/test/ELF/linkerscript/bss-fill.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/linkerscript/bss-fill.s?rev=327410&r1=327409&r2=327410&view=diff
==============================================================================
--- lld/trunk/test/ELF/linkerscript/bss-fill.s (original)
+++ lld/trunk/test/ELF/linkerscript/bss-fill.s Tue Mar 13 08:47:14 2018
@@ -1,7 +1,13 @@
 # REQUIRES: x86
-# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o
-# RUN: echo "SECTIONS { .bss : { . += 0x10000; *(.bss) } =0xFF };" > %t.script
-# RUN: ld.lld -o %t --script %t.script %t.o
+# RUN: echo '.section .bss,"", at nobits; .short 0' \
+# RUN:   | llvm-mc -filetype=obj -triple=x86_64-unknown-linux - -o %t.o
+# RUN: ld.lld -o %t --script %s %t.o
 
-.section .bss,"", at nobits
-.short 0
+## Check we do not crash.
+
+SECTIONS {
+ .bss : {
+   . += 0x10000;
+   *(.bss)
+ } =0xFF
+}

Modified: lld/trunk/test/ELF/linkerscript/common-filespec.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/linkerscript/common-filespec.s?rev=327410&r1=327409&r2=327410&view=diff
==============================================================================
--- lld/trunk/test/ELF/linkerscript/common-filespec.s (original)
+++ lld/trunk/test/ELF/linkerscript/common-filespec.s Tue Mar 13 08:47:14 2018
@@ -1,11 +1,17 @@
 # REQUIRES: x86
-# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %tfile0.o
+# RUN: echo '.long 0; .comm common_uniq_0,4,4; .comm common_multiple,8,8' \
+# RUN:   | llvm-mc -filetype=obj -triple=x86_64-unknown-linux - -o %tfile0.o
 # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/common-filespec1.s -o %tfile1.o
 # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/common-filespec2.s -o %tfile2.o
-# RUN: echo "SECTIONS { .common_0 : { *file0.o(COMMON) } .common_1 : { *file1.o(COMMON) } .common_2 : { *file2.o(COMMON) } }" > %t.script
-# RUN: ld.lld -o %t1 --script %t.script %tfile0.o %tfile1.o %tfile2.o
+# RUN: ld.lld -o %t1 --script %s %tfile0.o %tfile1.o %tfile2.o
 # RUN: llvm-readobj -s -t %t1 | FileCheck %s
 
+SECTIONS {
+  .common_0 : { *file0.o(COMMON) }
+  .common_1 : { *file1.o(COMMON) }
+  .common_2 : { *file2.o(COMMON) }
+}
+
 # Make sure all 3 sections are allocated and they have sizes and alignments
 # corresponding to the commons assigned to them
 # CHECK:       Section {
@@ -96,10 +102,3 @@
 # CHECK-NEXT:    Other: 0
 # CHECK-NEXT:    Section: .common_2
 # CHECK-NEXT:  }
-
-.globl _start
-_start:
-  jmp _start
-
-.comm common_uniq_0,4,4
-.comm common_multiple,8,8

Modified: lld/trunk/test/ELF/linkerscript/constructor.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/linkerscript/constructor.s?rev=327410&r1=327409&r2=327410&view=diff
==============================================================================
--- lld/trunk/test/ELF/linkerscript/constructor.s (original)
+++ lld/trunk/test/ELF/linkerscript/constructor.s Tue Mar 13 08:47:14 2018
@@ -1,7 +1,7 @@
 # REQUIRES: x86
-# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o
-# RUN: echo "SECTIONS { foo : { *(.foo) CONSTRUCTORS } }" > %t.script
-# RUN: ld.lld -o %t1 --script %t.script %t.o
+# RUN: echo '.section foo, "a"; .byte 0' \
+# RUN:   | llvm-mc -filetype=obj -triple=x86_64-unknown-linux - -o %t.o
+# RUN: ld.lld -o %t1 --script %s %t.o
 
 # RUN: llvm-objdump -section-headers %t1 | FileCheck %s
 # CHECK:      Sections:
@@ -9,5 +9,9 @@
 # CHECK-NEXT:   0               00000000
 # CHECK-NEXT:   1 foo           00000001
 
-.section foo, "a"
-.byte 0
+SECTIONS {
+  foo : {
+    *(.foo)
+    CONSTRUCTORS
+  }
+}

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=327410&r1=327409&r2=327410&view=diff
==============================================================================
--- lld/trunk/test/ELF/linkerscript/double-bss.s (original)
+++ lld/trunk/test/ELF/linkerscript/double-bss.s Tue Mar 13 08:47:14 2018
@@ -1,21 +1,14 @@
 # REQUIRES: x86
-# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
-# RUN: echo "SECTIONS { . = SIZEOF_HEADERS; " > %t.script
-# RUN: echo ".text : { *(.text*) }" >> %t.script
-# RUN: echo ".bss1 : { *(.bss) }" >> %t.script
-# RUN: echo ".bss2 : { *(COMMON) }" >> %t.script
-# RUN: echo "}" >> %t.script
-
-# RUN: ld.lld -o %t1 --script %t.script %t
+# RUN: echo '.short 0; .bss; .zero 4; .comm q,128,8' \
+# RUN:   | llvm-mc -filetype=obj -triple=x86_64-unknown-linux - -o %t
+# RUN: ld.lld -o %t1 --script %s %t
 # RUN: llvm-objdump -section-headers %t1 | FileCheck %s
 # CHECK:      .bss1          00000004 0000000000000122 BSS
 # CHECK-NEXT: .bss2          00000080 0000000000000128 BSS
 
-.globl _start
-_start:
-  jmp _start
-
-.bss
-.zero 4
-
-.comm q,128,8
+SECTIONS {
+  . = SIZEOF_HEADERS;
+  .text : { *(.text*) }
+  .bss1 : { *(.bss) }
+  .bss2 : { *(COMMON) }
+}

Modified: lld/trunk/test/ELF/linkerscript/empty-tls.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/linkerscript/empty-tls.s?rev=327410&r1=327409&r2=327410&view=diff
==============================================================================
--- lld/trunk/test/ELF/linkerscript/empty-tls.s (original)
+++ lld/trunk/test/ELF/linkerscript/empty-tls.s Tue Mar 13 08:47:14 2018
@@ -1,10 +1,13 @@
 # REQUIRES: x86
-# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
-# RUN: echo  "PHDRS { ph_tls PT_TLS; }" > %t.script
-# RUN: ld.lld -o %t.so -T %t.script %t.o -shared
+# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux /dev/null -o %t.o
+# RUN: ld.lld -o %t.so -T %s %t.o -shared
 # RUN: llvm-readobj -l %t.so | FileCheck %s
 
-# test that we don't crash with an empty PT_TLS
+PHDRS {
+  ph_tls PT_TLS;
+}
+
+# Test that we don't crash with an empty PT_TLS
 
 # CHECK:      Type: PT_TLS
 # CHECK-NEXT: Offset: 0x0

Modified: lld/trunk/test/ELF/linkerscript/exidx-crash.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/linkerscript/exidx-crash.s?rev=327410&r1=327409&r2=327410&view=diff
==============================================================================
--- lld/trunk/test/ELF/linkerscript/exidx-crash.s (original)
+++ lld/trunk/test/ELF/linkerscript/exidx-crash.s Tue Mar 13 08:47:14 2018
@@ -2,6 +2,9 @@
 
 # We used to crash on this.
 
-# RUN: llvm-mc %s -o %t.o -filetype=obj -triple=aarch64-pc-linux
-# RUN: echo "SECTIONS { .ARM.exidx : { *(.foo) } }" > %t.script
-# RUN: ld.lld -T %t.script %t.o -o %t
+# RUN: llvm-mc /dev/null -o %t.o -filetype=obj -triple=aarch64-pc-linux
+# RUN: ld.lld -T %s %t.o -o %t
+
+SECTIONS {
+  .ARM.exidx : { *(.foo) }
+}

Modified: lld/trunk/test/ELF/linkerscript/expr-invalid-sec.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/linkerscript/expr-invalid-sec.s?rev=327410&r1=327409&r2=327410&view=diff
==============================================================================
--- lld/trunk/test/ELF/linkerscript/expr-invalid-sec.s (original)
+++ lld/trunk/test/ELF/linkerscript/expr-invalid-sec.s Tue Mar 13 08:47:14 2018
@@ -1,6 +1,9 @@
 # REQUIRES: x86
-# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o
-# RUN: echo "SECTIONS { foo = ADDR(.text) + ADDR(.text); };" > %t.script
-# RUN: not ld.lld -o %t.so --script %t.script %t.o -shared 2>&1 | FileCheck %s
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux /dev/null -o %t.o
+# RUN: not ld.lld -o %t.so --script %s %t.o -shared 2>&1 | FileCheck %s
 
-# CHECK: error: {{.*}}.script:1: at least one side of the expression must be absolute
+# CHECK: error: {{.*}}.s:8: at least one side of the expression must be absolute
+
+SECTIONS {
+  foo = ADDR(.text) + ADDR(.text);
+};

Modified: lld/trunk/test/ELF/linkerscript/header-addr.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/linkerscript/header-addr.s?rev=327410&r1=327409&r2=327410&view=diff
==============================================================================
--- lld/trunk/test/ELF/linkerscript/header-addr.s (original)
+++ lld/trunk/test/ELF/linkerscript/header-addr.s Tue Mar 13 08:47:14 2018
@@ -1,13 +1,15 @@
 # REQUIRES: x86
-# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
-# RUN: echo "PHDRS {all PT_LOAD PHDRS;} \
-# RUN:       SECTIONS { \
-# RUN:       . = 0x2000 + SIZEOF_HEADERS; \
-# RUN:       .text : {*(.text)} :all \
-# RUN:     }" > %t.script
-# RUN: ld.lld --hash-style=sysv -o %t.so --script %t.script %t.o -shared
+# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux /dev/null -o %t.o
+# RUN: ld.lld --hash-style=sysv -o %t.so --script %s %t.o -shared
 # RUN: llvm-readobj -program-headers %t.so | FileCheck %s
 
+PHDRS { all PT_LOAD PHDRS; }
+
+SECTIONS {
+  . = 0x2000 + SIZEOF_HEADERS;
+  .text : {*(.text)} :all
+}
+
 # CHECK:      ProgramHeaders [
 # CHECK-NEXT:   ProgramHeader {
 # CHECK-NEXT:     Type: PT_LOAD
@@ -25,7 +27,7 @@
 # CHECK-NEXT:   }
 # CHECK-NEXT: ]
 
-# RUN: ld.lld --hash-style=sysv -o %t2.so --script %t.script %t.o -shared -z max-page-size=0x2000
+# RUN: ld.lld --hash-style=sysv -o %t2.so --script %s %t.o -shared -z max-page-size=0x2000
 # RUN: llvm-readobj -program-headers %t2.so \
 # RUN:   | FileCheck --check-prefix=MAXPAGE %s
 

Modified: lld/trunk/test/ELF/linkerscript/header-phdr.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/linkerscript/header-phdr.s?rev=327410&r1=327409&r2=327410&view=diff
==============================================================================
--- lld/trunk/test/ELF/linkerscript/header-phdr.s (original)
+++ lld/trunk/test/ELF/linkerscript/header-phdr.s Tue Mar 13 08:47:14 2018
@@ -1,13 +1,15 @@
 # REQUIRES: x86
-# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
-# RUN: echo "PHDRS { foobar PT_LOAD FILEHDR PHDRS; } \
-# RUN:       SECTIONS {  . = 0x1000;  .abc : { *(.zed) } : foobar }" > %t.script
-# RUN: ld.lld --script %t.script %t.o -o %t
+# RUN: echo '.section .zed, "a"; .zero 4' \
+# RUN:   | llvm-mc -filetype=obj -triple=x86_64-unknown-linux - -o %t.o
+# RUN: ld.lld --script %s %t.o -o %t
 # RUN: llvm-readelf -l -S -W %t | FileCheck %s
 
-.section .zed, "a"
-.zero 4
-
-
 # CHECK: [ 1] .abc              PROGBITS        0000000000001000 001000 000004 00   A  0   0  1
 # CHECK: LOAD           0x000000 0x0000000000000000 0x0000000000000000 0x001004 0x001004 R E 0x1000
+
+PHDRS { foobar PT_LOAD FILEHDR PHDRS; }
+
+SECTIONS {
+  . = 0x1000;
+  .abc : { *(.zed) } : foobar
+}

Modified: lld/trunk/test/ELF/linkerscript/implicit-program-header.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/linkerscript/implicit-program-header.s?rev=327410&r1=327409&r2=327410&view=diff
==============================================================================
--- lld/trunk/test/ELF/linkerscript/implicit-program-header.s (original)
+++ lld/trunk/test/ELF/linkerscript/implicit-program-header.s Tue Mar 13 08:47:14 2018
@@ -1,15 +1,9 @@
 # REQUIRES: x86
-# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
-# RUN: echo "PHDRS {                    \
-# RUN:   ph_write PT_LOAD FLAGS(2);     \
-# RUN:   ph_exec  PT_LOAD FLAGS(1);     \
-# RUN: }                                \
-# RUN: SECTIONS {                       \
-# RUN:  .bar : { *(.bar) } : ph_exec    \
-# RUN:  .foo : { *(.foo) }              \
-# RUN:  .text : { *(.text) } : ph_write \
-# RUN: }" > %t.script
-# RUN: ld.lld --hash-style=sysv -o %t1 --script %t.script  \
+
+# RUN: echo '.section .text,"ax"; .quad 0' > %t.s
+# RUN: echo '.section .foo,"ax"; .quad 0' >> %t.s
+# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %t.s -o %t.o
+# RUN: ld.lld --hash-style=sysv -o %t1 --script %s  \
 # RUN:   %t.o -shared
 # RUN: llvm-readobj -elf-output-style=GNU -l %t1 | FileCheck %s
 
@@ -17,6 +11,13 @@
 # CHECK-NEXT:   00     .text .dynsym .hash .dynstr .dynamic
 # CHECK-NEXT:   01     .bar .foo
 
-.quad 0
-.section .foo,"ax"
-.quad 0
+PHDRS {
+  ph_write PT_LOAD FLAGS(2);
+  ph_exec  PT_LOAD FLAGS(1);
+}
+
+SECTIONS {
+  .bar : { *(.bar) } : ph_exec
+  .foo : { *(.foo) }
+  .text : { *(.text) } : ph_write
+}

Modified: lld/trunk/test/ELF/linkerscript/lazy-symbols.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/linkerscript/lazy-symbols.s?rev=327410&r1=327409&r2=327410&view=diff
==============================================================================
--- lld/trunk/test/ELF/linkerscript/lazy-symbols.s (original)
+++ lld/trunk/test/ELF/linkerscript/lazy-symbols.s Tue Mar 13 08:47:14 2018
@@ -1,11 +1,12 @@
 # REQUIRES: x86
 # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %S/Inputs/lazy-symbols.s -o %t1
 # RUN: llvm-ar rcs %tar %t1
-# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t2
-# RUN: echo "foo = 1;" > %t.script
-# RUN: ld.lld %t2 %tar --script %t.script -o %tout
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux /dev/null -o %t2
+# RUN: ld.lld %t2 %tar --script %s -o %tout
 # RUN: llvm-readobj -symbols %tout | FileCheck %s
 
+foo = 1;
+
 # This test is to ensure a linker script can define a symbol which have the same
 # name as a lazy symbol.
 

Modified: lld/trunk/test/ELF/linkerscript/locationcountererr.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/linkerscript/locationcountererr.s?rev=327410&r1=327409&r2=327410&view=diff
==============================================================================
--- lld/trunk/test/ELF/linkerscript/locationcountererr.s (original)
+++ lld/trunk/test/ELF/linkerscript/locationcountererr.s Tue Mar 13 08:47:14 2018
@@ -1,11 +1,11 @@
 # REQUIRES: x86
-# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux /dev/null -o %t
+# RUN: not ld.lld %t --script %s -o %t1 2>&1 | FileCheck %s
+# CHECK: {{.*}}.s:8: unable to move location counter backward for: .text
 
-# RUN: echo "SECTIONS {" > %t.script
-# RUN: echo ".text 0x2000 : {. = 0x10 ; *(.text) } }" >> %t.script
-# RUN: not ld.lld %t --script %t.script -o %t1 2>&1 | FileCheck %s
-# CHECK: {{.*}}.script:2: unable to move location counter backward for: .text
-
-.globl _start
-_start:
-nop
+SECTIONS {
+  .text 0x2000 : {
+    . = 0x10;
+    *(.text)
+  }
+}

Modified: lld/trunk/test/ELF/linkerscript/memory-at.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/linkerscript/memory-at.s?rev=327410&r1=327409&r2=327410&view=diff
==============================================================================
--- lld/trunk/test/ELF/linkerscript/memory-at.s (original)
+++ lld/trunk/test/ELF/linkerscript/memory-at.s Tue Mar 13 08:47:14 2018
@@ -1,16 +1,21 @@
 # REQUIRES: x86
-# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
-# RUN: echo "MEMORY {                                   \
-# RUN:   FLASH (rx) : ORIGIN = 0x1000, LENGTH = 0x100   \
-# RUN:   RAM (rwx)  : ORIGIN = 0x2000, LENGTH = 0x100 } \
-# RUN: SECTIONS {                                       \
-# RUN:  .text : { *(.text*) } > FLASH                   \
-# RUN:  __etext = .;                                    \
-# RUN:  .data : AT (__etext) { *(.data*) } > RAM        \
-# RUN: }" > %t.script
-# RUN: ld.lld %t --script %t.script -o %t2
+# RUN: echo '.section .text,"ax"; .quad 0' > %t.s
+# RUN: echo '.section .data,"aw"; .quad 0' >> %t.s
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %t.s -o %t
+# RUN: ld.lld %t --script %s -o %t2
 # RUN: llvm-readobj -program-headers %t2 | FileCheck %s
 
+MEMORY {
+  FLASH (rx) : ORIGIN = 0x1000, LENGTH = 0x100
+  RAM (rwx)  : ORIGIN = 0x2000, LENGTH = 0x100
+}
+
+SECTIONS {
+ .text : { *(.text*) } > FLASH
+ __etext = .;
+ .data : AT (__etext) { *(.data*) } > RAM
+}
+
 # CHECK:      ProgramHeaders [
 # CHECK-NEXT:   ProgramHeader {
 # CHECK-NEXT:     Type: PT_LOAD
@@ -38,9 +43,3 @@
 # CHECK-NEXT:     ]
 # CHECK-NEXT:     Alignment:
 # CHECK-NEXT:   }
-
-.section .text, "ax"
-.quad 0
-
-.section .data, "aw"
-.quad 0

Modified: lld/trunk/test/ELF/linkerscript/no-pt-load.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/linkerscript/no-pt-load.s?rev=327410&r1=327409&r2=327410&view=diff
==============================================================================
--- lld/trunk/test/ELF/linkerscript/no-pt-load.s (original)
+++ lld/trunk/test/ELF/linkerscript/no-pt-load.s Tue Mar 13 08:47:14 2018
@@ -1,5 +1,11 @@
 # REQUIRES: x86
-# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
-# RUN: echo "PHDRS {foo PT_DYNAMIC ;} " \
-# RUN:      "SECTIONS { .text : { *(.text) } : foo }" > %t.script
-# RUN: ld.lld -o %t1 --script %t.script %t.o
+# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux /dev/null -o %t.o
+# RUN: ld.lld -o %t1 --script %s %t.o
+
+## Check we do not crash.
+
+PHDRS { foo PT_DYNAMIC; }
+
+SECTIONS {
+  .text : { *(.text) } : foo
+}

Modified: lld/trunk/test/ELF/linkerscript/non-absolute2.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/linkerscript/non-absolute2.s?rev=327410&r1=327409&r2=327410&view=diff
==============================================================================
--- lld/trunk/test/ELF/linkerscript/non-absolute2.s (original)
+++ lld/trunk/test/ELF/linkerscript/non-absolute2.s Tue Mar 13 08:47:14 2018
@@ -1,9 +1,13 @@
 # REQUIRES: x86
-# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t1.o
-# RUN: echo "SECTIONS { A = . + 0x1; . += 0x1000; }" > %t.script
-# RUN: ld.lld -shared %t1.o --script %t.script -o %t
+# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux /dev/null -o %t1.o
+# RUN: ld.lld -shared %t1.o --script %s -o %t
 # RUN: llvm-objdump -section-headers -t %t | FileCheck %s
 
+SECTIONS {
+  A = . + 0x1;
+  . += 0x1000;
+}
+
 # CHECK:       Sections:
 # CHECK-NEXT:   Idx Name          Size      Address
 # CHECK-NEXT:    0               00000000 0000000000000000

Modified: lld/trunk/test/ELF/linkerscript/openbsd-bootdata.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/linkerscript/openbsd-bootdata.s?rev=327410&r1=327409&r2=327410&view=diff
==============================================================================
--- lld/trunk/test/ELF/linkerscript/openbsd-bootdata.s (original)
+++ lld/trunk/test/ELF/linkerscript/openbsd-bootdata.s Tue Mar 13 08:47:14 2018
@@ -1,7 +1,8 @@
-# RUN: llvm-mc -filetype=obj -triple=i686-unknown-linux %s -o %t.o
-# RUN: echo "PHDRS { boot PT_OPENBSD_BOOTDATA; }" > %t.script
-# RUN: ld.lld --script %t.script %t.o -o %t
+# RUN: llvm-mc -filetype=obj -triple=i686-unknown-linux /dev/null -o %t.o
+# RUN: ld.lld --script %s %t.o -o %t
 # RUN: llvm-readobj --program-headers -s %t | FileCheck %s
 
+PHDRS { boot PT_OPENBSD_BOOTDATA; }
+
 # CHECK:      ProgramHeader {
 # CHECK:        Type: PT_OPENBSD_BOOTDATA (0x65A41BE6)

Modified: lld/trunk/test/ELF/linkerscript/openbsd-wxneeded.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/linkerscript/openbsd-wxneeded.s?rev=327410&r1=327409&r2=327410&view=diff
==============================================================================
--- lld/trunk/test/ELF/linkerscript/openbsd-wxneeded.s (original)
+++ lld/trunk/test/ELF/linkerscript/openbsd-wxneeded.s Tue Mar 13 08:47:14 2018
@@ -1,8 +1,9 @@
-# RUN: llvm-mc -filetype=obj -triple=i686-unknown-linux %s -o %t.o
-# RUN: echo "PHDRS { text PT_LOAD FILEHDR PHDRS; wxneeded PT_OPENBSD_WXNEEDED; }" > %t.script
-# RUN: ld.lld -z wxneeded --script %t.script %t.o -o %t
+# RUN: llvm-mc -filetype=obj -triple=i686-unknown-linux /dev/null -o %t.o
+# RUN: ld.lld -z wxneeded --script %s %t.o -o %t
 # RUN: llvm-readobj --program-headers %t | FileCheck %s
 
+PHDRS { text PT_LOAD FILEHDR PHDRS; wxneeded PT_OPENBSD_WXNEEDED; }
+
 # CHECK:      ProgramHeader {
 # CHECK:        Type: PT_OPENBSD_WXNEEDED (0x65A3DBE7)
 # CHECK-NEXT:   Offset: 0x0

Modified: lld/trunk/test/ELF/linkerscript/orphan-first-cmd.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/linkerscript/orphan-first-cmd.s?rev=327410&r1=327409&r2=327410&view=diff
==============================================================================
--- lld/trunk/test/ELF/linkerscript/orphan-first-cmd.s (original)
+++ lld/trunk/test/ELF/linkerscript/orphan-first-cmd.s Tue Mar 13 08:47:14 2018
@@ -1,14 +1,16 @@
 # REQUIRES: x86
-# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
-# RUN: echo "SECTIONS { \
-# RUN:         foo = 123; \
-# RUN:         . = 0x1000; \
-# RUN:         . = 0x2000; \
-# RUN:         .bar : { *(.bar) } \
-# RUN:       }" > %t.script
-# RUN: ld.lld -o %t -T %t.script %t.o -shared
+# RUN: echo '.section .bar, "aw"' \
+# RUN:   | llvm-mc -filetype=obj -triple=x86_64-unknown-linux - -o %t.o
+# RUN: ld.lld -o %t -T %s %t.o -shared
 # RUN: llvm-readobj -s %t | FileCheck %s
 
+SECTIONS {
+  foo = 123;
+  . = 0x1000;
+  . = 0x2000;
+  .bar : { *(.bar) }
+}
+
 # CHECK:      Name: .text
 # CHECK-NEXT: Type: SHT_PROGBITS
 # CHECK-NEXT: Flags [
@@ -16,5 +18,3 @@
 # CHECK-NEXT:   SHF_EXECINSTR
 # CHECK-NEXT: ]
 # CHECK-NEXT: Address: 0x1000
-
-.section .bar, "aw"

Modified: lld/trunk/test/ELF/linkerscript/outputarch.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/linkerscript/outputarch.s?rev=327410&r1=327409&r2=327410&view=diff
==============================================================================
--- lld/trunk/test/ELF/linkerscript/outputarch.s (original)
+++ lld/trunk/test/ELF/linkerscript/outputarch.s Tue Mar 13 08:47:14 2018
@@ -1,4 +1,5 @@
 # REQUIRES: x86
-# RUN: echo "OUTPUT_ARCH(All data written here is ignored)" > %t.script
-# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-freebsd %s -o %t1
-# RUN: ld.lld -shared -o %t2 %t1 %t.script
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-freebsd /dev/null -o %t1
+# RUN: ld.lld -shared -o %t2 %t1 %s
+
+OUTPUT_ARCH(All data written here is ignored)

Modified: lld/trunk/test/ELF/linkerscript/page-size-align.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/linkerscript/page-size-align.s?rev=327410&r1=327409&r2=327410&view=diff
==============================================================================
--- lld/trunk/test/ELF/linkerscript/page-size-align.s (original)
+++ lld/trunk/test/ELF/linkerscript/page-size-align.s Tue Mar 13 08:47:14 2018
@@ -1,17 +1,16 @@
 # REQUIRES: x86
-# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
-
-# RUN: echo "SECTIONS { \
-# RUN:         . = SIZEOF_HEADERS; \
-# RUN:         .text : { *(.text) } \
-# RUN:         . = ALIGN(CONSTANT(MAXPAGESIZE)); \
-# RUN:         . = . + 0x3000; \
-# RUN:         .dynamic : { *(.dynamic) } \
-# RUN:       }" > %t.script
-
-# RUN: ld.lld -T %t.script -z max-page-size=0x4000 %t.o -o %t.so -shared
+# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux /dev/null -o %t.o
+# RUN: ld.lld -T %s -z max-page-size=0x4000 %t.o -o %t.so -shared
 # RUN: llvm-readobj -s %t.so | FileCheck %s
 
+SECTIONS {
+  . = SIZEOF_HEADERS;
+  .text : { *(.text) }
+  . = ALIGN(CONSTANT(MAXPAGESIZE));
+  . = . + 0x3000;
+  .dynamic : { *(.dynamic) }
+}
+
 # CHECK:      Name: .dynamic
 # CHECK-NEXT: Type: SHT_DYNAMIC
 # CHECK-NEXT: Flags [

Modified: lld/trunk/test/ELF/linkerscript/parse-section-in-addr.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/linkerscript/parse-section-in-addr.s?rev=327410&r1=327409&r2=327410&view=diff
==============================================================================
--- lld/trunk/test/ELF/linkerscript/parse-section-in-addr.s (original)
+++ lld/trunk/test/ELF/linkerscript/parse-section-in-addr.s Tue Mar 13 08:47:14 2018
@@ -1,10 +1,10 @@
 # REQUIRES: x86
-# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
-
-# RUN: echo "SECTIONS {                                   \
-# RUN:         .foo-bar : AT(ADDR(.foo-bar)) { *(.text) } \
-# RUN:       }" > %t.script
-# RUN: ld.lld -o %t.so --script %t.script %t.o -shared
+# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux /dev/null -o %t.o
+# RUN: ld.lld -o %t.so --script %s %t.o -shared
 # RUN: llvm-readelf -S %t.so | FileCheck %s
 
+SECTIONS {
+ .foo-bar : AT(ADDR(.foo-bar)) { *(.text) }
+}
+
 # CHECK: .foo-bar

Modified: lld/trunk/test/ELF/linkerscript/rosegment.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/linkerscript/rosegment.s?rev=327410&r1=327409&r2=327410&view=diff
==============================================================================
--- lld/trunk/test/ELF/linkerscript/rosegment.s (original)
+++ lld/trunk/test/ELF/linkerscript/rosegment.s Tue Mar 13 08:47:14 2018
@@ -1,12 +1,14 @@
 # REQUIRES: x86
-# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux /dev/null -o %t
 
 # Test that with linker scripts we don't create a RO PT_LOAD.
 
-# RUN: echo "SECTIONS {}" > %t.script
-# RUN: ld.lld -o %t1 --script %t.script %t -shared
+# RUN: ld.lld -o %t1 --script %s %t -shared
 # RUN: llvm-readobj -l %t1 | FileCheck %s
 
+SECTIONS {
+}
+
 # CHECK-NOT:  Type: PT_LOAD
 
 # CHECK:      Type: PT_LOAD

Modified: lld/trunk/test/ELF/linkerscript/sort-constructors.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/linkerscript/sort-constructors.s?rev=327410&r1=327409&r2=327410&view=diff
==============================================================================
--- lld/trunk/test/ELF/linkerscript/sort-constructors.s (original)
+++ lld/trunk/test/ELF/linkerscript/sort-constructors.s Tue Mar 13 08:47:14 2018
@@ -1,5 +1,8 @@
 # REQUIRES: x86
-# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t1.o
-# RUN: echo "SECTIONS { .aaa : { SORT(CONSTRUCTORS) } }" > %t1.script
-# RUN: ld.lld -shared -o %t1 --script %t1.script %t1.o
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux /dev/null -o %t1.o
+# RUN: ld.lld -shared -o %t1 --script %s %t1.o
 # RUN: llvm-readobj %t1 > /dev/null
+
+SECTIONS {
+ .aaa : { SORT(CONSTRUCTORS) } 
+}

Modified: lld/trunk/test/ELF/linkerscript/start-end.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/linkerscript/start-end.s?rev=327410&r1=327409&r2=327410&view=diff
==============================================================================
--- lld/trunk/test/ELF/linkerscript/start-end.s (original)
+++ lld/trunk/test/ELF/linkerscript/start-end.s Tue Mar 13 08:47:14 2018
@@ -1,16 +1,12 @@
 # REQUIRES: x86
-# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
-# RUN: echo "SECTIONS { \
-# RUN:      .init_array : { \
-# RUN:        __init_array_start = .; \
-# RUN:        *(.init_array) \
-# RUN:        __init_array_end = .; } }" > %t.script
-# RUN: ld.lld %t.o -script %t.script -o %t 2>&1
+# RUN: echo '.section .init_array, "aw"; .quad 0' \
+# RUN:   | llvm-mc -filetype=obj -triple=x86_64-unknown-linux - -o %t.o
+# RUN: ld.lld %t.o -script %s -o %t 2>&1
 
-.globl _start
-.text
-_start:
-  nop
-
-.section .init_array, "aw"
-  .quad 0
+SECTIONS {
+  .init_array : {
+    __init_array_start = .;
+    *(.init_array)
+    __init_array_end = .;
+  }
+}

Modified: lld/trunk/test/ELF/linkerscript/symbol-only-flags.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/linkerscript/symbol-only-flags.s?rev=327410&r1=327409&r2=327410&view=diff
==============================================================================
--- lld/trunk/test/ELF/linkerscript/symbol-only-flags.s (original)
+++ lld/trunk/test/ELF/linkerscript/symbol-only-flags.s Tue Mar 13 08:47:14 2018
@@ -1,11 +1,15 @@
 # REQUIRES: x86
-# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o
-# RUN: echo "SECTIONS { . = SIZEOF_HEADERS; \
-# RUN:         .tbss : { *(.tbss) }         \
-# RUN:         .foo : { bar = .; } }" > %t.script
-# RUN: ld.lld -o %t --script %t.script %t.o
+# RUN: echo '.section .tbss,"awT", at nobits; .quad 0' \
+# RUN:   | llvm-mc -filetype=obj -triple=x86_64-unknown-linux - -o %t.o
+# RUN: ld.lld -o %t --script %s %t.o
 # RUN: llvm-readobj -s %t | FileCheck %s
 
+SECTIONS {
+  . = SIZEOF_HEADERS;
+  .tbss : { *(.tbss) }
+  .foo : { bar = .; }
+}
+
 ## Check .foo does not get SHF_TLS flag.
 # CHECK:     Section {
 # CHECK:       Index:
@@ -15,6 +19,3 @@
 # CHECK-NEXT:    SHF_ALLOC
 # CHECK-NEXT:    SHF_WRITE
 # CHECK-NEXT:  ]
-
-.section .tbss,"awT", at nobits
-.quad 0

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=327410&r1=327409&r2=327410&view=diff
==============================================================================
--- lld/trunk/test/ELF/linkerscript/symbol-only.s (original)
+++ lld/trunk/test/ELF/linkerscript/symbol-only.s Tue Mar 13 08:47:14 2018
@@ -1,14 +1,16 @@
 # REQUIRES: x86
-# 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) } \
-# RUN: }" > %t.script
-# RUN: ld.lld -o %t1 --script %t.script %t -shared
+# RUN: echo '.section bar, "a"' \
+# RUN:   | llvm-mc -filetype=obj -triple=x86_64-unknown-linux - -o %t
+# RUN: ld.lld -o %t1 --script %s %t -shared
 # RUN: llvm-objdump -section-headers -t %t1 | FileCheck %s
+
+SECTIONS {
+  . = SIZEOF_HEADERS;
+  abc : { foo = .; }
+  . = ALIGN(0x1000);
+  bar : { *(bar) }
+}
+
 # CHECK:      Sections:
 # CHECK-NEXT: Idx Name          Size      Address
 # CHECK-NEXT:   0               00000000 0000000000000000
@@ -17,5 +19,3 @@
 
 # CHECK: SYMBOL TABLE:
 # CHECK:     [[ADDR]]         abc                00000000 foo
-
-.section bar, "a"

Modified: lld/trunk/test/ELF/linkerscript/symbols-non-alloc.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/linkerscript/symbols-non-alloc.s?rev=327410&r1=327409&r2=327410&view=diff
==============================================================================
--- lld/trunk/test/ELF/linkerscript/symbols-non-alloc.s (original)
+++ lld/trunk/test/ELF/linkerscript/symbols-non-alloc.s Tue Mar 13 08:47:14 2018
@@ -1,12 +1,7 @@
 # REQUIRES: x86
-# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
-
-# RUN: echo "SECTIONS { . = SIZEOF_HEADERS; \
-# RUN:  .text : { *(.text) }                \
-# RUN:  .nonalloc : { *(.nonalloc) }        \
-# RUN:  Sym = .;                            \
-# RUN:  }" > %t.script
-# RUN: ld.lld -o %t2 --script %t.script %t
+# RUN: echo '.section .nonalloc,""; .quad 0' \
+# RUN:   | llvm-mc -filetype=obj -triple=x86_64-unknown-linux - -o %t
+# RUN: ld.lld -o %t2 --script %s %t
 # RUN: llvm-objdump -section-headers -t %t2 | FileCheck %s
 
 # CHECK: Sections:
@@ -15,5 +10,9 @@
 # CHECK: SYMBOL TABLE:
 # CHECK:  0000000000000008 .nonalloc 00000000 Sym
 
-.section .nonalloc,""
- .quad 0
+SECTIONS {
+  . = SIZEOF_HEADERS;
+  .text : { *(.text) }
+  .nonalloc : { *(.nonalloc) }
+  Sym = .;
+}

Modified: lld/trunk/test/ELF/linkerscript/unused-synthetic2.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/linkerscript/unused-synthetic2.s?rev=327410&r1=327409&r2=327410&view=diff
==============================================================================
--- lld/trunk/test/ELF/linkerscript/unused-synthetic2.s (original)
+++ lld/trunk/test/ELF/linkerscript/unused-synthetic2.s Tue Mar 13 08:47:14 2018
@@ -1,9 +1,12 @@
 # REQUIRES: arm
-# RUN: llvm-mc -filetype=obj -triple=armv7-unknown-linux-gnueabi %s -o %t.o
-# RUN: echo "SECTIONS { .trap : { *(.ARM.exidx) *(.dummy) } }" > %t.script
+# RUN: llvm-mc -filetype=obj -triple=armv7-unknown-linux-gnueabi /dev/null -o %t.o
 
 ## We incorrectly removed unused synthetic sections and crashed before.
 ## Check we do not crash and do not produce .trap output section.
-# RUN: ld.lld -shared -o %t.so --script %t.script %t.o
+# RUN: ld.lld -shared -o %t.so --script %s %t.o
 # RUN: llvm-objdump -section-headers %t.so | FileCheck %s
 # CHECK-NOT: .trap
+
+SECTIONS {
+  .trap : { *(.ARM.exidx) *(.dummy) }
+}




More information about the llvm-commits mailing list