Convert more tests as linker scripts instead of assembly.

llvm-svn: 326415
This commit is contained in:
Rui Ueyama 2018-03-01 04:21:42 +00:00
parent a32e84133a
commit 05660daced
36 changed files with 445 additions and 491 deletions

View File

@ -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

View File

@ -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

View File

@ -0,0 +1,8 @@
.global defined
defined = 0
.section .foo,"a"
.quad 1
.section .bar,"a"
.quad 1

View File

@ -0,0 +1,11 @@
.text
.globl _start
_start:
.cfi_startproc
.cfi_lsda 0, _ex
nop
.cfi_endproc
.data
_ex:
.word 0

View File

@ -0,0 +1,3 @@
nop
.section .data.rel.ro, "aw"
.byte 0

View File

@ -0,0 +1,11 @@
.text
.globl _start
_start:
.section .aaa, "a"
.align 1
.byte 0xAA
.section .bbb, "a"
.align 1
.byte 0xBB

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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: >>> ^

View File

@ -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: >>> ^

View File

@ -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: >>> ^

View File

@ -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: >>> ^

View File

@ -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: >>> ^

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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]

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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