Skip to content

Commit 8644a2a

Browse files
committed
[ELF,test] Improve negative linker script tests
1 parent e8504cb commit 8644a2a

File tree

9 files changed

+75
-76
lines changed

9 files changed

+75
-76
lines changed

lld/test/ELF/linkerscript/diag.test

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# REQUIRES: x86
2+
# RUN: rm -rf %t && split-file %s %t && cd %t
3+
# RUN: llvm-mc -filetype=obj -triple=x86_64 /dev/null -o 0.o
4+
5+
#--- 1.lds
6+
SECTIONS {
7+
.text + { *(.text) }
8+
.keep : { *(.keep) } /*
9+
comment line 1
10+
comment line 2 */
11+
.temp : { *(.temp) }
12+
}
13+
14+
# RUN: not ld.lld -shared 0.o -T 1.lds 2>&1 | FileCheck %s --check-prefix=CHECK1 --match-full-lines --strict-whitespace
15+
# CHECK1:{{.*}}:2: malformed number: +
16+
# CHECK1-NEXT:>>> .text + { *(.text) }
17+
# CHECK1-NEXT:>>> ^
18+
19+
#--- 2.lds
20+
21+
UNKNOWN_TAG {
22+
.text : { *(.text) }
23+
.keep : { *(.keep) }
24+
.temp : { *(.temp) }
25+
}
26+
27+
# RUN: not ld.lld -shared 0.o -T 2.lds 2>&1 | FileCheck %s --check-prefix=CHECK2 --match-full-lines --strict-whitespace
28+
# CHECK2:{{.*}}:2: unknown directive: UNKNOWN_TAG
29+
# CHECK2-NEXT:>>> UNKNOWN_TAG {
30+
# CHECK2-NEXT:>>> ^
31+
32+
#--- 3.lds
33+
SECTIONS {
34+
.text : { *(.text) }
35+
.keep : { *(.keep) }
36+
boom ^temp : { *(.temp) }
37+
}
38+
#--- 3a.lds
39+
INCLUDE "3.lds"
40+
#--- 3b.lds
41+
foo = 3;
42+
INCLUDE "3a.lds"
43+
44+
# RUN: not ld.lld -shared 0.o -T 3.lds 2>&1 | FileCheck %s --check-prefix=CHECK3 --match-full-lines --strict-whitespace
45+
# RUN: not ld.lld -shared 0.o -T 3a.lds 2>&1 | FileCheck %s --check-prefix=CHECK3 --match-full-lines --strict-whitespace
46+
# RUN: not ld.lld -shared 0.o -T 3b.lds 2>&1 | FileCheck %s --check-prefix=CHECK3 --match-full-lines --strict-whitespace
47+
# CHECK3:{{.*}}3.lds:4: malformed number: ^
48+
# CHECK3-NEXT:>>> boom ^temp : { *(.temp) }
49+
# CHECK3-NEXT:>>> ^

lld/test/ELF/linkerscript/diag1.test

Lines changed: 0 additions & 15 deletions
This file was deleted.

lld/test/ELF/linkerscript/diag2.test

Lines changed: 0 additions & 13 deletions
This file was deleted.

lld/test/ELF/linkerscript/diag3.test

Lines changed: 0 additions & 13 deletions
This file was deleted.

lld/test/ELF/linkerscript/diag4.test

Lines changed: 0 additions & 14 deletions
This file was deleted.

lld/test/ELF/linkerscript/diag5.test

Lines changed: 0 additions & 14 deletions
This file was deleted.

lld/test/ELF/linkerscript/diag6.test

Lines changed: 0 additions & 7 deletions
This file was deleted.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# REQUIRES: x86
2+
# RUN: rm -rf %t && split-file %s %t && cd %t
3+
# RUN: llvm-mc -filetype=obj -triple=x86_64 /dev/null -o 0.o
4+
5+
#--- empty.lds
6+
#--- 1.lds
7+
8+
SECTIONS /*
9+
#--- 1a.lds
10+
foo = 3;
11+
INCLUDE "empty.lds"
12+
INCLUDE "1.lds"
13+
14+
# RUN: not ld.lld -shared 0.o -T 1.lds 2>&1 | FileCheck %s --check-prefix=CHECK1 --match-full-lines --strict-whitespace
15+
# RUN: not ld.lld -shared 0.o -T 1a.lds 2>&1 | FileCheck %s --check-prefix=CHECK1A --match-full-lines --strict-whitespace
16+
# CHECK1:{{.*}}error: 1.lds:1: unclosed comment in a linker script
17+
# CHECK1A:{{.*}}error: 1a.lds:3: unclosed comment in a linker script
18+
#CHECK1A-NEXT:>>> INCLUDE "1.lds"
19+
#CHECK1A-NEXT:>>> ^
20+
21+
#--- 2.lds
22+
INCLUDE "empty.lds"
23+
"
24+
# RUN: not ld.lld -shared 0.o -T 2.lds 2>&1 | FileCheck %s --check-prefix=CHECK2 --match-full-lines --strict-whitespace
25+
# CHECK2:{{.*}}error: 2.lds:2: unclosed quote
26+
# CHECK2-NOT:{{.}}

0 commit comments

Comments
 (0)