diff options
28 files changed, 232 insertions, 200 deletions
diff --git a/lld/test/ELF/linkerscript/bss-fill.s b/lld/test/ELF/linkerscript/bss-fill.s index 92f9fdf5619..b7ed4765617 100644 --- a/lld/test/ELF/linkerscript/bss-fill.s +++ b/lld/test/ELF/linkerscript/bss-fill.s @@ -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,"",@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,"",@nobits -.short 0 +## Check we do not crash. + +SECTIONS { + .bss : { + . += 0x10000; + *(.bss) + } =0xFF +} diff --git a/lld/test/ELF/linkerscript/common-filespec.s b/lld/test/ELF/linkerscript/common-filespec.s index 25bb486ed44..2afd91d3d5b 100644 --- a/lld/test/ELF/linkerscript/common-filespec.s +++ b/lld/test/ELF/linkerscript/common-filespec.s @@ -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 diff --git a/lld/test/ELF/linkerscript/constructor.s b/lld/test/ELF/linkerscript/constructor.s index acb86fd88e2..edd2cd29799 100644 --- a/lld/test/ELF/linkerscript/constructor.s +++ b/lld/test/ELF/linkerscript/constructor.s @@ -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 + } +} diff --git a/lld/test/ELF/linkerscript/double-bss.s b/lld/test/ELF/linkerscript/double-bss.s index c24332f5e5a..32b796d01c2 100644 --- a/lld/test/ELF/linkerscript/double-bss.s +++ b/lld/test/ELF/linkerscript/double-bss.s @@ -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) } +} diff --git a/lld/test/ELF/linkerscript/empty-tls.s b/lld/test/ELF/linkerscript/empty-tls.s index 0ef2e7be7b3..2f473cb55f8 100644 --- a/lld/test/ELF/linkerscript/empty-tls.s +++ b/lld/test/ELF/linkerscript/empty-tls.s @@ -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 diff --git a/lld/test/ELF/linkerscript/exidx-crash.s b/lld/test/ELF/linkerscript/exidx-crash.s index c29d0135414..4d765f4d338 100644 --- a/lld/test/ELF/linkerscript/exidx-crash.s +++ b/lld/test/ELF/linkerscript/exidx-crash.s @@ -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) } +} diff --git a/lld/test/ELF/linkerscript/expr-invalid-sec.s b/lld/test/ELF/linkerscript/expr-invalid-sec.s index 5687751b680..9abfc1308a6 100644 --- a/lld/test/ELF/linkerscript/expr-invalid-sec.s +++ b/lld/test/ELF/linkerscript/expr-invalid-sec.s @@ -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); +}; diff --git a/lld/test/ELF/linkerscript/header-addr.s b/lld/test/ELF/linkerscript/header-addr.s index 70e6f674baf..7994c0fc965 100644 --- a/lld/test/ELF/linkerscript/header-addr.s +++ b/lld/test/ELF/linkerscript/header-addr.s @@ -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 diff --git a/lld/test/ELF/linkerscript/header-phdr.s b/lld/test/ELF/linkerscript/header-phdr.s index 8c9097d8dfa..72be15b88a9 100644 --- a/lld/test/ELF/linkerscript/header-phdr.s +++ b/lld/test/ELF/linkerscript/header-phdr.s @@ -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 +} diff --git a/lld/test/ELF/linkerscript/implicit-program-header.s b/lld/test/ELF/linkerscript/implicit-program-header.s index 682f2024558..ea5c8738d83 100644 --- a/lld/test/ELF/linkerscript/implicit-program-header.s +++ b/lld/test/ELF/linkerscript/implicit-program-header.s @@ -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 +} diff --git a/lld/test/ELF/linkerscript/lazy-symbols.s b/lld/test/ELF/linkerscript/lazy-symbols.s index 22dffeef979..579df932386 100644 --- a/lld/test/ELF/linkerscript/lazy-symbols.s +++ b/lld/test/ELF/linkerscript/lazy-symbols.s @@ -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. diff --git a/lld/test/ELF/linkerscript/locationcountererr.s b/lld/test/ELF/linkerscript/locationcountererr.s index 113e102d4bc..3311e4555ae 100644 --- a/lld/test/ELF/linkerscript/locationcountererr.s +++ b/lld/test/ELF/linkerscript/locationcountererr.s @@ -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) + } +} diff --git a/lld/test/ELF/linkerscript/memory-at.s b/lld/test/ELF/linkerscript/memory-at.s index 9e56dbdbd65..0f06a6620a7 100644 --- a/lld/test/ELF/linkerscript/memory-at.s +++ b/lld/test/ELF/linkerscript/memory-at.s @@ -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 diff --git a/lld/test/ELF/linkerscript/no-pt-load.s b/lld/test/ELF/linkerscript/no-pt-load.s index c7040250139..16f7f440998 100644 --- a/lld/test/ELF/linkerscript/no-pt-load.s +++ b/lld/test/ELF/linkerscript/no-pt-load.s @@ -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 +} diff --git a/lld/test/ELF/linkerscript/non-absolute2.s b/lld/test/ELF/linkerscript/non-absolute2.s index 97c34d31a91..fa9e0e41c66 100644 --- a/lld/test/ELF/linkerscript/non-absolute2.s +++ b/lld/test/ELF/linkerscript/non-absolute2.s @@ -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 diff --git a/lld/test/ELF/linkerscript/openbsd-bootdata.s b/lld/test/ELF/linkerscript/openbsd-bootdata.s index 3e90574bb3a..ad3a569dea5 100644 --- a/lld/test/ELF/linkerscript/openbsd-bootdata.s +++ b/lld/test/ELF/linkerscript/openbsd-bootdata.s @@ -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) diff --git a/lld/test/ELF/linkerscript/openbsd-wxneeded.s b/lld/test/ELF/linkerscript/openbsd-wxneeded.s index d371da9d864..3b82a94f094 100644 --- a/lld/test/ELF/linkerscript/openbsd-wxneeded.s +++ b/lld/test/ELF/linkerscript/openbsd-wxneeded.s @@ -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 diff --git a/lld/test/ELF/linkerscript/orphan-first-cmd.s b/lld/test/ELF/linkerscript/orphan-first-cmd.s index 263cb30d686..6ef473baa89 100644 --- a/lld/test/ELF/linkerscript/orphan-first-cmd.s +++ b/lld/test/ELF/linkerscript/orphan-first-cmd.s @@ -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" diff --git a/lld/test/ELF/linkerscript/outputarch.s b/lld/test/ELF/linkerscript/outputarch.s index dd3bf93611b..4819a983cfc 100644 --- a/lld/test/ELF/linkerscript/outputarch.s +++ b/lld/test/ELF/linkerscript/outputarch.s @@ -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) diff --git a/lld/test/ELF/linkerscript/page-size-align.s b/lld/test/ELF/linkerscript/page-size-align.s index 771bb13a8e6..f6941315742 100644 --- a/lld/test/ELF/linkerscript/page-size-align.s +++ b/lld/test/ELF/linkerscript/page-size-align.s @@ -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 [ diff --git a/lld/test/ELF/linkerscript/parse-section-in-addr.s b/lld/test/ELF/linkerscript/parse-section-in-addr.s index 7a79f646310..6f42a6fe278 100644 --- a/lld/test/ELF/linkerscript/parse-section-in-addr.s +++ b/lld/test/ELF/linkerscript/parse-section-in-addr.s @@ -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 diff --git a/lld/test/ELF/linkerscript/rosegment.s b/lld/test/ELF/linkerscript/rosegment.s index 3201b8bda9f..41479e609d2 100644 --- a/lld/test/ELF/linkerscript/rosegment.s +++ b/lld/test/ELF/linkerscript/rosegment.s @@ -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 diff --git a/lld/test/ELF/linkerscript/sort-constructors.s b/lld/test/ELF/linkerscript/sort-constructors.s index a0c23af6de7..698208afd54 100644 --- a/lld/test/ELF/linkerscript/sort-constructors.s +++ b/lld/test/ELF/linkerscript/sort-constructors.s @@ -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) } +} diff --git a/lld/test/ELF/linkerscript/start-end.s b/lld/test/ELF/linkerscript/start-end.s index b68606abc18..ab7504dac2d 100644 --- a/lld/test/ELF/linkerscript/start-end.s +++ b/lld/test/ELF/linkerscript/start-end.s @@ -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 = .; + } +} diff --git a/lld/test/ELF/linkerscript/symbol-only-flags.s b/lld/test/ELF/linkerscript/symbol-only-flags.s index 300d8d88da9..cea2539cd6b 100644 --- a/lld/test/ELF/linkerscript/symbol-only-flags.s +++ b/lld/test/ELF/linkerscript/symbol-only-flags.s @@ -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",@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",@nobits -.quad 0 diff --git a/lld/test/ELF/linkerscript/symbol-only.s b/lld/test/ELF/linkerscript/symbol-only.s index 76d54f01cdc..e2123fb172d 100644 --- a/lld/test/ELF/linkerscript/symbol-only.s +++ b/lld/test/ELF/linkerscript/symbol-only.s @@ -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" diff --git a/lld/test/ELF/linkerscript/symbols-non-alloc.s b/lld/test/ELF/linkerscript/symbols-non-alloc.s index e51a39ee5d2..6d7580affc2 100644 --- a/lld/test/ELF/linkerscript/symbols-non-alloc.s +++ b/lld/test/ELF/linkerscript/symbols-non-alloc.s @@ -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 = .; +} diff --git a/lld/test/ELF/linkerscript/unused-synthetic2.s b/lld/test/ELF/linkerscript/unused-synthetic2.s index cdde97df3c5..755d1af00be 100644 --- a/lld/test/ELF/linkerscript/unused-synthetic2.s +++ b/lld/test/ELF/linkerscript/unused-synthetic2.s @@ -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) } +} |