summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRui Ueyama <ruiu@google.com>2018-02-28 20:22:42 +0000
committerRui Ueyama <ruiu@google.com>2018-02-28 20:22:42 +0000
commit2dfe49a44155f0bd1d4819eb7e06488c6ec00bab (patch)
tree19180757bc24783f5ad83013e9fa28dec3244203
parentf181f1a6a206f427860e999768259e81a94f6d6a (diff)
downloadbcm5719-llvm-2dfe49a44155f0bd1d4819eb7e06488c6ec00bab.tar.gz
bcm5719-llvm-2dfe49a44155f0bd1d4819eb7e06488c6ec00bab.zip
Write some tests as linker scripts instead of assembly files.
Some linker script test cases contain only a few lines of assembly and a long linker script. Such tests are easier to maintain if we write the main test file as a linkier script instead of assembly. Differential Revision: https://reviews.llvm.org/D43887 llvm-svn: 326363
-rw-r--r--lld/test/ELF/linkerscript/absolute-expr.test (renamed from lld/test/ELF/linkerscript/absolute-expr.s)28
-rw-r--r--lld/test/ELF/linkerscript/align-empty.s18
-rw-r--r--lld/test/ELF/linkerscript/align-empty.test18
-rw-r--r--lld/test/ELF/linkerscript/discard-interp.s12
-rw-r--r--lld/test/ELF/linkerscript/discard-interp.test13
-rw-r--r--lld/test/ELF/linkerscript/operators.test (renamed from lld/test/ELF/linkerscript/operators.s)73
6 files changed, 79 insertions, 83 deletions
diff --git a/lld/test/ELF/linkerscript/absolute-expr.s b/lld/test/ELF/linkerscript/absolute-expr.test
index a9a674b859f..9e8f517d0ac 100644
--- a/lld/test/ELF/linkerscript/absolute-expr.s
+++ b/lld/test/ELF/linkerscript/absolute-expr.test
@@ -1,21 +1,19 @@
# REQUIRES: x86
-# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
-# RUN: echo "SECTIONS { \
-# RUN: .text : { \
-# RUN: bar1 = ALIGNOF(.text); \
-# RUN: bar2 = CONSTANT (MAXPAGESIZE); \
-# RUN: bar3 = SIZEOF (.text); \
-# RUN: bar4 = SIZEOF_HEADERS; \
-# RUN: bar5 = 0x42; \
-# RUN: bar6 = foo + 1; \
-# RUN: *(.text) \
-# RUN: } \
-# RUN: };" > %t.script
-# RUN: ld.lld -o %t.so --script %t.script %t.o -shared
+# RUN: echo ".global foo; foo = 0x123" | llvm-mc -filetype=obj -triple=x86_64-pc-linux - -o %t.o
+# RUN: ld.lld -o %t.so --script %s %t.o -shared
# RUN: llvm-readobj -t %t.so | FileCheck %s
-.global foo
-foo = 0x123
+SECTIONS {
+ .text : {
+ bar1 = ALIGNOF(.text);
+ bar2 = CONSTANT (MAXPAGESIZE);
+ bar3 = SIZEOF (.text);
+ bar4 = SIZEOF_HEADERS;
+ bar5 = 0x42;
+ bar6 = foo + 1;
+ *(.text)
+ }
+}
# CHECK: Symbol {
# CHECK: Name: foo
diff --git a/lld/test/ELF/linkerscript/align-empty.s b/lld/test/ELF/linkerscript/align-empty.s
deleted file mode 100644
index 3ff71578410..00000000000
--- a/lld/test/ELF/linkerscript/align-empty.s
+++ /dev/null
@@ -1,18 +0,0 @@
-# REQUIRES: x86
-# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
-
-# RUN: echo "SECTIONS { \
-# RUN: . = SIZEOF_HEADERS; \
-# RUN: abc : { } \
-# RUN: . = ALIGN(0x1000); \
-# RUN: foo : { *(foo) } \
-# RUN: }" > %t.script
-# RUN: ld.lld -o %t1 --script %t.script %t -shared
-# RUN: llvm-objdump -section-headers %t1 | FileCheck %s
-# CHECK: Sections:
-# CHECK-NEXT: Idx Name Size Address
-# CHECK-NEXT: 0 00000000 0000000000000000
-# CHECK-NEXT: 1 foo 00000001 0000000000001000
-
- .section foo, "a"
- .byte 0
diff --git a/lld/test/ELF/linkerscript/align-empty.test b/lld/test/ELF/linkerscript/align-empty.test
new file mode 100644
index 00000000000..deb82681877
--- /dev/null
+++ b/lld/test/ELF/linkerscript/align-empty.test
@@ -0,0 +1,18 @@
+# REQUIRES: x86
+# 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 -shared
+# RUN: llvm-objdump -section-headers %t1 | FileCheck %s
+
+SECTIONS {
+ . = SIZEOF_HEADERS;
+ abc : {}
+ . = ALIGN(0x1000);
+ foo : { *(foo) }
+}
+
+# CHECK: Sections:
+# CHECK-NEXT: Idx Name Size Address
+# CHECK-NEXT: 0 00000000 0000000000000000
+# CHECK-NEXT: 1 foo 00000001 0000000000001000
diff --git a/lld/test/ELF/linkerscript/discard-interp.s b/lld/test/ELF/linkerscript/discard-interp.s
deleted file mode 100644
index 261509e2e76..00000000000
--- a/lld/test/ELF/linkerscript/discard-interp.s
+++ /dev/null
@@ -1,12 +0,0 @@
-// RUN: llvm-mc -filetype=obj -triple=i686-unknown-linux %s -o %t.o
-// RUN: llvm-mc -filetype=obj -triple=i686-unknown-linux %p/../Inputs/shared.s -o %t2.o
-// RUN: ld.lld -shared %t2.o -o %t2.so
-// RUN: echo "PHDRS { text PT_LOAD FILEHDR PHDRS; } \
-// RUN: SECTIONS { . = SIZEOF_HEADERS; .text : { *(.text) } : text }" > %t.script
-// RUN: ld.lld -dynamic-linker /lib64/ld-linux-x86-64.so.2 -rpath foo -rpath bar --script %t.script --export-dynamic %t.o %t2.so -o %t
-// RUN: llvm-readobj -s %t | FileCheck %s
-
-// CHECK-NOT: Name: .interp
-
-.global _start
-_start:
diff --git a/lld/test/ELF/linkerscript/discard-interp.test b/lld/test/ELF/linkerscript/discard-interp.test
new file mode 100644
index 00000000000..97a6037e90e
--- /dev/null
+++ b/lld/test/ELF/linkerscript/discard-interp.test
@@ -0,0 +1,13 @@
+# RUN: llvm-mc -filetype=obj -triple=i686-unknown-linux /dev/null -o %t.o
+# RUN: llvm-mc -filetype=obj -triple=i686-unknown-linux %p/../Inputs/shared.s -o %t2.o
+# RUN: ld.lld -shared %t2.o -o %t2.so
+# RUN: ld.lld -dynamic-linker foo -rpath bar -rpath baz --script %s --export-dynamic %t.o %t2.so -o %t
+# RUN: llvm-readobj -s %t | FileCheck %s
+
+# CHECK-NOT: Name: .interp
+
+PHDRS { text PT_LOAD FILEHDR PHDRS; }
+SECTIONS {
+ . = SIZEOF_HEADERS;
+ .text : { *(.text) } : text
+}
diff --git a/lld/test/ELF/linkerscript/operators.s b/lld/test/ELF/linkerscript/operators.test
index b9be4b68e21..a5189fa1d4a 100644
--- a/lld/test/ELF/linkerscript/operators.s
+++ b/lld/test/ELF/linkerscript/operators.test
@@ -1,40 +1,41 @@
# REQUIRES: x86
-# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
-# RUN: echo "SECTIONS { \
-# RUN: _start = .; \
-# RUN: plus = 1 + 2 + 3; \
-# RUN: minus = 5 - 1; \
-# RUN: div = 6 / 2; \
-# RUN: mod = 20 % 7; \
-# RUN: mul = 1 + 2 * 3; \
-# RUN: nospace = 1+2*6/3; \
-# RUN: braces = 1 + (2 + 3) * 4; \
-# RUN: and = 0xbb & 0xee; \
-# RUN: ternary1 = 1 ? 1 : 2; \
-# RUN: ternary2 = 0 ? 1 : 2; \
-# RUN: less = 1 < 0 ? 1 : 2; \
-# RUN: lesseq = 1 <= 1 ? 1 : 2; \
-# RUN: greater = 0 > 1 ? 1 : 2; \
-# RUN: greatereq = 1 >= 1 ? 1 : 2; \
-# RUN: eq = 1 == 1 ? 1 : 2; \
-# RUN: neq = 1 != 1 ? 1 : 2; \
-# RUN: plusassign = 1; \
-# RUN: plusassign += 2; \
-# RUN: unary = -1 + 3; \
-# RUN: lshift = 1 << 5; \
-# RUN: rshift = 0xff >> 3; \
-# RUN: maxpagesize = CONSTANT (MAXPAGESIZE); \
-# RUN: commonpagesize = CONSTANT (COMMONPAGESIZE); \
-# RUN: . = 0xfff0; \
-# RUN: datasegmentalign = DATA_SEGMENT_ALIGN (0xffff, 0); \
-# RUN: datasegmentalign2 = DATA_SEGMENT_ALIGN (0, 0); \
-# RUN: _end = .; \
-# RUN: minus_rel = _end - 0x10; \
-# RUN: minus_abs = _end - _start; \
-# RUN: }" > %t.script
-# RUN: ld.lld %t --script %t.script -o %t2
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux /dev/null -o %t
+# RUN: ld.lld %t --script %s -o %t2
# RUN: llvm-objdump -t %t2 | FileCheck %s
+SECTIONS {
+ _start = .;
+ plus = 1 + 2 + 3;
+ minus = 5 - 1;
+ div = 6 / 2;
+ mod = 20 % 7;
+ mul = 1 + 2 * 3;
+ nospace = 1+2*6/3;
+ braces = 1 + (2 + 3) * 4;
+ and = 0xbb & 0xee;
+ ternary1 = 1 ? 1 : 2;
+ ternary2 = 0 ? 1 : 2;
+ less = 1 < 0 ? 1 : 2;
+ lesseq = 1 <= 1 ? 1 : 2;
+ greater = 0 > 1 ? 1 : 2;
+ greatereq = 1 >= 1 ? 1 : 2;
+ eq = 1 == 1 ? 1 : 2;
+ neq = 1 != 1 ? 1 : 2;
+ plusassign = 1;
+ plusassign += 2;
+ unary = -1 + 3;
+ lshift = 1 << 5;
+ rshift = 0xff >> 3;
+ maxpagesize = CONSTANT (MAXPAGESIZE);
+ commonpagesize = CONSTANT (COMMONPAGESIZE);
+ . = 0xfff0;
+ datasegmentalign = DATA_SEGMENT_ALIGN (0xffff, 0);
+ datasegmentalign2 = DATA_SEGMENT_ALIGN (0, 0);
+ _end = .;
+ minus_rel = _end - 0x10;
+ minus_abs = _end - _start;
+}
+
# CHECK: 00000000000006 *ABS* 00000000 plus
# CHECK: 00000000000004 *ABS* 00000000 minus
# CHECK: 00000000000003 *ABS* 00000000 div
@@ -97,7 +98,3 @@
# RUN: not ld.lld %t --script %t.script -o %t2 2>&1 | \
# RUN: FileCheck --check-prefix=TERNERR %s
# TERNERR: : expected, but got ;
-
-.globl _start
-_start:
-nop
OpenPOWER on IntegriCloud