Skip to content

Commit aad2238

Browse files
committed
[ELF] Improve INCLUDE cycle tests
And demonstrate the incorrect diagnostic when a linker script is included multiple times (#93947).
1 parent 4ad3dee commit aad2238

File tree

1 file changed

+22
-7
lines changed

1 file changed

+22
-7
lines changed
Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,30 @@
11
# REQUIRES: x86
2-
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o
2+
# RUN: rm -rf %t && split-file %s %t && cd %t
3+
# RUN: llvm-mc -filetype=obj -triple=x86_64 a.s -o a.o
34

4-
# RUN: echo "INCLUDE \"%t1.script\"" > %t1.script
5-
# RUN: not ld.lld %t.o %t1.script 2>&1 | FileCheck %s
5+
# RUN: not ld.lld a.o -T 1.lds 2>&1 | FileCheck %s --check-prefix=ERR1
6+
# ERR1: error: 1.lds:1: there is a cycle in linker script INCLUDEs
67

7-
# RUN: echo "INCLUDE \"%t2.script\"" > %t1.script
8-
# RUN: echo "INCLUDE \"%t1.script\"" > %t2.script
9-
# RUN: not ld.lld %t.o %t1.script 2>&1 | FileCheck %s
8+
# RUN: not ld.lld a.o -T 2a.lds 2>&1 | FileCheck %s --check-prefix=ERR2
9+
# ERR2: error: 2a.lds:1: there is a cycle in linker script INCLUDEs
1010

11-
# CHECK: there is a cycle in linker script INCLUDEs
11+
# RUN: not ld.lld a.o -T 3.lds 2>&1 | FileCheck %s --check-prefix=ERR3
12+
# ERR3: error: 3.lds:2: there is a cycle in linker script INCLUDEs
1213

14+
#--- 0.lds
15+
BYTE(42)
16+
#--- 1.lds
17+
INCLUDE "1.lds"
18+
#--- 2a.lds
19+
INCLUDE "2b.lds"
20+
#--- 2b.lds
21+
INCLUDE "2a.lds"
22+
#--- 3.lds
23+
SECTIONS {
24+
foo : { INCLUDE "0.lds" INCLUDE "0.lds" }
25+
}
26+
27+
#--- a.s
1328
.globl _start
1429
_start:
1530
ret

0 commit comments

Comments
 (0)