Skip to content

Commit 167cad5

Browse files
committed
[ELF] Improve ADDR tests
Merge some test files. The "undefined section" error (`checkIfExists`) was previously untested.
1 parent 8247068 commit 167cad5

File tree

4 files changed

+49
-58
lines changed

4 files changed

+49
-58
lines changed

lld/test/ELF/linkerscript/addr.test

Lines changed: 49 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,54 @@
11
# REQUIRES: x86
2-
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/addr.s -o %t
3-
# RUN: ld.lld %t --script %s -o %t1
4-
# RUN: llvm-objdump --section-headers %t1 | FileCheck %s
5-
6-
# CHECK: Sections:
7-
# CHECK-NEXT: Idx Name Size VMA Type
8-
# CHECK-NEXT: 0 00000000 0000000000000000
9-
# CHECK-NEXT: 1 .text 00000000 0000000000001000 TEXT
10-
# CHECK-NEXT: 2 .foo.1 00000008 0000000000001000 DATA
11-
# CHECK-NEXT: 3 .foo.2 00000008 0000000000001100 DATA
12-
# CHECK-NEXT: 4 .foo.3 00000008 0000000000001108 DATA
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
4+
# RUN: ld.lld a.o -T a.lds -o a
5+
# RUN: llvm-readelf -Ss a | FileCheck %s
136

7+
# CHECK: .text PROGBITS 0000000000001000 001000
8+
# CHECK-NEXT: .foo-1 PROGBITS 0000000000001001 001001
9+
# CHECK-NEXT: .foo-2 PROGBITS 0000000000001101 001101
10+
# CHECK-NEXT: .foo-3 PROGBITS 0000000000001102 001102
11+
12+
# CHECK: 0000000000001001 0 NOTYPE GLOBAL DEFAULT 1 x1
13+
# CHECK-NEXT: 0000000000001001 0 NOTYPE GLOBAL DEFAULT 1 x2
14+
# CHECK-NEXT: 0000000000001000 0 NOTYPE GLOBAL DEFAULT 1 x3
15+
16+
## TODO Fix duplicate errors
17+
# RUN: not ld.lld a.o -T absent.lds 2>&1 | FileCheck %s --check-prefix=ABSENT --implicit-check-not=error:
18+
# ABSENT-COUNT-2: error: absent.lds:3: undefined section .aaa
19+
20+
## TODO Fix duplicate errors
21+
# RUN: not ld.lld a.o -T absolute.lds 2>&1 | FileCheck %s --check-prefix=ABSOLUTE --implicit-check-not=error:
22+
# ABSOLUTE-COUNT-4: error: absolute.lds:2: at least one side of the expression must be absolute
23+
24+
#--- a.s
25+
.globl _start
26+
_start: nop
27+
28+
.section .foo-1,"a"; .byte 1
29+
.section .foo-2,"a"; .byte 2
30+
.section .foo-3,"a"; .byte 3
31+
32+
#--- a.lds
1433
SECTIONS {
1534
. = 0x1000;
16-
.text : { *(.text*) }
17-
.foo.1 : { *(.foo.1) }
18-
.foo.2 ADDR(.foo.1) + 0x100 : { *(.foo.2) }
19-
.foo.3 : { *(.foo.3) }
35+
.text : {
36+
*(.text*)
37+
x1 = ADDR(.text) + 1; x2 = 1 + ADDR(.text);
38+
x3 = ADDR(.text) & 0xffff;
39+
}
40+
.foo-1 : { *(.foo-1) }
41+
.foo-2 ADDR(.foo-1) + 0x100 : { *(.foo-2) }
42+
.foo-3 : { *(.foo-3) }
43+
}
44+
45+
#--- absent.lds
46+
SECTIONS {
47+
. = 0x1000;
48+
_aaa = ADDR(.aaa);
49+
}
50+
51+
#--- absolute.lds
52+
SECTIONS {
53+
foo = ADDR(.text) + ADDR(.text);
2054
}

lld/test/ELF/linkerscript/expr-invalid-sec.test

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

lld/test/ELF/linkerscript/expr-sections.test

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

lld/test/ELF/linkerscript/parse-section-in-addr.test

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

0 commit comments

Comments
 (0)