summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRui Ueyama <ruiu@google.com>2018-03-01 01:19:12 +0000
committerRui Ueyama <ruiu@google.com>2018-03-01 01:19:12 +0000
commitdc32dc1770d0cc3efec93dac1a9695acde02699e (patch)
tree96a21d969bf8e1009ce1d689f32e0eab91f6bb9b
parent6603052235bd64d8682ea529d7e16b5674f0bde8 (diff)
downloadbcm5719-llvm-dc32dc1770d0cc3efec93dac1a9695acde02699e.tar.gz
bcm5719-llvm-dc32dc1770d0cc3efec93dac1a9695acde02699e.zip
Convert more .s files to linker script files.
Summary: This change removes large "echo" commands from the test by writing tests themselves as linker scripts. Reviewers: rafael Subscribers: emaste, javed.absar, llvm-commits, arichardson Differential Revision: https://reviews.llvm.org/D43900 llvm-svn: 326403
-rw-r--r--lld/test/ELF/linkerscript/Inputs/addr.s12
-rw-r--r--lld/test/ELF/linkerscript/Inputs/align.s13
-rw-r--r--lld/test/ELF/linkerscript/Inputs/alignof.s15
-rw-r--r--lld/test/ELF/linkerscript/Inputs/at2.s14
-rw-r--r--lld/test/ELF/linkerscript/Inputs/at3.s8
-rw-r--r--lld/test/ELF/linkerscript/Inputs/synthetic-symbols.s16
-rw-r--r--lld/test/ELF/linkerscript/addr-zero.test (renamed from lld/test/ELF/linkerscript/addr-zero.s)9
-rw-r--r--lld/test/ELF/linkerscript/addr.test (renamed from lld/test/ELF/linkerscript/addr.s)30
-rw-r--r--lld/test/ELF/linkerscript/align-section-offset.s11
-rw-r--r--lld/test/ELF/linkerscript/align-section-offset.test12
-rw-r--r--lld/test/ELF/linkerscript/align-section.s6
-rw-r--r--lld/test/ELF/linkerscript/align-section.test7
-rw-r--r--lld/test/ELF/linkerscript/align.s125
-rw-r--r--lld/test/ELF/linkerscript/align1.test44
-rw-r--r--lld/test/ELF/linkerscript/align2.test20
-rw-r--r--lld/test/ELF/linkerscript/align3.test18
-rw-r--r--lld/test/ELF/linkerscript/align4.test25
-rw-r--r--lld/test/ELF/linkerscript/align5.test23
-rw-r--r--lld/test/ELF/linkerscript/alignof.s41
-rw-r--r--lld/test/ELF/linkerscript/alignof.test24
-rw-r--r--lld/test/ELF/linkerscript/arm-exidx-order.s19
-rw-r--r--lld/test/ELF/linkerscript/arm-exidx-order.test19
-rw-r--r--lld/test/ELF/linkerscript/arm-exidx-phdrs.s16
-rw-r--r--lld/test/ELF/linkerscript/arm-exidx-phdrs.test13
-rw-r--r--lld/test/ELF/linkerscript/arm-lscript.s9
-rw-r--r--lld/test/ELF/linkerscript/arm-lscript.test11
-rw-r--r--lld/test/ELF/linkerscript/at2.s81
-rw-r--r--lld/test/ELF/linkerscript/at2.test58
-rw-r--r--lld/test/ELF/linkerscript/at3.s38
-rw-r--r--lld/test/ELF/linkerscript/at3.test31
-rw-r--r--lld/test/ELF/linkerscript/at5.test14
-rw-r--r--lld/test/ELF/linkerscript/symbols-synthetic.s98
-rw-r--r--lld/test/ELF/linkerscript/synthetic-symbols1.test56
-rw-r--r--lld/test/ELF/linkerscript/synthetic-symbols2.test13
-rw-r--r--lld/test/ELF/linkerscript/synthetic-symbols3.test11
-rw-r--r--lld/test/ELF/linkerscript/synthetic-symbols4.test14
36 files changed, 506 insertions, 468 deletions
diff --git a/lld/test/ELF/linkerscript/Inputs/addr.s b/lld/test/ELF/linkerscript/Inputs/addr.s
new file mode 100644
index 00000000000..65d99dcf99c
--- /dev/null
+++ b/lld/test/ELF/linkerscript/Inputs/addr.s
@@ -0,0 +1,12 @@
+.text
+.globl _start
+_start:
+
+.section .foo.1,"a"
+.quad 1
+
+.section .foo.2,"a"
+.quad 2
+
+.section .foo.3,"a"
+.quad 3
diff --git a/lld/test/ELF/linkerscript/Inputs/align.s b/lld/test/ELF/linkerscript/Inputs/align.s
new file mode 100644
index 00000000000..c804536aa54
--- /dev/null
+++ b/lld/test/ELF/linkerscript/Inputs/align.s
@@ -0,0 +1,13 @@
+.global _start
+_start:
+ nop
+
+.section .aaa, "a"
+.quad 0
+
+.section .bbb, "a"
+.quad 0
+
+.section .ccc, "a"
+.quad 0
+
diff --git a/lld/test/ELF/linkerscript/Inputs/alignof.s b/lld/test/ELF/linkerscript/Inputs/alignof.s
new file mode 100644
index 00000000000..b288f94a12c
--- /dev/null
+++ b/lld/test/ELF/linkerscript/Inputs/alignof.s
@@ -0,0 +1,15 @@
+.global _start
+_start:
+ nop
+
+.section .aaa,"a"
+ .align 8
+ .quad 0
+
+.section .bbb,"a"
+ .align 16
+ .quad 0
+
+.section .ccc,"a"
+ .align 32
+ .quad 0
diff --git a/lld/test/ELF/linkerscript/Inputs/at2.s b/lld/test/ELF/linkerscript/Inputs/at2.s
new file mode 100644
index 00000000000..8c6548b53f6
--- /dev/null
+++ b/lld/test/ELF/linkerscript/Inputs/at2.s
@@ -0,0 +1,14 @@
+.section .foo1, "ax"
+.quad 0
+
+.section .foo2, "ax"
+.quad 0
+
+.section .bar1, "aw"
+.quad 0
+
+.section .bar2, "aw"
+.quad 0
+
+.section .bar3, "aw"
+.quad 0
diff --git a/lld/test/ELF/linkerscript/Inputs/at3.s b/lld/test/ELF/linkerscript/Inputs/at3.s
new file mode 100644
index 00000000000..8005c75723d
--- /dev/null
+++ b/lld/test/ELF/linkerscript/Inputs/at3.s
@@ -0,0 +1,8 @@
+.section .foo1, "a"
+.quad 0
+
+.section .foo2, "ax"
+.quad 0
+
+.section .foo3, "ax"
+.quad 0
diff --git a/lld/test/ELF/linkerscript/Inputs/synthetic-symbols.s b/lld/test/ELF/linkerscript/Inputs/synthetic-symbols.s
new file mode 100644
index 00000000000..670e65cb80f
--- /dev/null
+++ b/lld/test/ELF/linkerscript/Inputs/synthetic-symbols.s
@@ -0,0 +1,16 @@
+.global _start
+_start:
+ nop
+
+.section .foo,"a"
+ .quad 0
+
+.section .bar,"a"
+ .long 0
+
+.section .dah,"ax",@progbits
+ .cfi_startproc
+ nop
+ .cfi_endproc
+
+.global _begin_sec, _end_sec, _end_sec_abs
diff --git a/lld/test/ELF/linkerscript/addr-zero.s b/lld/test/ELF/linkerscript/addr-zero.test
index 71251d3acff..77adebc1ecc 100644
--- a/lld/test/ELF/linkerscript/addr-zero.s
+++ b/lld/test/ELF/linkerscript/addr-zero.test
@@ -1,7 +1,6 @@
# REQUIRES: x86
-# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o
-# RUN: echo "SECTIONS { foo = ADDR(.text) - ABSOLUTE(ADDR(.text)); };" > %t.script
-# RUN: ld.lld -o %t.so --script %t.script %t.o -shared
+# 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-readobj --symbols %t.so | FileCheck %s
# Test that the script creates a non absolute symbol with value
@@ -16,3 +15,7 @@
# CHECK-NEXT: Other: 0
# CHECK-NEXT: Section: .text
# CHECK-NEXT: }
+
+SECTIONS {
+ foo = ADDR(.text) - ABSOLUTE(ADDR(.text));
+};
diff --git a/lld/test/ELF/linkerscript/addr.s b/lld/test/ELF/linkerscript/addr.test
index 2d3a7ab3576..bacb842e747 100644
--- a/lld/test/ELF/linkerscript/addr.s
+++ b/lld/test/ELF/linkerscript/addr.test
@@ -1,13 +1,6 @@
# REQUIRES: x86
-# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
-# RUN: echo "SECTIONS { \
-# RUN: . = 0x1000; \
-# RUN: .text : { *(.text*) } \
-# RUN: .foo.1 : { *(.foo.1) } \
-# RUN: .foo.2 ADDR(.foo.1) + 0x100 : { *(.foo.2) } \
-# RUN: .foo.3 : { *(.foo.3) } \
-# RUN: }" > %t.script
-# RUN: ld.lld %t --script %t.script -o %t1
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/addr.s -o %t
+# RUN: ld.lld %t --script %s -o %t1
# RUN: llvm-objdump -section-headers %t1 | FileCheck %s
# CHECK: Sections:
@@ -18,15 +11,10 @@
# CHECK-NEXT: 3 .foo.2 00000008 0000000000001100 DATA
# CHECK-NEXT: 4 .foo.3 00000008 0000000000001108 DATA
-.text
-.globl _start
-_start:
-
-.section .foo.1,"a"
- .quad 1
-
-.section .foo.2,"a"
- .quad 2
-
-.section .foo.3,"a"
- .quad 3
+SECTIONS {
+ . = 0x1000;
+ .text : { *(.text*) }
+ .foo.1 : { *(.foo.1) }
+ .foo.2 ADDR(.foo.1) + 0x100 : { *(.foo.2) }
+ .foo.3 : { *(.foo.3) }
+}
diff --git a/lld/test/ELF/linkerscript/align-section-offset.s b/lld/test/ELF/linkerscript/align-section-offset.s
deleted file mode 100644
index 9c1603a1985..00000000000
--- a/lld/test/ELF/linkerscript/align-section-offset.s
+++ /dev/null
@@ -1,11 +0,0 @@
-# REQUIRES: x86
-# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
-# RUN: echo "SECTIONS { .foo : ALIGN(2M) { *(.foo) } }" > %t.script
-# RUN: ld.lld -o %t --script %t.script %t.o -shared
-# RUN: llvm-readelf -S -l %t | FileCheck %s
-
-# CHECK: .foo PROGBITS 0000000000200000 200000 000008 00 WA 0 0 2097152
-# CHECK: LOAD 0x200000 0x0000000000200000 0x0000000000200000 {{.*}} RW 0x200000
-
- .section .foo, "aw"
- .quad 42
diff --git a/lld/test/ELF/linkerscript/align-section-offset.test b/lld/test/ELF/linkerscript/align-section-offset.test
new file mode 100644
index 00000000000..66508c472e9
--- /dev/null
+++ b/lld/test/ELF/linkerscript/align-section-offset.test
@@ -0,0 +1,12 @@
+# REQUIRES: x86
+# RUN: echo '.section .foo, "aw"; .quad 42' \
+# RUN: | llvm-mc -filetype=obj -triple=x86_64-pc-linux - -o %t.o
+# RUN: ld.lld -o %t --script %s %t.o -shared
+# RUN: llvm-readelf -S -l %t | FileCheck %s
+
+SECTIONS {
+ .foo : ALIGN(2M) { *(.foo) }
+}
+
+# CHECK: .foo PROGBITS 0000000000200000 200000 000008 00 WA 0 0 2097152
+# CHECK: LOAD 0x200000 0x0000000000200000 0x0000000000200000 {{.*}} RW 0x200000
diff --git a/lld/test/ELF/linkerscript/align-section.s b/lld/test/ELF/linkerscript/align-section.s
deleted file mode 100644
index d26f15c8732..00000000000
--- a/lld/test/ELF/linkerscript/align-section.s
+++ /dev/null
@@ -1,6 +0,0 @@
-# REQUIRES: x86
-# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
-# RUN: echo "SECTIONS { .foo : ALIGN(2M) { } }" > %t.script
-# RUN: ld.lld -o %t --script %t.script %t.o -shared
-
-# We would crash if an empty section had an ALIGN.
diff --git a/lld/test/ELF/linkerscript/align-section.test b/lld/test/ELF/linkerscript/align-section.test
new file mode 100644
index 00000000000..7a28fef2076
--- /dev/null
+++ b/lld/test/ELF/linkerscript/align-section.test
@@ -0,0 +1,7 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux /dev/null -o %t.o
+# RUN: ld.lld -o %t --script %s %t.o -shared
+
+# lld shouldn't crash.
+
+SECTIONS { .foo : ALIGN(2M) {} }
diff --git a/lld/test/ELF/linkerscript/align.s b/lld/test/ELF/linkerscript/align.s
deleted file mode 100644
index 99e7382daa5..00000000000
--- a/lld/test/ELF/linkerscript/align.s
+++ /dev/null
@@ -1,125 +0,0 @@
-# REQUIRES: x86
-# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
-
-## Check that ALIGN command workable using location counter
-# RUN: echo "SECTIONS { \
-# RUN: . = 0x10000; \
-# RUN: .aaa : { *(.aaa) } \
-# RUN: . = ALIGN(4096); \
-# RUN: .bbb : { *(.bbb) } \
-# RUN: . = ALIGN(4096 * 4); \
-# RUN: .ccc : { *(.ccc) } \
-# RUN: }" > %t.script
-# RUN: ld.lld -o %t1 --script %t.script %t
-# RUN: llvm-objdump -section-headers %t1 | FileCheck %s
-
-## Check that the two argument version of ALIGN command works
-# RUN: echo "SECTIONS { \
-# RUN: . = ALIGN(0x1234, 0x10000); \
-# RUN: .aaa : { *(.aaa) } \
-# RUN: . = ALIGN(., 4096); \
-# RUN: .bbb : { *(.bbb) } \
-# RUN: . = ALIGN(., 4096 * 4); \
-# RUN: .ccc : { *(.ccc) } \
-# RUN: }" > %t.script
-# RUN: ld.lld -o %t1 --script %t.script %t
-# RUN: llvm-objdump -section-headers %t1 | FileCheck %s
-
-# CHECK: Sections:
-# CHECK-NEXT: Idx Name Size Address Type
-# CHECK-NEXT: 0 00000000 0000000000000000
-# CHECK-NEXT: 1 .aaa 00000008 0000000000010000 DATA
-# CHECK-NEXT: 2 .bbb 00000008 0000000000011000 DATA
-# CHECK-NEXT: 3 .ccc 00000008 0000000000014000 DATA
-
-## Check output sections ALIGN modificator
-# RUN: echo "SECTIONS { \
-# RUN: . = 0x10000; \
-# RUN: .aaa : { *(.aaa) } \
-# RUN: .bbb : ALIGN(4096) { *(.bbb) } \
-# RUN: .ccc : ALIGN(4096 * 4) { *(.ccc) } \
-# RUN: }" > %t2.script
-# RUN: ld.lld -o %t2 --script %t2.script %t
-# RUN: llvm-objdump -section-headers %t2 | FileCheck %s
-
-## Check use of variables in align expressions:
-# RUN: echo "VAR = 0x1000; \
-# RUN: __code_base__ = 0x10000; \
-# RUN: SECTIONS { \
-# RUN: . = __code_base__; \
-# RUN: .aaa : { *(.aaa) } \
-# RUN: .bbb : ALIGN(VAR) { *(.bbb) } \
-# RUN: . = ALIGN(., VAR * 4); \
-# RUN: .ccc : { *(.ccc) } \
-# RUN: __start_bbb = ADDR(.bbb); \
-# RUN: __end_bbb = ALIGN(__start_bbb + SIZEOF(.bbb), VAR); \
-# RUN: }" > %t3.script
-# RUN: ld.lld -o %t3 --script %t3.script %t
-# RUN: llvm-objdump -section-headers %t3 | FileCheck %s
-# RUN: llvm-objdump -t %t3 | FileCheck -check-prefix SYMBOLS %s
-
-# SYMBOLS-LABEL: SYMBOL TABLE:
-# SYMBOLS-NEXT: 0000000000000000 *UND* 00000000
-# SYMBOLS-NEXT: 0000000000014008 .text 00000000 _start
-# SYMBOLS-NEXT: 0000000000010000 *ABS* 00000000 __code_base__
-# SYMBOLS-NEXT: 0000000000001000 *ABS* 00000000 VAR
-# SYMBOLS-NEXT: 0000000000011000 .bbb 00000000 __start_bbb
-# SYMBOLS-NEXT: 0000000000012000 .bbb 00000000 __end_bbb
-
-## Check that ALIGN zero do nothing and does not crash #1.
-# RUN: echo "SECTIONS { . = ALIGN(0x123, 0); .aaa : { *(.aaa) } }" > %t.script
-# RUN: ld.lld -o %t4 --script %t.script %t
-# RUN: llvm-objdump -section-headers %t4 | FileCheck %s -check-prefix=ZERO
-
-# ZERO: Sections:
-# ZERO-NEXT: Idx Name Size Address Type
-# ZERO-NEXT: 0 00000000 0000000000000000
-# ZERO-NEXT: 1 .aaa 00000008 0000000000000123 DATA
-
-## Check that ALIGN zero do nothing and does not crash #2.
-# RUN: echo "SECTIONS { . = 0x123; . = ALIGN(0); .aaa : { *(.aaa) } }" > %t.script
-# RUN: ld.lld -o %t5 --script %t.script %t
-# RUN: llvm-objdump -section-headers %t5 | FileCheck %s -check-prefix=ZERO
-
-## Test we fail gracefuly when alignment value is not a power of 2 (#1).
-# RUN: echo "SECTIONS { . = 0x123; . = ALIGN(0x123, 3); .aaa : { *(.aaa) } }" > %t.script
-# RUN: not ld.lld -o %t6 --script %t.script %t 2>&1 | FileCheck -check-prefix=ERR %s
-# ERR: {{.*}}.script:1: alignment must be power of 2
-
-## Test we fail gracefuly when alignment value is not a power of 2 (#2).
-# RUN: echo "SECTIONS { . = 0x123; . = ALIGN(3); .aaa : { *(.aaa) } }" > %t.script
-# RUN: not ld.lld -o %t7 --script %t.script %t 2>&1 | FileCheck -check-prefix=ERR %s
-
-# RUN: echo "SECTIONS { \
-# RUN: . = 0xff8; \
-# RUN: .aaa : { \
-# RUN: *(.aaa) \
-# RUN: foo = ALIGN(., 0x100); \
-# RUN: bar = .; \
-# RUN: zed1 = ALIGN(., 0x100) + 1; \
-# RUN: zed2 = ALIGN(., 0x100) - 1; \
-# RUN: } \
-# RUN: .bbb : { *(.bbb); } \
-# RUN: .ccc : { *(.ccc); } \
-# RUN: .text : { *(.text); } \
-# RUN: }" > %t.script
-# RUN: ld.lld -o %t1 --script %t.script %t
-# RUN: llvm-objdump -t %t1 | FileCheck --check-prefix=OFFSET %s
-
-# OFFSET: 0000000000001000 .aaa 00000000 foo
-# OFFSET: 0000000000001000 .aaa 00000000 bar
-# OFFSET: 0000000000001001 .aaa 00000000 zed1
-# OFFSET: 0000000000000fff .aaa 00000000 zed2
-
-.global _start
-_start:
- nop
-
-.section .aaa, "a"
-.quad 0
-
-.section .bbb, "a"
-.quad 0
-
-.section .ccc, "a"
-.quad 0
diff --git a/lld/test/ELF/linkerscript/align1.test b/lld/test/ELF/linkerscript/align1.test
new file mode 100644
index 00000000000..5804bf93374
--- /dev/null
+++ b/lld/test/ELF/linkerscript/align1.test
@@ -0,0 +1,44 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/align.s -o %t.o
+# RUN: ld.lld -o %t --script %s %t.o
+# RUN: llvm-objdump -section-headers %t | FileCheck %s
+
+SECTIONS {
+ . = 0x10000;
+ .aaa : { *(.aaa) }
+ . = ALIGN(4096);
+ .bbb : { *(.bbb) }
+ . = ALIGN(4096 * 4);
+ .ccc : { *(.ccc) }
+}
+
+# CHECK: Sections:
+# CHECK-NEXT: Idx Name Size Address Type
+# CHECK-NEXT: 0 00000000 0000000000000000
+# CHECK-NEXT: 1 .aaa 00000008 0000000000010000 DATA
+# CHECK-NEXT: 2 .bbb 00000008 0000000000011000 DATA
+# CHECK-NEXT: 3 .ccc 00000008 0000000000014000 DATA
+
+## Check that ALIGN zero do nothing and does not crash #1.
+# RUN: echo "SECTIONS { . = ALIGN(0x123, 0); .aaa : { *(.aaa) } }" > %t.script
+# RUN: ld.lld -o %t4 --script %t.script %t.o
+# RUN: llvm-objdump -section-headers %t4 | FileCheck %s -check-prefix=ZERO
+
+# ZERO: Sections:
+# ZERO-NEXT: Idx Name Size Address Type
+# ZERO-NEXT: 0 00000000 0000000000000000
+# ZERO-NEXT: 1 .aaa 00000008 0000000000000123 DATA
+
+## Check that ALIGN zero do nothing and does not crash #2.
+# RUN: echo "SECTIONS { . = 0x123; . = ALIGN(0); .aaa : { *(.aaa) } }" > %t.script
+# RUN: ld.lld -o %t5 --script %t.script %t.o
+# RUN: llvm-objdump -section-headers %t5 | FileCheck %s -check-prefix=ZERO
+
+## Test we fail gracefuly when alignment value is not a power of 2 (#1).
+# RUN: echo "SECTIONS { . = 0x123; . = ALIGN(0x123, 3); .aaa : { *(.aaa) } }" > %t.script
+# RUN: not ld.lld -o %t6 --script %t.script %t.o 2>&1 | FileCheck -check-prefix=ERR %s
+
+# RUN: echo "SECTIONS { . = 0x123; . = ALIGN(3); .aaa : { *(.aaa) } }" > %t.script
+# RUN: not ld.lld -o %t7 --script %t.script %t.o 2>&1 | FileCheck -check-prefix=ERR %s
+
+# ERR: {{.*}}.script:1: alignment must be power of 2
diff --git a/lld/test/ELF/linkerscript/align2.test b/lld/test/ELF/linkerscript/align2.test
new file mode 100644
index 00000000000..a9003a403d7
--- /dev/null
+++ b/lld/test/ELF/linkerscript/align2.test
@@ -0,0 +1,20 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/align.s -o %t.o
+# RUN: ld.lld -o %t --script %s %t.o
+# RUN: llvm-objdump -section-headers %t | FileCheck %s
+
+SECTIONS {
+ . = ALIGN(0x1234, 0x10000);
+ .aaa : { *(.aaa) }
+ . = ALIGN(., 4096);
+ .bbb : { *(.bbb) }
+ . = ALIGN(., 4096 * 4);
+ .ccc : { *(.ccc) }
+}
+
+# CHECK: Sections:
+# CHECK-NEXT: Idx Name Size Address Type
+# CHECK-NEXT: 0 00000000 0000000000000000
+# CHECK-NEXT: 1 .aaa 00000008 0000000000010000 DATA
+# CHECK-NEXT: 2 .bbb 00000008 0000000000011000 DATA
+# CHECK-NEXT: 3 .ccc 00000008 0000000000014000 DATA
diff --git a/lld/test/ELF/linkerscript/align3.test b/lld/test/ELF/linkerscript/align3.test
new file mode 100644
index 00000000000..2a091fcbd6b
--- /dev/null
+++ b/lld/test/ELF/linkerscript/align3.test
@@ -0,0 +1,18 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/align.s -o %t.o
+# RUN: ld.lld -o %t --script %s %t.o
+# RUN: llvm-objdump -section-headers %t | FileCheck %s
+
+SECTIONS {
+ . = 0x10000;
+ .aaa : { *(.aaa) }
+ .bbb : ALIGN(4096) { *(.bbb) }
+ .ccc : ALIGN(4096 * 4) { *(.ccc) }
+}
+
+# CHECK: Sections:
+# CHECK-NEXT: Idx Name Size Address Type
+# CHECK-NEXT: 0 00000000 0000000000000000
+# CHECK-NEXT: 1 .aaa 00000008 0000000000010000 DATA
+# CHECK-NEXT: 2 .bbb 00000008 0000000000011000 DATA
+# CHECK-NEXT: 3 .ccc 00000008 0000000000014000 DATA
diff --git a/lld/test/ELF/linkerscript/align4.test b/lld/test/ELF/linkerscript/align4.test
new file mode 100644
index 00000000000..9440d60f638
--- /dev/null
+++ b/lld/test/ELF/linkerscript/align4.test
@@ -0,0 +1,25 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/align.s -o %t.o
+# RUN: ld.lld -o %t --script %s %t.o
+# RUN: llvm-objdump -t %t | FileCheck %s
+
+# CHECK-LABEL: SYMBOL TABLE:
+# CHECK-NEXT: 0000000000000000 *UND* 00000000
+# CHECK-NEXT: 0000000000014008 .text 00000000 _start
+# CHECK-NEXT: 0000000000010000 *ABS* 00000000 __code_base__
+# CHECK-NEXT: 0000000000001000 *ABS* 00000000 VAR
+# CHECK-NEXT: 0000000000011000 .bbb 00000000 __start_bbb
+# CHECK-NEXT: 0000000000012000 .bbb 00000000 __end_bbb
+
+VAR = 0x1000;
+__code_base__ = 0x10000;
+
+SECTIONS {
+ . = __code_base__;
+ .aaa : { *(.aaa) }
+ .bbb : ALIGN(VAR) { *(.bbb) }
+ . = ALIGN(., VAR * 4);
+ .ccc : { *(.ccc) }
+ __start_bbb = ADDR(.bbb);
+ __end_bbb = ALIGN(__start_bbb + SIZEOF(.bbb), VAR);
+}
diff --git a/lld/test/ELF/linkerscript/align5.test b/lld/test/ELF/linkerscript/align5.test
new file mode 100644
index 00000000000..47b5c8c0349
--- /dev/null
+++ b/lld/test/ELF/linkerscript/align5.test
@@ -0,0 +1,23 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/align.s -o %t.o
+# RUN: ld.lld -o %t --script %s %t.o
+# RUN: llvm-objdump -t %t | FileCheck %s
+
+SECTIONS {
+ . = 0xff8;
+ .aaa : {
+ *(.aaa)
+ foo = ALIGN(., 0x100);
+ bar = .;
+ zed1 = ALIGN(., 0x100) + 1;
+ zed2 = ALIGN(., 0x100) - 1;
+ }
+ .bbb : { *(.bbb); }
+ .ccc : { *(.ccc); }
+ .text : { *(.text); }
+}
+
+# CHECK: 0000000000001000 .aaa 00000000 foo
+# CHECK: 0000000000001000 .aaa 00000000 bar
+# CHECK: 0000000000001001 .aaa 00000000 zed1
+# CHECK: 0000000000000fff .aaa 00000000 zed2
diff --git a/lld/test/ELF/linkerscript/alignof.s b/lld/test/ELF/linkerscript/alignof.s
deleted file mode 100644
index 8880634df24..00000000000
--- a/lld/test/ELF/linkerscript/alignof.s
+++ /dev/null
@@ -1,41 +0,0 @@
-# REQUIRES: x86
-# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
-
-# RUN: echo "SECTIONS { \
-# RUN: .aaa : { *(.aaa) } \
-# RUN: .bbb : { *(.bbb) } \
-# RUN: .ccc : { *(.ccc) } \
-# RUN: _aaa = ALIGNOF(.aaa); \
-# RUN: _bbb = ALIGNOF(.bbb); \
-# RUN: _ccc = ALIGNOF(.ccc); \
-# RUN: }" > %t.script
-# RUN: ld.lld -o %t1 --script %t.script %t
-# RUN: llvm-objdump -t %t1 | FileCheck %s
-# CHECK: SYMBOL TABLE:
-# CHECK: 0000000000000008 *ABS* 00000000 _aaa
-# CHECK-NEXT: 0000000000000010 *ABS* 00000000 _bbb
-# CHECK-NEXT: 0000000000000020 *ABS* 00000000 _ccc
-
-## Check that we error out if trying to get alignment of
-## section that does not exist.
-# RUN: echo "SECTIONS { \
-# RUN: _aaa = ALIGNOF(.foo); \
-# RUN: }" > %t.script
-# RUN: not ld.lld -o %t1 --script %t.script %t 2>&1 \
-# RUN: | FileCheck -check-prefix=ERR %s
-# ERR: {{.*}}.script:1: undefined section .foo
-.global _start
-_start:
- nop
-
-.section .aaa,"a"
- .align 8
- .quad 0
-
-.section .bbb,"a"
- .align 16
- .quad 0
-
-.section .ccc,"a"
- .align 32
- .quad 0
diff --git a/lld/test/ELF/linkerscript/alignof.test b/lld/test/ELF/linkerscript/alignof.test
new file mode 100644
index 00000000000..0e3abf6133c
--- /dev/null
+++ b/lld/test/ELF/linkerscript/alignof.test
@@ -0,0 +1,24 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/alignof.s -o %t
+# RUN: ld.lld -o %t1 --script %s %t
+# RUN: llvm-objdump -t %t1 | FileCheck %s
+# CHECK: SYMBOL TABLE:
+# CHECK: 0000000000000008 *ABS* 00000000 _aaa
+# CHECK-NEXT: 0000000000000010 *ABS* 00000000 _bbb
+# CHECK-NEXT: 0000000000000020 *ABS* 00000000 _ccc
+
+SECTIONS {
+ .aaa : { *(.aaa) }
+ .bbb : { *(.bbb) }
+ .ccc : { *(.ccc) }
+ _aaa = ALIGNOF(.aaa);
+ _bbb = ALIGNOF(.bbb);
+ _ccc = ALIGNOF(.ccc);
+}
+
+## Check that we error out if trying to get alignment of
+## section that does not exist.
+# RUN: echo "SECTIONS { _aaa = ALIGNOF(.foo); }" > %t.script
+# RUN: not ld.lld -o %t1 --script %t.script %t 2>&1 \
+# RUN: | FileCheck -check-prefix=ERR %s
+# ERR: {{.*}}.script:1: undefined section .foo
diff --git a/lld/test/ELF/linkerscript/arm-exidx-order.s b/lld/test/ELF/linkerscript/arm-exidx-order.s
deleted file mode 100644
index 1ff1711e60b..00000000000
--- a/lld/test/ELF/linkerscript/arm-exidx-order.s
+++ /dev/null
@@ -1,19 +0,0 @@
-# REQUIRES: arm
-# RUN: llvm-mc -filetype=obj -triple=armv7a-none-linux-gnueabi %s -o %t.o
-# RUN: echo "SECTIONS { . = SIZEOF_HEADERS; \
-# RUN: .ARM.exidx : { *(.ARM.exidx*) } \
-# RUN: .foo : { _foo = 0; } }" > %t.script
-# RUN: ld.lld -T %t.script %t.o -shared -o %t.so
-# RUN: llvm-readobj -s %t.so | FileCheck %s
-
-# CHECK: Section {
-# CHECK: Index:
-# CHECK: Name: .foo
-# CHECK-NEXT: Type: SHT_NOBITS
-# CHECK-NEXT: Flags [
-# CHECK-NEXT: SHF_ALLOC
-# CHECK-NEXT: ]
-
-.fnstart
-.cantunwind
-.fnend
diff --git a/lld/test/ELF/linkerscript/arm-exidx-order.test b/lld/test/ELF/linkerscript/arm-exidx-order.test
new file mode 100644
index 00000000000..60abddfd77d
--- /dev/null
+++ b/lld/test/ELF/linkerscript/arm-exidx-order.test
@@ -0,0 +1,19 @@
+# REQUIRES: arm
+# RUN: echo ".fnstart; .cantunwind; .fnend" \
+# RUN: | llvm-mc -filetype=obj -triple=armv7a-none-linux-gnueabi - -o %t.o
+# RUN: ld.lld -T %s %t.o -shared -o %t.so
+# RUN: llvm-readobj -s %t.so | FileCheck %s
+
+SECTIONS {
+ . = SIZEOF_HEADERS;
+ .ARM.exidx : { *(.ARM.exidx*) }
+ .foo : { _foo = 0; }
+}
+
+# CHECK: Section {
+# CHECK: Index:
+# CHECK: Name: .foo
+# CHECK-NEXT: Type: SHT_NOBITS
+# CHECK-NEXT: Flags [
+# CHECK-NEXT: SHF_ALLOC
+# CHECK-NEXT: ]
diff --git a/lld/test/ELF/linkerscript/arm-exidx-phdrs.s b/lld/test/ELF/linkerscript/arm-exidx-phdrs.s
deleted file mode 100644
index 971702f55d7..00000000000
--- a/lld/test/ELF/linkerscript/arm-exidx-phdrs.s
+++ /dev/null
@@ -1,16 +0,0 @@
-// REQUIRES: arm
-// RUN: llvm-mc -filetype=obj -triple=armv7a-none-linux-gnueabi %s -o %t.o
-// RUN: echo "PHDRS { ph_text PT_LOAD; } \
-// RUN: SECTIONS { \
-// RUN: . = SIZEOF_HEADERS; \
-// RUN: .text : { *(.text) } : ph_text \
-// RUN: }" > %t.script
-// RUN: ld.lld -T %t.script %t.o -shared -o %t.so
-// RUN: llvm-readobj --program-headers %t.so | FileCheck %s
-
-// CHECK: Type: PT_ARM_EXIDX
-
-.fnstart
-bx lr
-.cantunwind
-.fnend
diff --git a/lld/test/ELF/linkerscript/arm-exidx-phdrs.test b/lld/test/ELF/linkerscript/arm-exidx-phdrs.test
new file mode 100644
index 00000000000..208d4d72ad4
--- /dev/null
+++ b/lld/test/ELF/linkerscript/arm-exidx-phdrs.test
@@ -0,0 +1,13 @@
+# REQUIRES: arm
+# RUN: echo ".fnstart; bx lr; .cantunwind; .fnend" \
+# RUN: | llvm-mc -filetype=obj -triple=armv7a-none-linux-gnueabi - -o %t.o
+# RUN: ld.lld -T %s %t.o -shared -o %t.so
+# RUN: llvm-readobj --program-headers %t.so | FileCheck %s
+
+# CHECK: Type: PT_ARM_EXIDX
+
+PHDRS { ph_text PT_LOAD; }
+SECTIONS {
+ . = SIZEOF_HEADERS;
+ .text : { *(.text) } : ph_text
+}
diff --git a/lld/test/ELF/linkerscript/arm-lscript.s b/lld/test/ELF/linkerscript/arm-lscript.s
deleted file mode 100644
index c377764e977..00000000000
--- a/lld/test/ELF/linkerscript/arm-lscript.s
+++ /dev/null
@@ -1,9 +0,0 @@
-// REQUIRES: arm
-// RUN: llvm-mc -filetype=obj -triple=armv7a-none-linux-gnueabi %s -o %t.o
-// RUN: echo "SECTIONS { \
-// RUN: .rel.dyn : { } \
-// RUN: .zed : { PROVIDE_HIDDEN (foobar = .); } \
-// RUN: }" > %t.script
-// This is a test case for PR33029. Making sure that linker can digest
-// the above script without dumping core.
-// RUN: ld.lld -emit-relocs -T %t.script %t.o -shared -o %t.so
diff --git a/lld/test/ELF/linkerscript/arm-lscript.test b/lld/test/ELF/linkerscript/arm-lscript.test
new file mode 100644
index 00000000000..af2e6316ea4
--- /dev/null
+++ b/lld/test/ELF/linkerscript/arm-lscript.test
@@ -0,0 +1,11 @@
+# REQUIRES: arm
+# RUN: llvm-mc -filetype=obj -triple=armv7a-none-linux-gnueabi /dev/null -o %t.o
+
+# This is a test case for PR33029. Making sure that linker can digest
+# the above script without dumping core.
+# RUN: ld.lld -emit-relocs -T %s %t.o -shared -o %t.so
+
+SECTIONS {
+ .rel.dyn : {}
+ .zed : { PROVIDE_HIDDEN (foobar = .); }
+}
diff --git a/lld/test/ELF/linkerscript/at2.s b/lld/test/ELF/linkerscript/at2.s
deleted file mode 100644
index 1545b1d826a..00000000000
--- a/lld/test/ELF/linkerscript/at2.s
+++ /dev/null
@@ -1,81 +0,0 @@
-# REQUIRES: x86
-# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
-# RUN: echo "MEMORY { \
-# RUN: AX (ax) : ORIGIN = 0x2000, LENGTH = 0x100 \
-# RUN: AW (aw) : ORIGIN = 0x3000, LENGTH = 0x100 \
-# RUN: FLASH (ax) : ORIGIN = 0x6000, LENGTH = 0x100 \
-# RUN: RAM (aw) : ORIGIN = 0x7000, LENGTH = 0x100 } \
-# RUN: SECTIONS { \
-# RUN: .foo1 : { *(.foo1) } > AX AT>FLASH \
-# RUN: .foo2 : { *(.foo2) } > AX \
-# RUN: .bar1 : { *(.bar1) } > AW AT> RAM \
-# RUN: .bar2 : { *(.bar2) } > AW AT > RAM \
-# RUN: .bar3 : { *(.bar3) } > AW AT >RAM \
-# RUN: }" > %t.script
-# RUN: ld.lld %t --script %t.script -o %t2
-# RUN: llvm-readobj -program-headers %t2 | FileCheck %s
-# RUN: llvm-objdump -section-headers %t2 | FileCheck %s --check-prefix=SECTIONS
-
-# CHECK: ProgramHeaders [
-# CHECK-NEXT: ProgramHeader {
-# CHECK-NEXT: Type: PT_LOAD
-# CHECK-NEXT: Offset: 0x1000
-# CHECK-NEXT: VirtualAddress: 0x2000
-# CHECK-NEXT: PhysicalAddress: 0x6000
-# CHECK-NEXT: FileSize: 16
-# CHECK-NEXT: MemSize: 16
-# CHECK-NEXT: Flags [
-# CHECK-NEXT: PF_R
-# CHECK-NEXT: PF_X
-# CHECK-NEXT: ]
-# CHECK-NEXT: Alignment:
-# CHECK-NEXT: }
-# CHECK-NEXT: ProgramHeader {
-# CHECK-NEXT: Type: PT_LOAD
-# CHECK-NEXT: Offset: 0x2000
-# CHECK-NEXT: VirtualAddress: 0x3000
-# CHECK-NEXT: PhysicalAddress: 0x7000
-# CHECK-NEXT: FileSize: 24
-# CHECK-NEXT: MemSize: 24
-# CHECK-NEXT: Flags [
-# CHECK-NEXT: PF_R
-# CHECK-NEXT: PF_W
-# CHECK-NEXT: ]
-# CHECK-NEXT: Alignment: 4096
-# CHECK-NEXT: }
-
-# SECTIONS: Sections:
-# SECTIONS-NEXT: Idx Name Size Address
-# SECTIONS-NEXT: 0 00000000 0000000000000000
-# SECTIONS-NEXT: 1 .foo1 00000008 0000000000002000
-# SECTIONS-NEXT: 2 .foo2 00000008 0000000000002008
-# SECTIONS-NEXT: 3 .text 00000000 0000000000002010
-# SECTIONS-NEXT: 4 .bar1 00000008 0000000000003000
-# SECTIONS-NEXT: 5 .bar2 00000008 0000000000003008
-# SECTIONS-NEXT: 6 .bar3 00000008 0000000000003010
-
-# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
-# RUN: echo "MEMORY { \
-# RUN: FLASH (ax) : ORIGIN = 0x2000, LENGTH = 0x100 \
-# RUN: RAM (aw) : ORIGIN = 0x5000, LENGTH = 0x100 } \
-# RUN: SECTIONS { \
-# RUN: .foo1 : AT(0x500) { *(.foo1) } > FLASH AT>FLASH \
-# RUN: }" > %t2.script
-# RUN: not ld.lld %t --script %t2.script -o %t2 2>&1 | \
-# RUN: FileCheck %s --check-prefix=ERR
-# ERR: error: section can't have both LMA and a load region
-
-.section .foo1, "ax"
-.quad 0
-
-.section .foo2, "ax"
-.quad 0
-
-.section .bar1, "aw"
-.quad 0
-
-.section .bar2, "aw"
-.quad 0
-
-.section .bar3, "aw"
-.quad 0
diff --git a/lld/test/ELF/linkerscript/at2.test b/lld/test/ELF/linkerscript/at2.test
new file mode 100644
index 00000000000..82c9ae1d225
--- /dev/null
+++ b/lld/test/ELF/linkerscript/at2.test
@@ -0,0 +1,58 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/at2.s -o %t.o
+# RUN: ld.lld -o %t.exe %t.o --script %s
+# RUN: llvm-readobj -program-headers %t.exe | FileCheck %s
+# RUN: llvm-objdump -section-headers %t.exe | FileCheck %s --check-prefix=SECTIONS
+
+MEMORY {
+ AX (ax) : ORIGIN = 0x2000, LENGTH = 0x100
+ AW (aw) : ORIGIN = 0x3000, LENGTH = 0x100
+ FLASH (ax) : ORIGIN = 0x6000, LENGTH = 0x100
+ RAM (aw) : ORIGIN = 0x7000, LENGTH = 0x100
+}
+
+SECTIONS {
+ .foo1 : { *(.foo1) } > AX AT>FLASH
+ .foo2 : { *(.foo2) } > AX
+ .bar1 : { *(.bar1) } > AW AT> RAM
+ .bar2 : { *(.bar2) } > AW AT > RAM
+ .bar3 : { *(.bar3) } > AW AT >RAM
+}
+
+# CHECK: ProgramHeaders [
+# CHECK-NEXT: ProgramHeader {
+# CHECK-NEXT: Type: PT_LOAD
+# CHECK-NEXT: Offset: 0x1000
+# CHECK-NEXT: VirtualAddress: 0x2000
+# CHECK-NEXT: PhysicalAddress: 0x6000
+# CHECK-NEXT: FileSize: 16
+# CHECK-NEXT: MemSize: 16
+# CHECK-NEXT: Flags [
+# CHECK-NEXT: PF_R
+# CHECK-NEXT: PF_X
+# CHECK-NEXT: ]
+# CHECK-NEXT: Alignment:
+# CHECK-NEXT: }
+# CHECK-NEXT: ProgramHeader {
+# CHECK-NEXT: Type: PT_LOAD
+# CHECK-NEXT: Offset: 0x2000
+# CHECK-NEXT: VirtualAddress: 0x3000
+# CHECK-NEXT: PhysicalAddress: 0x7000
+# CHECK-NEXT: FileSize: 24
+# CHECK-NEXT: MemSize: 24
+# CHECK-NEXT: Flags [
+# CHECK-NEXT: PF_R
+# CHECK-NEXT: PF_W
+# CHECK-NEXT: ]
+# CHECK-NEXT: Alignment: 4096
+# CHECK-NEXT: }
+
+# SECTIONS: Sections:
+# SECTIONS-NEXT: Idx Name Size Address
+# SECTIONS-NEXT: 0 00000000 0000000000000000
+# SECTIONS-NEXT: 1 .foo1 00000008 0000000000002000
+# SECTIONS-NEXT: 2 .foo2 00000008 0000000000002008
+# SECTIONS-NEXT: 3 .text 00000000 0000000000002010
+# SECTIONS-NEXT: 4 .bar1 00000008 0000000000003000
+# SECTIONS-NEXT: 5 .bar2 00000008 0000000000003008
+# SECTIONS-NEXT: 6 .bar3 00000008 0000000000003010
diff --git a/lld/test/ELF/linkerscript/at3.s b/lld/test/ELF/linkerscript/at3.s
deleted file mode 100644
index 10bbfc6e96e..00000000000
--- a/lld/test/ELF/linkerscript/at3.s
+++ /dev/null
@@ -1,38 +0,0 @@
-# REQUIRES: x86
-# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
-# RUN: echo "MEMORY { \
-# RUN: FOO (ax) : ORIGIN = 0x1000, LENGTH = 0x100 \
-# RUN: BAR (ax) : ORIGIN = 0x2000, LENGTH = 0x100 \
-# RUN: ZED (ax) : ORIGIN = 0x3000, LENGTH = 0x100 \
-# RUN: FLASH (ax) : ORIGIN = 0x6000, LENGTH = 0x200 \
-# RUN: } \
-# RUN: SECTIONS { \
-# RUN: .foo1 : { *(.foo1) } > FOO AT>FLASH \
-# RUN: .foo2 : { *(.foo2) BYTE(0x42) } > BAR AT>FLASH \
-# RUN: .foo3 : { *(.foo3) } > ZED AT>FLASH \
-# RUN: }" > %t.script
-# RUN: ld.lld %t.o --script %t.script -o %t
-# RUN: llvm-readelf -sections -program-headers %t | FileCheck %s
-
-# CHECK: .foo1 PROGBITS 0000000000001000 001000
-# CHECK: .foo2 PROGBITS 0000000000002000 002000
-# CHECK: .foo3 PROGBITS 0000000000003000 003000
-
-# CHECK: Program Headers:
-# CHECK-NOT: LOAD
-
-# CHECK: Type Offset VirtAddr PhysAddr
-# CHECK-NEXT: LOAD 0x001000 0x0000000000001000 0x0000000000006000
-# CHECK-NEXT: LOAD 0x002000 0x0000000000002000 0x0000000000006008
-# CHECK-NEXT: LOAD 0x003000 0x0000000000003000 0x0000000000006011
-
-# CHECK-NOT: LOAD
-
-.section .foo1, "a"
-.quad 0
-
-.section .foo2, "ax"
-.quad 0
-
-.section .foo3, "ax"
-.quad 0
diff --git a/lld/test/ELF/linkerscript/at3.test b/lld/test/ELF/linkerscript/at3.test
new file mode 100644
index 00000000000..6344f38b304
--- /dev/null
+++ b/lld/test/ELF/linkerscript/at3.test
@@ -0,0 +1,31 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %p/Inputs/at3.s -o %t.o
+# RUN: ld.lld %t.o --script %s -o %t
+# RUN: llvm-readelf -sections -program-headers %t | FileCheck %s
+
+MEMORY {
+ FOO (ax) : ORIGIN = 0x1000, LENGTH = 0x100
+ BAR (ax) : ORIGIN = 0x2000, LENGTH = 0x100
+ ZED (ax) : ORIGIN = 0x3000, LENGTH = 0x100
+ FLASH (ax) : ORIGIN = 0x6000, LENGTH = 0x200
+}
+
+SECTIONS {
+ .foo1 : { *(.foo1) } > FOO AT>FLASH
+ .foo2 : { *(.foo2) BYTE(0x42) } > BAR AT>FLASH
+ .foo3 : { *(.foo3) } > ZED AT>FLASH
+}
+
+# CHECK: .foo1 PROGBITS 0000000000001000 001000
+# CHECK: .foo2 PROGBITS 0000000000002000 002000
+# CHECK: .foo3 PROGBITS 0000000000003000 003000
+
+# CHECK: Program Headers:
+# CHECK-NOT: LOAD
+
+# CHECK: Type Offset VirtAddr PhysAddr
+# CHECK-NEXT: LOAD 0x001000 0x0000000000001000 0x0000000000006000
+# CHECK-NEXT: LOAD 0x002000 0x0000000000002000 0x0000000000006008
+# CHECK-NEXT: LOAD 0x003000 0x0000000000003000 0x0000000000006011
+
+# CHECK-NOT: LOAD
diff --git a/lld/test/ELF/linkerscript/at5.test b/lld/test/ELF/linkerscript/at5.test
new file mode 100644
index 00000000000..8e1ed93bcad
--- /dev/null
+++ b/lld/test/ELF/linkerscript/at5.test
@@ -0,0 +1,14 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux /dev/null -o %t.o
+# RUN: not ld.lld -o %t.exe %t.o --script %s 2>&1 | FileCheck %s
+
+MEMORY {
+ FLASH (ax) : ORIGIN = 0x2000, LENGTH = 0x100
+ RAM (aw) : ORIGIN = 0x5000, LENGTH = 0x100
+}
+
+SECTIONS {
+ .foo1 : AT(0x500) { *(.foo1) } > FLASH AT>FLASH
+}
+
+# CHECK: error: section can't have both LMA and a load region
diff --git a/lld/test/ELF/linkerscript/symbols-synthetic.s b/lld/test/ELF/linkerscript/symbols-synthetic.s
deleted file mode 100644
index 95cdae9a929..00000000000
--- a/lld/test/ELF/linkerscript/symbols-synthetic.s
+++ /dev/null
@@ -1,98 +0,0 @@
-# REQUIRES: x86
-# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
-# Simple symbol assignment within input section list. The '.' symbol
-# is not location counter but offset from the beginning of output
-# section .foo
-# RUN: echo "SECTIONS { \
-# RUN: . = SIZEOF_HEADERS; \
-# RUN: .foo : { \
-# RUN: begin_foo = .; \
-# RUN: PROVIDE(_begin_sec = .); \
-# RUN: *(.foo) \
-# RUN: end_foo = .; \
-# RUN: PROVIDE_HIDDEN(_end_sec = .); \
-# RUN: PROVIDE(_end_sec_abs = ABSOLUTE(.)); \
-# RUN: size_foo_1 = SIZEOF(.foo); \
-# RUN: size_foo_1_abs = ABSOLUTE(SIZEOF(.foo)); \
-# RUN: . = ALIGN(0x1000); \
-# RUN: begin_bar = .; \
-# RUN: *(.bar) \
-# RUN: end_bar = .; \
-# RUN: size_foo_2 = SIZEOF(.foo); } \
-# RUN: size_foo_3 = SIZEOF(.foo); \
-# RUN: .eh_frame_hdr : { \
-# RUN: __eh_frame_hdr_start = .; \
-# RUN: __eh_frame_hdr_start2 = ABSOLUTE(ALIGN(0x10)); \
-# RUN: *(.eh_frame_hdr) \
-# RUN: __eh_frame_hdr_end = .; \
-# RUN: __eh_frame_hdr_end2 = ABSOLUTE(ALIGN(0x10)); } \
-# RUN: .eh_frame : { } \
-# RUN: }" > %t.script
-# RUN: ld.lld -o %t1 --eh-frame-hdr --script %t.script %t
-# RUN: llvm-objdump -t %t1 | FileCheck --check-prefix=SIMPLE %s
-
-# Check that the following script is processed without errors
-# RUN: echo "SECTIONS { \
-# RUN: .eh_frame_hdr : { \
-# RUN: PROVIDE_HIDDEN(_begin_sec = .); \
-# RUN: *(.eh_frame_hdr) \
-# RUN: *(.eh_frame_hdr) \
-# RUN: PROVIDE_HIDDEN(_end_sec_abs = ABSOLUTE(.)); \
-# RUN: PROVIDE_HIDDEN(_end_sec = .); } \
-# RUN: }" > %t.script
-# RUN: ld.lld -o %t1 --eh-frame-hdr --script %t.script %t
-
-# Check that we can specify synthetic symbols without defining SECTIONS.
-# RUN: echo "PROVIDE_HIDDEN(_begin_sec = _start); \
-# RUN: PROVIDE_HIDDEN(_end_sec = ADDR(.text) + SIZEOF(.text));" > %t.script
-# RUN: ld.lld -o %t1 --eh-frame-hdr --script %t.script %t
-# RUN: llvm-objdump -t %t1 | FileCheck --check-prefix=NO-SEC %s
-
-# Check that we can do the same as above inside SECTIONS block.
-# RUN: echo "SECTIONS { \
-# RUN: . = 0x201000; \
-# RUN: .text : { *(.text) } \
-# RUN: PROVIDE_HIDDEN(_begin_sec = ADDR(.text)); \
-# RUN: PROVIDE_HIDDEN(_end_sec = ADDR(.text) + SIZEOF(.text)); }" > %t.script
-# RUN: ld.lld -o %t1 --eh-frame-hdr --script %t.script %t
-# RUN: llvm-objdump -t %t1 | FileCheck --check-prefix=IN-SEC %s
-
-# SIMPLE: 0000000000000128 .foo 00000000 .hidden _end_sec
-# SIMPLE-NEXT: 0000000000000120 .foo 00000000 _begin_sec
-# SIMPLE-NEXT: 0000000000000128 *ABS* 00000000 _end_sec_abs
-# SIMPLE-NEXT: 0000000000001048 .text 00000000 _start
-# SIMPLE-NEXT: 0000000000000120 .foo 00000000 begin_foo
-# SIMPLE-NEXT: 0000000000000128 .foo 00000000 end_foo
-# SIMPLE-NEXT: 0000000000000008 *ABS* 00000000 size_foo_1
-# SIMPLE-NEXT: 0000000000000008 *ABS* 00000000 size_foo_1_abs
-# SIMPLE-NEXT: 0000000000001000 .foo 00000000 begin_bar
-# SIMPLE-NEXT: 0000000000001004 .foo 00000000 end_bar
-# SIMPLE-NEXT: 0000000000000ee4 *ABS* 00000000 size_foo_2
-# SIMPLE-NEXT: 0000000000000ee4 *ABS* 00000000 size_foo_3
-# SIMPLE-NEXT: 0000000000001004 .eh_frame_hdr 00000000 __eh_frame_hdr_start
-# SIMPLE-NEXT: 0000000000001010 *ABS* 00000000 __eh_frame_hdr_start2
-# SIMPLE-NEXT: 0000000000001018 .eh_frame_hdr 00000000 __eh_frame_hdr_end
-# SIMPLE-NEXT: 0000000000001020 *ABS* 00000000 __eh_frame_hdr_end2
-
-# NO-SEC: 0000000000201000 .text 00000000 .hidden _begin_sec
-# NO-SEC-NEXT: 0000000000201001 .text 00000000 .hidden _end_sec
-
-# IN-SEC: 0000000000201000 .text 00000000 .hidden _begin_sec
-# IN-SEC-NEXT: 0000000000201001 .text 00000000 .hidden _end_sec
-
-.global _start
-_start:
- nop
-
-.section .foo,"a"
- .quad 0
-
-.section .bar,"a"
- .long 0
-
-.section .dah,"ax",@progbits
- .cfi_startproc
- nop
- .cfi_endproc
-
-.global _begin_sec, _end_sec, _end_sec_abs
diff --git a/lld/test/ELF/linkerscript/synthetic-symbols1.test b/lld/test/ELF/linkerscript/synthetic-symbols1.test
new file mode 100644
index 00000000000..eb09d2dda7f
--- /dev/null
+++ b/lld/test/ELF/linkerscript/synthetic-symbols1.test
@@ -0,0 +1,56 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/synthetic-symbols.s -o %t
+# RUN: ld.lld -o %t.exe --eh-frame-hdr --script %s %t
+# RUN: llvm-objdump -t %t.exe | FileCheck %s
+
+# Simple symbol assignment within input section list. The '.' symbol
+# is not location counter but offset from the beginning of output
+# section .foo
+
+SECTIONS {
+ . = SIZEOF_HEADERS;
+ .foo : {
+ begin_foo = .;
+ PROVIDE(_begin_sec = .);
+ *(.foo)
+ end_foo = .;
+ PROVIDE_HIDDEN(_end_sec = .);
+ PROVIDE(_end_sec_abs = ABSOLUTE(.));
+ size_foo_1 = SIZEOF(.foo);
+ size_foo_1_abs = ABSOLUTE(SIZEOF(.foo));
+ . = ALIGN(0x1000);
+ begin_bar = .;
+ *(.bar)
+ end_bar = .;
+ size_foo_2 = SIZEOF(.foo);
+ }
+
+ size_foo_3 = SIZEOF(.foo);
+
+ .eh_frame_hdr : {
+ __eh_frame_hdr_start = .;
+ __eh_frame_hdr_start2 = ABSOLUTE(ALIGN(0x10));
+ *(.eh_frame_hdr)
+ __eh_frame_hdr_end = .;
+ __eh_frame_hdr_end2 = ABSOLUTE(ALIGN(0x10));
+ }
+
+ .eh_frame : {}
+}
+
+# CHECK: 0000000000000128 .foo 00000000 .hidden _end_sec
+# CHECK-NEXT: 0000000000000120 .foo 00000000 _begin_sec
+# CHECK-NEXT: 0000000000000128 *ABS* 00000000 _end_sec_abs
+# CHECK-NEXT: 0000000000001048 .text 00000000 _start
+# CHECK-NEXT: 0000000000000120 .foo 00000000 begin_foo
+# CHECK-NEXT: 0000000000000128 .foo 00000000 end_foo
+# CHECK-NEXT: 0000000000000008 *ABS* 00000000 size_foo_1
+# CHECK-NEXT: 0000000000000008 *ABS* 00000000 size_foo_1_abs
+# CHECK-NEXT: 0000000000001000 .foo 00000000 begin_bar
+# CHECK-NEXT: 0000000000001004 .foo 00000000 end_bar
+# CHECK-NEXT: 0000000000000ee4 *ABS* 00000000 size_foo_2
+# CHECK-NEXT: 0000000000000ee4 *ABS* 00000000 size_foo_3
+# CHECK-NEXT: 0000000000001004 .eh_frame_hdr 00000000 __eh_frame_hdr_start
+# CHECK-NEXT: 0000000000001010 *ABS* 00000000 __eh_frame_hdr_start2
+# CHECK-NEXT: 0000000000001018 .eh_frame_hdr 00000000 __eh_frame_hdr_end
+# CHECK-NEXT: 0000000000001020 *ABS* 00000000 __eh_frame_hdr_end2
diff --git a/lld/test/ELF/linkerscript/synthetic-symbols2.test b/lld/test/ELF/linkerscript/synthetic-symbols2.test
new file mode 100644
index 00000000000..5304c1e28f0
--- /dev/null
+++ b/lld/test/ELF/linkerscript/synthetic-symbols2.test
@@ -0,0 +1,13 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/synthetic-symbols.s -o %t
+# RUN: ld.lld -o %t.exe --eh-frame-hdr --script %s %t
+
+SECTIONS {
+ .eh_frame_hdr : {
+ PROVIDE_HIDDEN(_begin_sec = .);
+ *(.eh_frame_hdr)
+ *(.eh_frame_hdr)
+ PROVIDE_HIDDEN(_end_sec_abs = ABSOLUTE(.));
+ PROVIDE_HIDDEN(_end_sec = .);
+ }
+}
diff --git a/lld/test/ELF/linkerscript/synthetic-symbols3.test b/lld/test/ELF/linkerscript/synthetic-symbols3.test
new file mode 100644
index 00000000000..a24ecccedf0
--- /dev/null
+++ b/lld/test/ELF/linkerscript/synthetic-symbols3.test
@@ -0,0 +1,11 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/synthetic-symbols.s -o %t
+# RUN: ld.lld -o %t.exe --eh-frame-hdr --script %s %t
+# RUN: llvm-objdump -t %t.exe | FileCheck %s
+
+# Check that we can specify synthetic symbols without defining SECTIONS.
+PROVIDE_HIDDEN(_begin_sec = _start);
+PROVIDE_HIDDEN(_end_sec = ADDR(.text) + SIZEOF(.text));
+
+# CHECK: 0000000000201000 .text 00000000 .hidden _begin_sec
+# CHECK-NEXT: 0000000000201001 .text 00000000 .hidden _end_sec
diff --git a/lld/test/ELF/linkerscript/synthetic-symbols4.test b/lld/test/ELF/linkerscript/synthetic-symbols4.test
new file mode 100644
index 00000000000..fb857e7f584
--- /dev/null
+++ b/lld/test/ELF/linkerscript/synthetic-symbols4.test
@@ -0,0 +1,14 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/synthetic-symbols.s -o %t
+# RUN: ld.lld -o %t.exe --eh-frame-hdr --script %s %t
+# RUN: llvm-objdump -t %t.exe | FileCheck %s
+
+SECTIONS {
+ . = 0x201000;
+ .text : { *(.text) }
+ PROVIDE_HIDDEN(_begin_sec = ADDR(.text));
+ PROVIDE_HIDDEN(_end_sec = ADDR(.text) + SIZEOF(.text));
+}
+
+# CHECK: 0000000000201000 .text 00000000 .hidden _begin_sec
+# CHECK-NEXT: 0000000000201001 .text 00000000 .hidden _end_sec
OpenPOWER on IntegriCloud