diff options
36 files changed, 445 insertions, 491 deletions
diff --git a/lld/test/ELF/linkerscript/Inputs/data-commands.s b/lld/test/ELF/linkerscript/Inputs/data-commands.s new file mode 100644 index 00000000000..d5d78cfd9be --- /dev/null +++ b/lld/test/ELF/linkerscript/Inputs/data-commands.s @@ -0,0 +1,35 @@ +.global a +a = 0x11 + +.global b +b = 0x1122 + +.global c +c = 0x11223344 + +.global d +d = 0x1122334455667788 + +.section .foo.1, "a" + .byte 0xFF + +.section .foo.2, "a" + .byte 0xFF + +.section .foo.3, "a" + .byte 0xFF + +.section .foo.4, "a" + .byte 0xFF + +.section .bar.1, "a" + .byte 0xFF + +.section .bar.2, "a" + .byte 0xFF + +.section .bar.3, "a" + .byte 0xFF + +.section .bar.4, "a" + .byte 0xFF diff --git a/lld/test/ELF/linkerscript/Inputs/data-segment-relro.s b/lld/test/ELF/linkerscript/Inputs/data-segment-relro.s new file mode 100644 index 00000000000..668a2e2ca2a --- /dev/null +++ b/lld/test/ELF/linkerscript/Inputs/data-segment-relro.s @@ -0,0 +1,11 @@ +.global _start +_start: + .long bar + jmp *bar2@GOTPCREL(%rip) + +.section .data,"aw" +.quad 0 + +.zero 4 +.section .foo,"aw" +.section .bss,"",@nobits diff --git a/lld/test/ELF/linkerscript/Inputs/define.s b/lld/test/ELF/linkerscript/Inputs/define.s new file mode 100644 index 00000000000..bc60a233dcb --- /dev/null +++ b/lld/test/ELF/linkerscript/Inputs/define.s @@ -0,0 +1,8 @@ +.global defined +defined = 0 + +.section .foo,"a" +.quad 1 + +.section .bar,"a" +.quad 1 diff --git a/lld/test/ELF/linkerscript/Inputs/eh-frame-reloc-out-of-range.s b/lld/test/ELF/linkerscript/Inputs/eh-frame-reloc-out-of-range.s new file mode 100644 index 00000000000..19e50488050 --- /dev/null +++ b/lld/test/ELF/linkerscript/Inputs/eh-frame-reloc-out-of-range.s @@ -0,0 +1,11 @@ +.text +.globl _start +_start: + .cfi_startproc + .cfi_lsda 0, _ex + nop + .cfi_endproc + +.data +_ex: + .word 0 diff --git a/lld/test/ELF/linkerscript/Inputs/extend-pt-load.s b/lld/test/ELF/linkerscript/Inputs/extend-pt-load.s new file mode 100644 index 00000000000..8993fb16334 --- /dev/null +++ b/lld/test/ELF/linkerscript/Inputs/extend-pt-load.s @@ -0,0 +1,3 @@ +nop +.section .data.rel.ro, "aw" +.byte 0 diff --git a/lld/test/ELF/linkerscript/Inputs/fill.s b/lld/test/ELF/linkerscript/Inputs/fill.s new file mode 100644 index 00000000000..b8eed890601 --- /dev/null +++ b/lld/test/ELF/linkerscript/Inputs/fill.s @@ -0,0 +1,11 @@ +.text +.globl _start +_start: + +.section .aaa, "a" +.align 1 +.byte 0xAA + +.section .bbb, "a" +.align 1 +.byte 0xBB diff --git a/lld/test/ELF/linkerscript/data-commands.s b/lld/test/ELF/linkerscript/data-commands.s deleted file mode 100644 index 5a5655620dd..00000000000 --- a/lld/test/ELF/linkerscript/data-commands.s +++ /dev/null @@ -1,117 +0,0 @@ -# REQUIRES: x86,mips -# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o -# RUN: echo "SECTIONS \ -# RUN: { \ -# RUN: .foo : { \ -# RUN: *(.foo.1) \ -# RUN: BYTE(0x11) \ -# RUN: *(.foo.2) \ -# RUN: SHORT(0x1122) \ -# RUN: *(.foo.3) \ -# RUN: LONG(0x11223344) \ -# RUN: *(.foo.4) \ -# RUN: QUAD(0x1122334455667788) \ -# RUN: } \ -# RUN: .bar : { \ -# RUN: *(.bar.1) \ -# RUN: BYTE(a + 1) \ -# RUN: *(.bar.2) \ -# RUN: SHORT(b) \ -# RUN: *(.bar.3) \ -# RUN: LONG(c + 2) \ -# RUN: *(.bar.4) \ -# RUN: QUAD(d) \ -# RUN: } \ -# RUN: }" > %t.script -# RUN: ld.lld -o %t %t.o --script %t.script -# RUN: llvm-objdump -s %t | FileCheck %s - -# CHECK: Contents of section .foo: -# CHECK-NEXT: ff11ff22 11ff4433 2211ff88 77665544 -# CHECK-NEXT: 332211 - -# CHECK: Contents of section .bar: -# CHECK-NEXT: ff12ff22 11ff4633 2211ff88 77665544 -# CHECK-NEXT: 332211 - -# RUN: llvm-mc -filetype=obj -triple=mips64-unknown-linux %s -o %tmips64be -# RUN: ld.lld --script %t.script %tmips64be -o %t2 -# RUN: llvm-objdump -s %t2 | FileCheck %s --check-prefix=BE -# BE: Contents of section .foo: -# BE-NEXT: ff11ff11 22ff1122 3344ff11 22334455 -# BE-NEXT: 667788 -# BE-NEXT: Contents of section .bar: -# BE-NEXT: ff12ff11 22ff1122 3346ff11 22334455 -# BE-NEXT: 667788 - -# RUN: echo "MEMORY { \ -# RUN: rom (rwx) : ORIGIN = 0x00, LENGTH = 2K \ -# RUN: } \ -# RUN: SECTIONS { \ -# RUN: .foo : { \ -# RUN: *(.foo.1) \ -# RUN: BYTE(0x11) \ -# RUN: *(.foo.2) \ -# RUN: SHORT(0x1122) \ -# RUN: *(.foo.3) \ -# RUN: LONG(0x11223344) \ -# RUN: *(.foo.4) \ -# RUN: QUAD(0x1122334455667788) \ -# RUN: } > rom \ -# RUN: .bar : { \ -# RUN: *(.bar.1) \ -# RUN: BYTE(a + 1) \ -# RUN: *(.bar.2) \ -# RUN: SHORT(b) \ -# RUN: *(.bar.3) \ -# RUN: LONG(c + 2) \ -# RUN: *(.bar.4) \ -# RUN: QUAD(d) \ -# RUN: } > rom \ -# RUN: }" > %t-memory.script -# RUN: ld.lld -o %t-memory %t.o --script %t-memory.script -# RUN: llvm-objdump -s %t-memory | FileCheck %s --check-prefix=MEM - -# MEM: Contents of section .foo: -# MEM-NEXT: 0000 ff11ff22 11ff4433 2211ff88 77665544 -# MEM-NEXT: 0010 332211 - -# MEM: Contents of section .bar: -# MEM-NEXT: 0013 ff12ff22 11ff4633 2211ff88 77665544 -# MEM-NEXT: 0023 332211 - -.global a -a = 0x11 - -.global b -b = 0x1122 - -.global c -c = 0x11223344 - -.global d -d = 0x1122334455667788 - -.section .foo.1, "a" - .byte 0xFF - -.section .foo.2, "a" - .byte 0xFF - -.section .foo.3, "a" - .byte 0xFF - -.section .foo.4, "a" - .byte 0xFF - -.section .bar.1, "a" - .byte 0xFF - -.section .bar.2, "a" - .byte 0xFF - -.section .bar.3, "a" - .byte 0xFF - -.section .bar.4, "a" - .byte 0xFF diff --git a/lld/test/ELF/linkerscript/data-commands1.test b/lld/test/ELF/linkerscript/data-commands1.test new file mode 100644 index 00000000000..32c5978c30a --- /dev/null +++ b/lld/test/ELF/linkerscript/data-commands1.test @@ -0,0 +1,45 @@ +# REQUIRES: x86,mips +# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/data-commands.s -o %t.o +# RUN: ld.lld -o %t %t.o --script %s +# RUN: llvm-objdump -s %t | FileCheck %s + +SECTIONS { + .foo : { + *(.foo.1) + BYTE(0x11) + *(.foo.2) + SHORT(0x1122) + *(.foo.3) + LONG(0x11223344) + *(.foo.4) + QUAD(0x1122334455667788) + } + .bar : { + *(.bar.1) + BYTE(a + 1) + *(.bar.2) + SHORT(b) + *(.bar.3) + LONG(c + 2) + *(.bar.4) + QUAD(d) + } +} + +# CHECK: Contents of section .foo: +# CHECK-NEXT: ff11ff22 11ff4433 2211ff88 77665544 +# CHECK-NEXT: 332211 + +# CHECK: Contents of section .bar: +# CHECK-NEXT: ff12ff22 11ff4633 2211ff88 77665544 +# CHECK-NEXT: 332211 + +# RUN: llvm-mc -filetype=obj -triple=mips64-unknown-linux %p/Inputs/data-commands.s -o %t2.o +# RUN: ld.lld --script %s %t2.o -o %t2 +# RUN: llvm-objdump -s %t2 | FileCheck -check-prefix=BIGENDIAN %s +# BIGENDIAN: Contents of section .foo: +# BIGENDIAN-NEXT: ff11ff11 22ff1122 3344ff11 22334455 +# BIGENDIAN-NEXT: 667788 +# BIGENDIAN-NEXT: Contents of section .bar: +# BIGENDIAN-NEXT: ff12ff11 22ff1122 3346ff11 22334455 +# BIGENDIAN-NEXT: 667788 diff --git a/lld/test/ELF/linkerscript/data-commands2.test b/lld/test/ELF/linkerscript/data-commands2.test new file mode 100644 index 00000000000..e1efa35965c --- /dev/null +++ b/lld/test/ELF/linkerscript/data-commands2.test @@ -0,0 +1,40 @@ +# REQUIRES: x86 +# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/data-commands.s -o %t.o +# RUN: ld.lld -o %t %t.o --script %s +# RUN: llvm-objdump -s %t | FileCheck %s + +MEMORY { + rom (rwx) : ORIGIN = 0x00, LENGTH = 2K +} + +SECTIONS { + .foo : { + *(.foo.1) + BYTE(0x11) + *(.foo.2) + SHORT(0x1122) + *(.foo.3) + LONG(0x11223344) + *(.foo.4) + QUAD(0x1122334455667788) + } > rom + + .bar : { + *(.bar.1) + BYTE(a + 1) + *(.bar.2) + SHORT(b) + *(.bar.3) + LONG(c + 2) + *(.bar.4) + QUAD(d) + } > rom +} + +# CHECK: Contents of section .foo: +# CHECK-NEXT: 0000 ff11ff22 11ff4433 2211ff88 77665544 +# CHECK-NEXT: 0010 332211 + +# CHECK: Contents of section .bar: +# CHECK-NEXT: 0013 ff12ff22 11ff4633 2211ff88 77665544 +# CHECK-NEXT: 0023 332211 diff --git a/lld/test/ELF/linkerscript/data-segment-relro.s b/lld/test/ELF/linkerscript/data-segment-relro.test index e835f42e22c..aeaf0854087 100644 --- a/lld/test/ELF/linkerscript/data-segment-relro.s +++ b/lld/test/ELF/linkerscript/data-segment-relro.test @@ -1,29 +1,37 @@ # REQUIRES: x86 -# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t1.o +# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/data-segment-relro.s -o %t1.o # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/shared.s -o %t2.o # 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)); \ -# RUN: .dynamic : { *(.dynamic) } \ -# RUN: .got : { *(.got) } \ -# RUN: . = DATA_SEGMENT_RELRO_END (1 ? 24 : 0, .); \ -# RUN: .got.plt : { *(.got.plt) } \ -# RUN: .data : { *(.data) } \ -# RUN: .bss : { *(.bss) } \ -# RUN: . = DATA_SEGMENT_END (.); \ -# RUN: }" > %t.script - ## With relro or without DATA_SEGMENT_RELRO_END just aligns to ## page boundary. -# RUN: ld.lld --hash-style=sysv -z norelro %t1.o %t2.so --script %t.script -o %t + +# RUN: ld.lld --hash-style=sysv -z norelro %t1.o %t2.so --script %s -o %t # RUN: llvm-readobj -s %t | FileCheck %s -# RUN: ld.lld --hash-style=sysv -z relro %t1.o %t2.so --script %t.script -o %t2 + +# RUN: ld.lld --hash-style=sysv -z relro %t1.o %t2.so --script %s -o %t2 # RUN: llvm-readobj -s %t2 | FileCheck %s +SECTIONS { + . = SIZEOF_HEADERS; + + .plt : { *(.plt) } + .text : { *(.text) } + + . = DATA_SEGMENT_ALIGN (CONSTANT (MAXPAGESIZE), CONSTANT (COMMONPAGESIZE)); + + .dynamic : { *(.dynamic) } + .got : { *(.got) } + + . = DATA_SEGMENT_RELRO_END (1 ? 24 : 0, .); + + .got.plt : { *(.got.plt) } + .data : { *(.data) } + .bss : { *(.bss) } + + . = DATA_SEGMENT_END (.); +} + # CHECK: Section { # CHECK: Index: # CHECK: Name: .got @@ -56,15 +64,3 @@ # CHECK-NEXT: AddressAlignment: # CHECK-NEXT: EntrySize: # CHECK-NEXT: } - -.global _start -_start: - .long bar - jmp *bar2@GOTPCREL(%rip) - -.section .data,"aw" -.quad 0 - -.zero 4 -.section .foo,"aw" -.section .bss,"",@nobits diff --git a/lld/test/ELF/linkerscript/define.s b/lld/test/ELF/linkerscript/define.s deleted file mode 100644 index b5f0b76e9e6..00000000000 --- a/lld/test/ELF/linkerscript/define.s +++ /dev/null @@ -1,25 +0,0 @@ -# REQUIRES: x86 -# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t - -# RUN: echo "SECTIONS \ -# RUN: { \ -# RUN: . = DEFINED(defined) ? 0x11000 : .; \ -# RUN: .foo : { *(.foo*) } \ -# RUN: . = DEFINED(notdefined) ? 0x12000 : 0x13000; \ -# RUN: .bar : { *(.bar*) } \ -# RUN: }" > %t.script -# RUN: ld.lld -o %t1 --script %t.script %t -# RUN: llvm-objdump -section-headers %t1 | FileCheck %s - -# CHECK: 1 .foo 00000008 0000000000011000 DATA -# CHECK: 2 .bar 00000008 0000000000013000 DATA -# CHECK: 3 .text 00000000 0000000000013008 TEXT DATA - -.global defined -defined = 0 - -.section .foo,"a" -.quad 1 - -.section .bar,"a" -.quad 1 diff --git a/lld/test/ELF/linkerscript/define.test b/lld/test/ELF/linkerscript/define.test new file mode 100644 index 00000000000..95b88314365 --- /dev/null +++ b/lld/test/ELF/linkerscript/define.test @@ -0,0 +1,15 @@ +# REQUIRES: x86 +# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/define.s -o %t.o +# RUN: ld.lld -o %t --script %s %t.o +# RUN: llvm-objdump -section-headers %t | FileCheck %s + +SECTIONS { + . = DEFINED(defined) ? 0x11000 : .; + .foo : { *(.foo*) } + . = DEFINED(notdefined) ? 0x12000 : 0x13000; + .bar : { *(.bar*) } +} + +# CHECK: 1 .foo 00000008 0000000000011000 DATA +# CHECK: 2 .bar 00000008 0000000000013000 DATA +# CHECK: 3 .text 00000000 0000000000013008 TEXT DATA diff --git a/lld/test/ELF/linkerscript/diag1.test b/lld/test/ELF/linkerscript/diag1.test new file mode 100644 index 00000000000..73a627ff4ef --- /dev/null +++ b/lld/test/ELF/linkerscript/diag1.test @@ -0,0 +1,15 @@ +# REQUIRES: x86 +# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux /dev/null -o %t.o +# RUN: not ld.lld -shared %t.o -o %t --script %s 2>&1 | FileCheck -strict-whitespace %s + +SECTIONS { + .text + { *(.text) } + .keep : { *(.keep) } /* + comment line 1 + comment line 2 */ + .temp : { *(.temp) } +} + +CHECK: 6: malformed number: + +CHECK-NEXT: >>> .text + { *(.text) } +CHECK-NEXT: >>> ^ diff --git a/lld/test/ELF/linkerscript/diag2.test b/lld/test/ELF/linkerscript/diag2.test new file mode 100644 index 00000000000..05cd4c3a752 --- /dev/null +++ b/lld/test/ELF/linkerscript/diag2.test @@ -0,0 +1,13 @@ +# REQUIRES: x86 +# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux /dev/null -o %t.o +# RUN: not ld.lld -shared %t.o -o %t --script %s 2>&1 | FileCheck -strict-whitespace %s + +UNKNOWN_TAG { + .text : { *(.text) } + .keep : { *(.keep) } + .temp : { *(.temp) } +} + +CHECK: 5: unknown directive: UNKNOWN_TAG +CHECK-NEXT: >>> UNKNOWN_TAG { +CHECK-NEXT: >>> ^ diff --git a/lld/test/ELF/linkerscript/diag3.test b/lld/test/ELF/linkerscript/diag3.test new file mode 100644 index 00000000000..8ffc9d4d864 --- /dev/null +++ b/lld/test/ELF/linkerscript/diag3.test @@ -0,0 +1,13 @@ +# REQUIRES: x86 +# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux /dev/null -o %t.o +# RUN: not ld.lld -shared %t.o -o %t --script %s 2>&1 | FileCheck -strict-whitespace %s + +SECTIONS { + .text : { *(.text) } + .keep : { *(.keep) } + boom .temp : { *(.temp) } +} + +# CHECK: 8: malformed number: .temp +# CHECK-NEXT: >>> boom .temp : { *(.temp) } +# CHECK-NEXT: >>> ^ diff --git a/lld/test/ELF/linkerscript/diag4.test b/lld/test/ELF/linkerscript/diag4.test new file mode 100644 index 00000000000..484bdf26fe7 --- /dev/null +++ b/lld/test/ELF/linkerscript/diag4.test @@ -0,0 +1,14 @@ +# REQUIRES: x86 +# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux /dev/null -o %t.o +# RUN: echo "INCLUDE \"%s\"" > %t.script +# RUN: not ld.lld -shared %t.o -o %t --script %t.script 2>&1 | FileCheck -strict-whitespace %s + +SECTIONS { + .text : { *(.text) } + .keep : { *(.keep) } + boom .temp : { *(.temp) } +} + +# CHECK: 9: malformed number: .temp +# CHECK-NEXT: >>> boom .temp : { *(.temp) } +# CHECK-NEXT: >>> ^
\ No newline at end of file diff --git a/lld/test/ELF/linkerscript/diag5.test b/lld/test/ELF/linkerscript/diag5.test new file mode 100644 index 00000000000..38a774e747a --- /dev/null +++ b/lld/test/ELF/linkerscript/diag5.test @@ -0,0 +1,14 @@ +# REQUIRES: x86 +# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux /dev/null -o %t.o +# RUN: echo "INCLUDE \"%s\"" > %t.script +# RUN: not ld.lld -shared %t.o -o %t --script %t.script 2>&1 | FileCheck -strict-whitespace %s + +SECTIONS { + .text : { *(.text) } + .keep : { *(.keep) } + boom .temp : { *(.temp) } +} + +# CHECK: 9: malformed number: .temp +# CHECK-NEXT: >>> boom .temp : { *(.temp) } +# CHECK-NEXT: >>> ^ diff --git a/lld/test/ELF/linkerscript/diag6.test b/lld/test/ELF/linkerscript/diag6.test new file mode 100644 index 00000000000..e4ad4d96d1d --- /dev/null +++ b/lld/test/ELF/linkerscript/diag6.test @@ -0,0 +1,7 @@ +# REQUIRES: x86 +# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux /dev/null -o %t.o +# RUN: not ld.lld -shared %t.o -o %t --script %s 2>&1 | FileCheck %s + +SECTIONS /* + +CHECK: error: unclosed comment in a linker script diff --git a/lld/test/ELF/linkerscript/diagnostic.s b/lld/test/ELF/linkerscript/diagnostic.s deleted file mode 100644 index af185729c43..00000000000 --- a/lld/test/ELF/linkerscript/diagnostic.s +++ /dev/null @@ -1,106 +0,0 @@ -# REQUIRES: x86 -# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t - -## Take some valid script with multiline comments -## and check it actually works: -# RUN: echo "SECTIONS {" > %t.script -# RUN: echo ".text : { *(.text) }" >> %t.script -# RUN: echo ".keep : { *(.keep) } /*" >> %t.script -# RUN: echo "comment line 1" >> %t.script -# RUN: echo "comment line 2 */" >> %t.script -# RUN: echo ".temp : { *(.temp) } }" >> %t.script -# RUN: ld.lld -shared %t -o %t1 --script %t.script - -## Change ":" to "+" at line 2, check that error -## message starts from correct line number: -# RUN: echo "SECTIONS {" > %t.script -# RUN: echo ".text + { *(.text) }" >> %t.script -# RUN: echo ".keep : { *(.keep) } /*" >> %t.script -# RUN: echo "comment line 1" >> %t.script -# RUN: echo "comment line 2 */" >> %t.script -# RUN: echo ".temp : { *(.temp) } }" >> %t.script -# RUN: not ld.lld -shared %t -o %t1 --script %t.script 2>&1 | FileCheck -check-prefix=ERR1 %s -# ERR1: {{.*}}.script:2: - -## Change ":" to "+" at line 3 now, check correct error line number: -# RUN: echo "SECTIONS {" > %t.script -# RUN: echo ".text : { *(.text) }" >> %t.script -# RUN: echo ".keep + { *(.keep) } /*" >> %t.script -# RUN: echo "comment line 1" >> %t.script -# RUN: echo "comment line 2 */" >> %t.script -# RUN: echo ".temp : { *(.temp) } }" >> %t.script -# RUN: not ld.lld -shared %t -o %t1 --script %t.script 2>&1 | FileCheck -check-prefix=ERR2 %s -# ERR2: {{.*}}.script:3: - -## Change ":" to "+" at line 6, after multiline comment, -## check correct error line number: -# RUN: echo "SECTIONS {" > %t.script -# RUN: echo ".text : { *(.text) }" >> %t.script -# RUN: echo ".keep : { *(.keep) } /*" >> %t.script -# RUN: echo "comment line 1" >> %t.script -# RUN: echo "comment line 2 */" >> %t.script -# RUN: echo ".temp + { *(.temp) } }" >> %t.script -# RUN: not ld.lld -shared %t -o %t1 --script %t.script 2>&1 | FileCheck -check-prefix=ERR5 %s -# ERR5: {{.*}}.script:6: - -## Check that text of lines and pointer to 'bad' token are working ok. -# RUN: echo "UNKNOWN_TAG {" > %t.script -# RUN: echo ".text : { *(.text) }" >> %t.script -# RUN: echo ".keep : { *(.keep) }" >> %t.script -# RUN: echo ".temp : { *(.temp) } }" >> %t.script -# RUN: not ld.lld -shared %t -o %t1 --script %t.script 2>&1 | \ -# RUN: FileCheck -check-prefix=ERR6 -strict-whitespace %s -# ERR6: error: {{.*}}.script:1: unknown directive: UNKNOWN_TAG -# ERR6-NEXT: >>> UNKNOWN_TAG { -# ERR6-NEXT: >>> ^ - -## One more check that text of lines and pointer to 'bad' token are working ok. -# RUN: echo "SECTIONS {" > %t.script -# RUN: echo ".text : { *(.text) }" >> %t.script -# RUN: echo ".keep : { *(.keep) }" >> %t.script -# RUN: echo "boom .temp : { *(.temp) } }" >> %t.script -# RUN: not ld.lld -shared %t -o %t1 --script %t.script 2>&1 | \ -# RUN: FileCheck -check-prefix=ERR7 -strict-whitespace %s -# ERR7: error: {{.*}}.script:4: malformed number: .temp -# ERR7-NEXT: >>> boom .temp : { *(.temp) } } -# ERR7-NEXT: >>> ^ - -## Check tokenize() error -# RUN: echo "SECTIONS {}" > %t.script -# RUN: echo "\"" >> %t.script -# RUN: not ld.lld -shared %t -o %t1 --script %t.script 2>&1 | \ -# RUN: FileCheck -check-prefix=ERR8 -strict-whitespace %s -# ERR8: {{.*}}.script:2: unclosed quote - -## Check tokenize() error in included script file -# RUN: echo "SECTIONS {}" > %t.script.inc -# RUN: echo "\"" >> %t.script.inc -# RUN: echo "INCLUDE \"%t.script.inc\"" > %t.script -# RUN: not ld.lld -shared %t -o %t1 --script %t.script 2>&1 | \ -# RUN: FileCheck -check-prefix=ERR9 -strict-whitespace %s -# ERR9: {{.*}}.script.inc:2: unclosed quote - -## Check error reporting correctness for included files. -# RUN: echo "SECTIONS {" > %t.script.inc -# RUN: echo ".text : { *(.text) }" >> %t.script.inc -# RUN: echo ".keep : { *(.keep) }" >> %t.script.inc -# RUN: echo "boom .temp : { *(.temp) } }" >> %t.script.inc -# RUN: echo "INCLUDE \"%t.script.inc\"" > %t.script -# RUN: not ld.lld -shared %t -o %t1 --script %t.script 2>&1 | \ -# RUN: FileCheck -check-prefix=ERR10 -strict-whitespace %s -# ERR10: error: {{.*}}.script.inc:4: malformed number: .temp -# ERR10-NEXT: >>> boom .temp : { *(.temp) } } -# ERR10-NEXT: >>> ^ - -## Check error reporting in script with INCLUDE directive. -# RUN: echo "SECTIONS {" > %t.script.inc -# RUN: echo ".text : { *(.text) }" >> %t.script.inc -# RUN: echo ".keep : { *(.keep) }" >> %t.script.inc -# RUN: echo ".temp : { *(.temp) } }" >> %t.script.inc -# RUN: echo "/* One line before INCLUDE */" > %t.script -# RUN: echo "INCLUDE \"%t.script.inc\"" >> %t.script -# RUN: echo "/* One line ater INCLUDE */" >> %t.script -# RUN: echo "Error" >> %t.script -# RUN: not ld.lld -shared %t -o %t1 --script %t.script 2>&1 | \ -# RUN: FileCheck -check-prefix=ERR11 -strict-whitespace %s -# ERR11: error: {{.*}}.script:4: unexpected EOF diff --git a/lld/test/ELF/linkerscript/dot-is-not-abs.s b/lld/test/ELF/linkerscript/dot-is-not-abs.s index 4532cd59f2a..a93d1c8b434 100644 --- a/lld/test/ELF/linkerscript/dot-is-not-abs.s +++ b/lld/test/ELF/linkerscript/dot-is-not-abs.s @@ -1,9 +1,7 @@ # REQUIRES: x86 # RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o -# RUN: echo "SECTIONS { .text : { *(.text) } \ -# RUN: foo = .; \ -# RUN: .bar : { *(.bar) } }" > %t1.script +# RUN: echo "SECTIONS { .text : { *(.text) } foo = .; .bar : { *(.bar) } }" > %t1.script # RUN: ld.lld -o %t1 --script %t1.script %t.o -shared # RUN: llvm-readobj -t -s -section-data %t1 | FileCheck %s diff --git a/lld/test/ELF/linkerscript/eh-frame-hdr.s b/lld/test/ELF/linkerscript/eh-frame-hdr.s index d1545be632a..02bc3ea3994 100644 --- a/lld/test/ELF/linkerscript/eh-frame-hdr.s +++ b/lld/test/ELF/linkerscript/eh-frame-hdr.s @@ -1,9 +1,6 @@ # REQUIRES: x86 # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t -# RUN: echo "SECTIONS { \ -# RUN: .eh_frame_hdr : {} \ -# RUN: .eh_frame : {} \ -# RUN: }" > %t.script +# RUN: echo "SECTIONS { .eh_frame_hdr : {} .eh_frame : {} }" > %t.script # RUN: ld.lld -o %t1 --eh-frame-hdr --script %t.script %t # RUN: llvm-objdump -s -section=".eh_frame_hdr" %t1 | FileCheck %s diff --git a/lld/test/ELF/linkerscript/eh-frame-reloc-out-of-range.s b/lld/test/ELF/linkerscript/eh-frame-reloc-out-of-range.s deleted file mode 100644 index 817e458fa5e..00000000000 --- a/lld/test/ELF/linkerscript/eh-frame-reloc-out-of-range.s +++ /dev/null @@ -1,27 +0,0 @@ -## Check that error is correctly reported when .eh_frame reloc -## is out of range - -# REQUIRES: x86 -# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o -# RUN: echo "PHDRS { eh PT_LOAD; text PT_LOAD; } \ -# RUN: SECTIONS { . = 0x10000; \ -# RUN: .eh_frame_hdr : { *(.eh_frame_hdr*) } : eh \ -# RUN: .eh_frame : { *(.eh_frame) } : eh \ -# RUN: . = 0xF00000000; \ -# RUN: .text : { *(.text*) } : text \ -# RUN: }" > %t.script -# RUN: not ld.lld %t.o -T %t.script -o %t 2>&1 | FileCheck %s - -# CHECK: error: {{.*}}:(.eh_frame+0x20): relocation R_X86_64_PC32 out of range: 64424443872 is not in [-2147483648, 2147483647] - - .text - .globl _start -_start: - .cfi_startproc - .cfi_lsda 0, _ex - nop - .cfi_endproc - - .data -_ex: - .word 0 diff --git a/lld/test/ELF/linkerscript/eh-frame-reloc-out-of-range.test b/lld/test/ELF/linkerscript/eh-frame-reloc-out-of-range.test new file mode 100644 index 00000000000..c64a27440b4 --- /dev/null +++ b/lld/test/ELF/linkerscript/eh-frame-reloc-out-of-range.test @@ -0,0 +1,13 @@ +# REQUIRES: x86 +# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/eh-frame-reloc-out-of-range.s -o %t.o +# RUN: not ld.lld %t.o -T %t.script -o %t 2>&1 | FileCheck %s + +PHDRS { eh PT_LOAD; text PT_LOAD; } +SECTIONS { . = 0x10000; + .eh_frame_hdr : { *(.eh_frame_hdr*) } : eh + .eh_frame : { *(.eh_frame) } : eh + . = 0xF00000000; + .text : { *(.text*) } : text +} + +# CHECK: error: {{.*}}:(.eh_frame+0x20): relocation R_X86_64_PC32 out of range: 64424443872 is not in [-2147483648, 2147483647] diff --git a/lld/test/ELF/linkerscript/eh-frame.s b/lld/test/ELF/linkerscript/eh-frame.s index 750f74eb36c..5e43ec738f7 100644 --- a/lld/test/ELF/linkerscript/eh-frame.s +++ b/lld/test/ELF/linkerscript/eh-frame.s @@ -1,8 +1,6 @@ # REQUIRES: x86 # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t -# RUN: echo "SECTIONS { \ -# RUN: .eh_frame : { *(.eh_frame) } \ -# RUN: }" > %t.script +# RUN: echo "SECTIONS { .eh_frame : { *(.eh_frame) } }" > %t.script # RUN: ld.lld -o %t1 --script %t.script %t # RUN: llvm-objdump -s -section=".eh_frame" %t1 | FileCheck %s diff --git a/lld/test/ELF/linkerscript/emit-reloc-section-names.s b/lld/test/ELF/linkerscript/emit-reloc-section-names.s index 8661ff060a7..7f76057322e 100644 --- a/lld/test/ELF/linkerscript/emit-reloc-section-names.s +++ b/lld/test/ELF/linkerscript/emit-reloc-section-names.s @@ -1,7 +1,6 @@ # REQUIRES: x86 # RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o -# RUN: echo "SECTIONS { .text.zed : { *(.text.foo) } \ -# RUN: .text.qux : { *(.text.bar) } }" > %t.script +# RUN: echo "SECTIONS { .text.zed : { *(.text.foo) } .text.qux : { *(.text.bar) } }" > %t.script # RUN: ld.lld -T %t.script --emit-relocs %t.o -o %t # RUN: llvm-objdump -section-headers %t | FileCheck %s diff --git a/lld/test/ELF/linkerscript/empty-load.s b/lld/test/ELF/linkerscript/empty-load.s index ea58d71402d..a2b7d8227f6 100644 --- a/lld/test/ELF/linkerscript/empty-load.s +++ b/lld/test/ELF/linkerscript/empty-load.s @@ -1,6 +1,6 @@ # REQUIRES: x86 # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t -# RUN: echo "SECTIONS { .rw : { *(.rw) } .text : { *(.text) } }" > %t.script +# RUN: echo "SECTIONS { .rw : { *(.rw) } .text : { *(.text) } }" > %t.script # RUN: ld.lld -o %t1 --script %t.script %t # RUN: llvm-objdump -private-headers %t1 | FileCheck %s diff --git a/lld/test/ELF/linkerscript/empty-tls.s b/lld/test/ELF/linkerscript/empty-tls.s index 919ccbffbe4..0ef2e7be7b3 100644 --- a/lld/test/ELF/linkerscript/empty-tls.s +++ b/lld/test/ELF/linkerscript/empty-tls.s @@ -1,14 +1,14 @@ -// 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-readobj -l %t.so | FileCheck %s +# 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-readobj -l %t.so | FileCheck %s -// test that we don't crash with an empty PT_TLS +# test that we don't crash with an empty PT_TLS -// CHECK: Type: PT_TLS -// CHECK-NEXT: Offset: 0x0 -// CHECK-NEXT: VirtualAddress: 0x0 -// CHECK-NEXT: PhysicalAddress: 0x0 -// CHECK-NEXT: FileSize: 0 -// CHECK-NEXT: MemSize: 0 +# CHECK: Type: PT_TLS +# CHECK-NEXT: Offset: 0x0 +# CHECK-NEXT: VirtualAddress: 0x0 +# CHECK-NEXT: PhysicalAddress: 0x0 +# CHECK-NEXT: FileSize: 0 +# CHECK-NEXT: MemSize: 0 diff --git a/lld/test/ELF/linkerscript/expr-sections.s b/lld/test/ELF/linkerscript/expr-sections.s deleted file mode 100644 index eb60009cd97..00000000000 --- a/lld/test/ELF/linkerscript/expr-sections.s +++ /dev/null @@ -1,22 +0,0 @@ -# REQUIRES: x86 -# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o -# RUN: echo "SECTIONS { \ -# RUN: . = . + 4; \ -# RUN: .text : { \ -# RUN: *(.text) \ -# RUN: foo1 = ADDR(.text) + 1; bar1 = 1 + ADDR(.text); \ -# RUN: foo2 = ADDR(.text) & 1; bar2 = 1 & ADDR(.text); \ -# RUN: foo3 = ADDR(.text) | 1; bar3 = 1 | ADDR(.text); \ -# RUN: } \ -# RUN: };" > %t.script -# RUN: ld.lld -o %t.so --script %t.script %t.o -shared -# RUN: llvm-objdump -t -h %t.so | FileCheck %s - -# CHECK: 1 .text 00000000 0000000000000004 TEXT DATA - -# CHECK: 0000000000000005 .text 00000000 foo1 -# CHECK: 0000000000000005 .text 00000000 bar1 -# CHECK: 0000000000000000 .text 00000000 foo2 -# CHECK: 0000000000000000 .text 00000000 bar2 -# CHECK: 0000000000000005 .text 00000000 foo3 -# CHECK: 0000000000000005 .text 00000000 bar3 diff --git a/lld/test/ELF/linkerscript/expr-sections.test b/lld/test/ELF/linkerscript/expr-sections.test new file mode 100644 index 00000000000..a9219e627b0 --- /dev/null +++ b/lld/test/ELF/linkerscript/expr-sections.test @@ -0,0 +1,23 @@ +# REQUIRES: x86 +# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux /dev/null -o %t.o +# RUN: ld.lld -o %t.so --script %s %t.o -shared +# RUN: llvm-objdump -t -h %t.so | FileCheck %s + +SECTIONS { + . = . + 4; + .text : { + *(.text) + foo1 = ADDR(.text) + 1; bar1 = 1 + ADDR(.text); + foo2 = ADDR(.text) & 1; bar2 = 1 & ADDR(.text); + foo3 = ADDR(.text) | 1; bar3 = 1 | ADDR(.text); + } +}; + +# CHECK: 1 .text 00000000 0000000000000004 TEXT DATA + +# CHECK: 0000000000000005 .text 00000000 foo1 +# CHECK: 0000000000000005 .text 00000000 bar1 +# CHECK: 0000000000000000 .text 00000000 foo2 +# CHECK: 0000000000000000 .text 00000000 bar2 +# CHECK: 0000000000000005 .text 00000000 foo3 +# CHECK: 0000000000000005 .text 00000000 bar3 diff --git a/lld/test/ELF/linkerscript/extend-pt-load.s b/lld/test/ELF/linkerscript/extend-pt-load.s deleted file mode 100644 index 72740f1092e..00000000000 --- a/lld/test/ELF/linkerscript/extend-pt-load.s +++ /dev/null @@ -1,68 +0,0 @@ -# REQUIRES: x86 -# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o - -# This test demonstrates an odd consequence of the way we handle sections with just symbol -# assignments. - -# First, run a test with no such section. - -# RUN: echo "SECTIONS { \ -# RUN: . = SIZEOF_HEADERS; \ -# RUN: .dynsym : { } \ -# RUN: .hash : { } \ -# RUN: .dynstr : { } \ -# RUN: .text : { *(.text) } \ -# RUN: . = ALIGN(0x1000); \ -# RUN: .data.rel.ro : { *(.data.rel.ro) } \ -# RUN: }" > %t.script -# RUN: ld.lld --hash-style=sysv -o %t1 --script %t.script %t.o -shared -# RUN: llvm-readobj --elf-output-style=GNU -l -s %t1 | FileCheck --check-prefix=CHECK1 %s - -# CHECK1: .text PROGBITS 00000000000001bc 0001bc 000001 00 AX -# CHECK1-NEXT: .data.rel.ro PROGBITS 0000000000001000 001000 000001 00 WA - -# CHECK1: LOAD 0x000000 0x0000000000000000 0x0000000000000000 0x0001bd 0x0001bd R E -# CHECK1-NEXT: LOAD 0x001000 0x0000000000001000 0x0000000000001000 0x000068 0x000068 RW - -# Then add the section bar. Note how bar is given AX flags, which causes the PT_LOAD to now -# cover the padding bits created by ALIGN. - -# RUN: echo "SECTIONS { \ -# RUN: . = SIZEOF_HEADERS; \ -# RUN: .dynsym : { } \ -# RUN: .hash : { } \ -# RUN: .dynstr : { } \ -# RUN: .text : { *(.text) } \ -# RUN: bar : { . = ALIGN(0x1000); } \ -# RUN: .data.rel.ro : { *(.data.rel.ro) } \ -# RUN: }" > %t.script -# RUN: ld.lld --hash-style=sysv -o %t2 --script %t.script %t.o -shared -# RUN: llvm-readobj --elf-output-style=GNU -l -s %t2 | FileCheck --check-prefix=CHECK2 %s - -# CHECK2: .text PROGBITS 00000000000001bc 0001bc 000001 00 AX -# CHECK2-NEXT: bar NOBITS 00000000000001bd 0001bd 000e43 00 AX -# CHECK2-NEXT: .data.rel.ro PROGBITS 0000000000001000 001000 000001 00 WA - -# CHECK2: LOAD 0x000000 0x0000000000000000 0x0000000000000000 0x0001bd 0x001000 R E -# CHECK2-NEXT: LOAD 0x001000 0x0000000000001000 0x0000000000001000 0x000068 0x000068 RW - -# If the current behavior becomes a problem we should consider just moving the commands out -# of the section. That is, handle the above like the following test. - -# RUN: echo "SECTIONS { \ -# RUN: . = SIZEOF_HEADERS; \ -# RUN: .dynsym : { } \ -# RUN: .hash : { } \ -# RUN: .dynstr : { } \ -# RUN: .text : { *(.text) } \ -# RUN: . = ALIGN(0x1000); \ -# RUN: HIDDEN(bar_sym = .); \ -# RUN: .data.rel.ro : { *(.data.rel.ro) } \ -# RUN: }" > %t.script -# RUN: ld.lld --hash-style=sysv -o %t3 --script %t.script %t.o -shared -# RUN: llvm-readobj --elf-output-style=GNU -l -s %t3 | FileCheck --check-prefix=CHECK1 %s - -nop - -.section .data.rel.ro, "aw" -.byte 0 diff --git a/lld/test/ELF/linkerscript/extend-pt-load1.test b/lld/test/ELF/linkerscript/extend-pt-load1.test new file mode 100644 index 00000000000..a1359eace18 --- /dev/null +++ b/lld/test/ELF/linkerscript/extend-pt-load1.test @@ -0,0 +1,23 @@ +# REQUIRES: x86 +# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/extend-pt-load.s -o %t.o +# RUN: ld.lld --hash-style=sysv -o %t1 --script %s %t.o -shared +# RUN: llvm-readobj --elf-output-style=GNU -l -s %t1 | FileCheck %s + +# This test demonstrates an odd consequence of the way we handle sections with just symbol +# assignments. + +SECTIONS { + . = SIZEOF_HEADERS; + .dynsym : {} + .hash : {} + .dynstr : {} + .text : { *(.text) } + . = ALIGN(0x1000); + .data.rel.ro : { *(.data.rel.ro) } +} + +# CHECK: .text PROGBITS 00000000000001bc 0001bc 000001 00 AX +# CHECK-NEXT: .data.rel.ro PROGBITS 0000000000001000 001000 000001 00 WA + +# CHECK: LOAD 0x000000 0x0000000000000000 0x0000000000000000 0x0001bd 0x0001bd R E +# CHECK-NEXT: LOAD 0x001000 0x0000000000001000 0x0000000000001000 0x000068 0x000068 RW diff --git a/lld/test/ELF/linkerscript/extend-pt-load2.test b/lld/test/ELF/linkerscript/extend-pt-load2.test new file mode 100644 index 00000000000..1aa943703f2 --- /dev/null +++ b/lld/test/ELF/linkerscript/extend-pt-load2.test @@ -0,0 +1,24 @@ +# REQUIRES: x86 +# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/extend-pt-load.s -o %t.o +# RUN: ld.lld --hash-style=sysv -o %t2 --script %s %t.o -shared +# RUN: llvm-readobj --elf-output-style=GNU -l -s %t2 | FileCheck %s + +# Then add the section bar. Note how bar is given AX flags, which causes the PT_LOAD to now +# cover the padding bits created by ALIGN. + +SECTIONS { + . = SIZEOF_HEADERS; + .dynsym : {} + .hash : {} + .dynstr : {} + .text : { *(.text) } + bar : { . = ALIGN(0x1000); } + .data.rel.ro : { *(.data.rel.ro) } +} + +# CHECK: .text PROGBITS 00000000000001bc 0001bc 000001 00 AX +# CHECK-NEXT: bar NOBITS 00000000000001bd 0001bd 000e43 00 AX +# CHECK-NEXT: .data.rel.ro PROGBITS 0000000000001000 001000 000001 00 WA + +# CHECK: LOAD 0x000000 0x0000000000000000 0x0000000000000000 0x0001bd 0x001000 R E +# CHECK-NEXT: LOAD 0x001000 0x0000000000001000 0x0000000000001000 0x000068 0x000068 RW diff --git a/lld/test/ELF/linkerscript/extend-pt-load3.test b/lld/test/ELF/linkerscript/extend-pt-load3.test new file mode 100644 index 00000000000..1b7ef6fdbf9 --- /dev/null +++ b/lld/test/ELF/linkerscript/extend-pt-load3.test @@ -0,0 +1,24 @@ +# REQUIRES: x86 +# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/extend-pt-load.s -o %t.o +# RUN: ld.lld --hash-style=sysv -o %t3 --script %s %t.o -shared +# RUN: llvm-readobj --elf-output-style=GNU -l -s %t3 | FileCheck --check-prefix=CHECK %s + +# If the current behavior becomes a problem we should consider just moving the commands out +# of the section. That is, handle the above like the following test. + +SECTIONS { + . = SIZEOF_HEADERS; + .dynsym : {} + .hash : {} + .dynstr : {} + .text : { *(.text) } + . = ALIGN(0x1000); + HIDDEN(bar_sym = .); + .data.rel.ro : { *(.data.rel.ro) } +} + +# CHECK: .text PROGBITS 00000000000001bc 0001bc 000001 00 AX +# CHECK-NEXT: .data.rel.ro PROGBITS 0000000000001000 001000 000001 00 WA + +# CHECK: LOAD 0x000000 0x0000000000000000 0x0000000000000000 0x0001bd 0x0001bd R E +# CHECK-NEXT: LOAD 0x001000 0x0000000000001000 0x0000000000001000 0x000068 0x000068 RW
\ No newline at end of file diff --git a/lld/test/ELF/linkerscript/filename-spec.s b/lld/test/ELF/linkerscript/filename-spec.s index ada8c3c2c84..66fd4178387 100644 --- a/lld/test/ELF/linkerscript/filename-spec.s +++ b/lld/test/ELF/linkerscript/filename-spec.s @@ -1,55 +1,43 @@ # REQUIRES: x86 -# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %tfirst.o +# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %tx.o # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux \ -# RUN: %p/Inputs/filename-spec.s -o %tsecond.o +# RUN: %p/Inputs/filename-spec.s -o %ty.o -# RUN: echo "SECTIONS { .foo : { \ -# RUN: KEEP(*first.o(.foo)) \ -# RUN: KEEP(*second.o(.foo)) } }" > %t1.script -# RUN: ld.lld -o %t1 --script %t1.script %tfirst.o %tsecond.o -# RUN: llvm-objdump -s %t1 | FileCheck --check-prefix=FIRSTSECOND %s -# FIRSTSECOND: Contents of section .foo: -# FIRSTSECOND-NEXT: 01000000 00000000 11000000 00000000 +# RUN: echo "SECTIONS{.foo :{ KEEP(*x.o(.foo)) KEEP(*y.o(.foo)) }}" > %t1.script +# RUN: ld.lld -o %t1 --script %t1.script %tx.o %ty.o +# RUN: llvm-objdump -s %t1 | FileCheck --check-prefix=FIRSTY %s +# FIRSTY: Contents of section .foo: +# FIRSTY-NEXT: 01000000 00000000 11000000 00000000 -# RUN: echo "SECTIONS { .foo : { \ -# RUN: KEEP(*second.o(.foo)) \ -# RUN: KEEP(*first.o(.foo)) } }" > %t2.script -# RUN: ld.lld -o %t2 --script %t2.script %tfirst.o %tsecond.o +# RUN: echo "SECTIONS{.foo :{ KEEP(*y.o(.foo)) KEEP(*x.o(.foo)) }}" > %t2.script +# RUN: ld.lld -o %t2 --script %t2.script %tx.o %ty.o # RUN: llvm-objdump -s %t2 | FileCheck --check-prefix=SECONDFIRST %s # SECONDFIRST: Contents of section .foo: # SECONDFIRST-NEXT: 11000000 00000000 01000000 00000000 ## Now the same tests but without KEEP. Checking that file name inside ## KEEP is parsed fine. -# RUN: echo "SECTIONS { .foo : { \ -# RUN: *first.o(.foo) \ -# RUN: *second.o(.foo) } }" > %t3.script -# RUN: ld.lld -o %t3 --script %t3.script %tfirst.o %tsecond.o -# RUN: llvm-objdump -s %t3 | FileCheck --check-prefix=FIRSTSECOND %s +# RUN: echo "SECTIONS{.foo :{ *x.o(.foo) *y.o(.foo) }}" > %t3.script +# RUN: ld.lld -o %t3 --script %t3.script %tx.o %ty.o +# RUN: llvm-objdump -s %t3 | FileCheck --check-prefix=FIRSTY %s -# RUN: echo "SECTIONS { .foo : { \ -# RUN: *second.o(.foo) \ -# RUN: *first.o(.foo) } }" > %t4.script -# RUN: ld.lld -o %t4 --script %t4.script %tfirst.o %tsecond.o +# RUN: echo "SECTIONS{.foo :{ *y.o(.foo) *x.o(.foo) }}" > %t4.script +# RUN: ld.lld -o %t4 --script %t4.script %tx.o %ty.o # RUN: llvm-objdump -s %t4 | FileCheck --check-prefix=SECONDFIRST %s # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %T/filename-spec1.o # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux \ # RUN: %p/Inputs/filename-spec.s -o %T/filename-spec2.o -# RUN: echo "SECTIONS { .foo : { \ -# RUN: %T/filename-spec2.o(.foo) \ -# RUN: %T/filename-spec1.o(.foo) } }" > %t5.script +# RUN: echo "SECTIONS{.foo :{ %T/filename-spec2.o(.foo) %T/filename-spec1.o(.foo) }}" > %t5.script # RUN: ld.lld -o %t5 --script %t5.script \ # RUN: %T/filename-spec1.o %T/filename-spec2.o # RUN: llvm-objdump -s %t5 | FileCheck --check-prefix=SECONDFIRST %s -# RUN: echo "SECTIONS { .foo : { \ -# RUN: %T/filename-spec1.o(.foo) \ -# RUN: %T/filename-spec2.o(.foo) } }" > %t6.script +# RUN: echo "SECTIONS{.foo :{ %T/filename-spec1.o(.foo) %T/filename-spec2.o(.foo) }}" > %t6.script # RUN: ld.lld -o %t6 --script %t6.script \ # RUN: %T/filename-spec1.o %T/filename-spec2.o -# RUN: llvm-objdump -s %t6 | FileCheck --check-prefix=FIRSTSECOND %s +# RUN: llvm-objdump -s %t6 | FileCheck --check-prefix=FIRSTY %s # RUN: mkdir -p %t.testdir1 %t.testdir2 # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.testdir1/filename-spec1.o @@ -59,33 +47,25 @@ # RUN: llvm-ar rsc %t.testdir2/lib2.a %t.testdir2/filename-spec2.o # Verify matching of archive library names. -# RUN: echo "SECTIONS { .foo : { \ -# RUN: *lib2*(.foo) \ -# RUN: *lib1*(.foo) } }" > %t7.script +# RUN: echo "SECTIONS{.foo :{ *lib2*(.foo) *lib1*(.foo) }}" > %t7.script # RUN: ld.lld -o %t7 --script %t7.script --whole-archive \ # RUN: %t.testdir1/lib1.a %t.testdir2/lib2.a # RUN: llvm-objdump -s %t7 | FileCheck --check-prefix=SECONDFIRST %s # Verify matching directories. -# RUN: echo "SECTIONS { .foo : { \ -# RUN: *testdir2*(.foo) \ -# RUN: *testdir1*(.foo) } }" > %t8.script +# RUN: echo "SECTIONS{.foo :{ *testdir2*(.foo) *testdir1*(.foo) }}" > %t8.script # RUN: ld.lld -o %t8 --script %t8.script --whole-archive \ # RUN: %t.testdir1/lib1.a %t.testdir2/lib2.a # RUN: llvm-objdump -s %t8 | FileCheck --check-prefix=SECONDFIRST %s # Verify matching of archive library names in KEEP. -# RUN: echo "SECTIONS { .foo : { \ -# RUN: KEEP(*lib2*(.foo)) \ -# RUN: KEEP(*lib1*(.foo)) } }" > %t9.script +# RUN: echo "SECTIONS{.foo :{ KEEP(*lib2*(.foo)) KEEP(*lib1*(.foo)) }}" > %t9.script # RUN: ld.lld -o %t9 --script %t9.script --whole-archive \ # RUN: %t.testdir1/lib1.a %t.testdir2/lib2.a # RUN: llvm-objdump -s %t9 | FileCheck --check-prefix=SECONDFIRST %s # Verify matching directories in KEEP. -# RUN: echo "SECTIONS { .foo : { \ -# RUN: KEEP(*testdir2*(.foo)) \ -# RUN: KEEP(*testdir1*(.foo)) } }" > %t10.script +# RUN: echo "SECTIONS{.foo :{ KEEP(*testdir2*(.foo)) KEEP(*testdir1*(.foo)) }}" > %t10.script # RUN: ld.lld -o %t10 --script %t10.script --whole-archive \ # RUN: %t.testdir1/lib1.a %t.testdir2/lib2.a # RUN: llvm-objdump -s %t10 | FileCheck --check-prefix=SECONDFIRST %s diff --git a/lld/test/ELF/linkerscript/fill.s b/lld/test/ELF/linkerscript/fill.s deleted file mode 100644 index 604506084a7..00000000000 --- a/lld/test/ELF/linkerscript/fill.s +++ /dev/null @@ -1,31 +0,0 @@ -# REQUIRES: x86 -# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o -# RUN: echo "SECTIONS { \ -# RUN: .out : { \ -# RUN: FILL(0x11111111) \ -# RUN: . += 2; \ -# RUN: *(.aaa) \ -# RUN: . += 4; \ -# RUN: *(.bbb) \ -# RUN: . += 4; \ -# RUN: FILL(0x22222222); \ -# RUN: . += 4; \ -# RUN: } \ -# RUN: }; " > %t.script -# RUN: ld.lld -o %t --script %t.script %t.o -# RUN: llvm-objdump -s %t | FileCheck %s - -# CHECK: Contents of section .out: -# CHECK-NEXT: 2222aa22 222222bb 22222222 22222222 - -.text -.globl _start -_start: - -.section .aaa, "a" -.align 1 -.byte 0xAA - -.section .bbb, "a" -.align 1 -.byte 0xBB diff --git a/lld/test/ELF/linkerscript/fill.test b/lld/test/ELF/linkerscript/fill.test new file mode 100644 index 00000000000..5bf295ec9c1 --- /dev/null +++ b/lld/test/ELF/linkerscript/fill.test @@ -0,0 +1,20 @@ +# REQUIRES: x86 +# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/fill.s -o %t.o +# RUN: ld.lld -o %t --script %s %t.o +# RUN: llvm-objdump -s %t | FileCheck %s + +SECTIONS { + .out : { + FILL(0x11111111) + . += 2; + *(.aaa) + . += 4; + *(.bbb) + . += 4; + FILL(0x22222222); + . += 4; + } +} + +# CHECK: Contents of section .out: +# CHECK-NEXT: 2222aa22 222222bb 22222222 22222222 |