mirror of
https://github.com/intel/llvm.git
synced 2026-01-25 09:13:38 +08:00
[ELF] - Represent tests as linker scripts instead of asm.
This follows recently started direction and sometimes allows to fully get rid from `echo` calls. I'll rename changed files to *.test in a follow-up. llvm-svn: 327410
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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) }
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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) }
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
};
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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 [
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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) }
|
||||
}
|
||||
|
||||
@@ -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 = .;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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 = .;
|
||||
}
|
||||
|
||||
@@ -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) }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user