Skip to content

Commit 667e7ba

Browse files
committed
Add tests
Created using spr 1.3.6-beta.1
1 parent c420199 commit 667e7ba

File tree

4 files changed

+98
-6
lines changed

4 files changed

+98
-6
lines changed

lld/test/ELF/shuffle-padding-bss.s

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# REQUIRES: x86
2+
# RUN: llvm-mc -filetype=obj -triple=x86_64 %s -o %t.o
3+
4+
## --shuffle-padding= inserts segment offset padding and pre-section padding,
5+
## and does not affect .bss flags.
6+
# RUN: ld.lld --shuffle-padding=1 %t.o -o %t.out
7+
# RUN: llvm-readelf -sS %t.out | FileCheck --check-prefix=HEADER %s
8+
# HEADER: .bss NOBITS 0000000000202580 000580 000f90 00 WA 0 0 1
9+
# HEADER: 1: 000000000020350c 0 NOTYPE LOCAL DEFAULT 2 a
10+
# HEADER: 2: 000000000020350e 0 NOTYPE LOCAL DEFAULT 2 b
11+
# HEADER: 3: 000000000020350f 0 NOTYPE LOCAL DEFAULT 2 c
12+
13+
.section .bss.a,"a",@nobits
14+
a:
15+
.zero 1
16+
17+
.section .bss.b,"a",@nobits
18+
b:
19+
.zero 1
20+
21+
.section .bss.c,"a",@nobits
22+
c:
23+
.zero 1
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# REQUIRES: x86
2+
# RUN: llvm-mc -filetype=obj -triple=x86_64 %s -o %t.o
3+
4+
# RUN: ld.lld %t.o -o %t.out
5+
# RUN: llvm-readelf -x .data %t.out | FileCheck %s
6+
# CHECK: Hex dump of section '.data':
7+
# CHECK-NEXT: 0x00202158 010203
8+
9+
## --shuffle-padding= inserts segment offset padding and pre-section padding.
10+
# RUN: ld.lld --shuffle-padding=1 %t.o -o %t.out
11+
# RUN: llvm-readelf -x .data %t.out | FileCheck --check-prefix=PAD1 %s
12+
# PAD1: Hex dump of section '.data':
13+
# PAD1: 0x00203500 00000000 00000000 00000000 01000203
14+
15+
## --shuffle-padding= does not affect .rodata flags.
16+
# RUN: llvm-readelf -S %t.out | FileCheck --check-prefix=HEADER %s
17+
# HEADER: .data PROGBITS 0000000000202580 000580 000f90 00 WA 0 0 1
18+
19+
## Size of segment offset padding and location of pre-section padding is
20+
## dependent on the seed.
21+
# RUN: ld.lld --shuffle-padding=2 %t.o -o %t.out
22+
# RUN: llvm-readelf -x .data %t.out | FileCheck --check-prefix=PAD2 %s
23+
# PAD2: Hex dump of section '.data':
24+
# PAD2: 0x002037e0 00000000 00000000 00000000 00010203
25+
26+
.section .data.a,"aw",@progbits
27+
a:
28+
.byte 1
29+
30+
.section .data.b,"aw",@progbits
31+
b:
32+
.byte 2
33+
34+
.section .data.c,"aw",@progbits
35+
c:
36+
.byte 3
Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,33 @@
44
# RUN: ld.lld %t.o -o %t.out
55
# RUN: llvm-readelf -x .rodata %t.out | FileCheck %s
66
# CHECK: Hex dump of section '.rodata':
7-
# CHECK-NEXT: 0x00201120 010203
7+
# CHECK-NEXT: 0x00200120 010203
88

99
## --shuffle-padding= inserts segment offset padding and pre-section padding.
1010
# RUN: ld.lld --shuffle-padding=1 %t.o -o %t.out
1111
# RUN: llvm-readelf -x .rodata %t.out | FileCheck --check-prefix=PAD1 %s
1212
# PAD1: Hex dump of section '.rodata':
13-
# PAD1-NEXT: 0x00201548 0102cc03
13+
# PAD1: 0x00200540 00000000 00010203
14+
15+
## --shuffle-padding= does not affect .rodata flags.
16+
# RUN: llvm-readelf -S %t.out | FileCheck --check-prefix=HEADER %s
17+
# HEADER: .rodata PROGBITS 0000000000200120 000120 000428 00 A 0 0 1
1418

1519
## Size of segment offset padding and location of pre-section padding is
1620
## dependent on the seed.
1721
# RUN: ld.lld --shuffle-padding=2 %t.o -o %t.out
1822
# RUN: llvm-readelf -x .rodata %t.out | FileCheck --check-prefix=PAD2 %s
1923
# PAD2: Hex dump of section '.rodata':
20-
# PAD2-NEXT: 0x00201dc8 cc010203
24+
# PAD2: 0x00200dc0 00000000 00000000 01000203
2125

22-
.section .rodata.a,"ax"
26+
.section .rodata.a,"a",@progbits
27+
a:
2328
.byte 1
2429

25-
.section .rodata.b,"ax"
30+
.section .rodata.b,"a",@progbits
31+
b:
2632
.byte 2
2733

28-
.section .rodata.c,"ax"
34+
.section .rodata.c,"a",@progbits
35+
c:
2936
.byte 3
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# REQUIRES: x86
2+
# RUN: llvm-mc -filetype=obj -triple=x86_64 %s -o %t.o
3+
4+
# RUN: ld.lld %t.o -o %t.out
5+
# RUN: llvm-readelf -x .text %t.out | FileCheck %s
6+
# CHECK: Hex dump of section '.text':
7+
# CHECK-NEXT: 0x00201120 010203
8+
9+
## --shuffle-padding= inserts segment offset padding and pre-section padding.
10+
# RUN: ld.lld --shuffle-padding=1 %t.o -o %t.out
11+
# RUN: llvm-readelf -x .text %t.out | FileCheck --check-prefix=PAD1 %s
12+
# PAD1: Hex dump of section '.text':
13+
# PAD1: 0x00201540 cccccccc cccccccc 0102cc03
14+
15+
## --shuffle-padding= does not affect .text flags.
16+
# RUN: llvm-readelf -S %t.out | FileCheck --check-prefix=HEADER %s
17+
# HEADER: .text PROGBITS 0000000000201120 000120 00042c 00 AX 0 0 4
18+
19+
.section .text.a,"ax"
20+
.byte 1
21+
22+
.section .text.b,"ax"
23+
.byte 2
24+
25+
.section .text.c,"ax"
26+
.byte 3

0 commit comments

Comments
 (0)