Skip to content

Commit 270d95b

Browse files
committed
[ELF] Improve orphan placement tests
Merge orphan-align.test (which introduced `shouldSkip`) into orphan.s.
1 parent ded04bf commit 270d95b

File tree

3 files changed

+84
-85
lines changed

3 files changed

+84
-85
lines changed

lld/test/ELF/linkerscript/orphan-align.s

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

lld/test/ELF/linkerscript/orphan.s

Lines changed: 84 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,94 @@
11
# REQUIRES: x86
2-
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
3-
# RUN: echo "SECTIONS { \
4-
# RUN: .text : { *(.text) } \
5-
# RUN: .rw1 : { *(.rw1) } \
6-
# RUN: .rw2 : { *(.rw2) } \
7-
# RUN: .rw3 : { *(.rw3) } \
8-
# RUN: }" > %t.script
9-
# RUN: ld.lld -o %t1 --script %t.script %t
10-
# RUN: llvm-objdump --section-headers %t1 | FileCheck %s
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
114

125
## .jcr is a relro section and should be placed before other RW sections.
136
## .bss is SHT_NOBITS section and should be last RW section, so some space
147
## in ELF file could be saved.
15-
# CHECK: 0 00000000 0000000000000000
16-
# CHECK-NEXT: 1 .text 00000000 0000000000000000 TEXT
17-
# CHECK-NEXT: 2 .jcr 00000008 0000000000000000 DATA
18-
# CHECK-NEXT: 3 .rw1 00000008 0000000000000008 DATA
19-
# CHECK-NEXT: 4 .rw2 00000008 0000000000000010 DATA
20-
# CHECK-NEXT: 5 .rw3 00000008 0000000000000018 DATA
21-
# CHECK-NEXT: 6 .bss 00000008 0000000000000020 BSS
8+
# RUN: ld.lld a.o -T text-rw.lds -o text-rw
9+
# RUN: llvm-readelf -S text-rw | FileCheck %s --check-prefix=TEXT-RW
10+
# TEXT-RW: .interp PROGBITS 00000000000002{{..}} 0
11+
# TEXT-RW-NEXT: .note.my NOTE 00000000000002{{..}} 0
12+
# TEXT-RW-NEXT: .text PROGBITS 00000000000002{{..}} 0
13+
# TEXT-RW-NEXT: .mytext PROGBITS 00000000000002{{..}} 0
14+
# TEXT-RW-NEXT: .jcr PROGBITS 00000000000002{{..}} 0
15+
# TEXT-RW-NEXT: .rw1 PROGBITS 0000000000001{{...}} 0
16+
# TEXT-RW-NEXT: .rw2 PROGBITS 0000000000001{{...}} 0
17+
# TEXT-RW-NEXT: .rw3 PROGBITS 0000000000001{{...}} 0
18+
# TEXT-RW-NEXT: .bss NOBITS 0000000000001{{...}} 0
2219

23-
.section .rw1, "aw"
24-
.quad 0
20+
# RUN: ld.lld a.o -T only-text.lds -o only-text
21+
# RUN: llvm-readelf -S only-text | FileCheck %s --check-prefix=ONLY-TEXT
22+
# ONLY-TEXT: .interp PROGBITS 00000000000002{{..}} 0
23+
# ONLY-TEXT-NEXT: .note.my NOTE 00000000000002{{..}} 0
24+
# ONLY-TEXT-NEXT: .text PROGBITS 00000000000002{{..}} 0
25+
# ONLY-TEXT-NEXT: .mytext PROGBITS 00000000000002{{..}} 0
26+
# ONLY-TEXT-NEXT: .jcr PROGBITS 00000000000002{{..}} 0
27+
# ONLY-TEXT-NEXT: .rw1 PROGBITS 00000000000002{{..}} 0
28+
# ONLY-TEXT-NEXT: .rw2 PROGBITS 00000000000002{{..}} 0
29+
# ONLY-TEXT-NEXT: .rw3 PROGBITS 00000000000002{{..}} 0
30+
# ONLY-TEXT-NEXT: .bss NOBITS 00000000000002{{..}} 0
2531

26-
.section .rw2, "aw"
27-
.quad 0
32+
# RUN: ld.lld a.o -T text-align.lds -o text-align
33+
# RUN: llvm-readelf -S text-align | FileCheck %s --check-prefix=TEXT-ALIGN
34+
# TEXT-ALIGN: .interp PROGBITS 00000000000002{{..}} 0
35+
# TEXT-ALIGN-NEXT: .note.my NOTE 00000000000002{{..}} 0
36+
# TEXT-ALIGN-NEXT: .text PROGBITS 00000000000002{{..}} 0
37+
# TEXT-ALIGN-NEXT: .mytext PROGBITS 0000000000001000 0
38+
# TEXT-ALIGN-NEXT: .jcr PROGBITS 0000000000001{{...}} 0
39+
# TEXT-ALIGN-NEXT: .rw1 PROGBITS 0000000000001{{...}} 0
40+
# TEXT-ALIGN-NEXT: .rw2 PROGBITS 0000000000001{{...}} 0
41+
# TEXT-ALIGN-NEXT: .rw3 PROGBITS 0000000000001{{...}} 0
42+
# TEXT-ALIGN-NEXT: .bss NOBITS 0000000000001{{...}} 0
2843

29-
.section .rw3, "aw"
30-
.quad 0
44+
# RUN: ld.lld a.o -T only-rw.lds -o only-rw
45+
# RUN: llvm-readelf -S only-rw | FileCheck %s --check-prefix=ONLY-RW
46+
# ONLY-RW: .interp PROGBITS 00000000000002{{..}} 0
47+
# ONLY-RW-NEXT: .note.my NOTE 00000000000002{{..}} 0
48+
# ONLY-RW-NEXT: .text PROGBITS 00000000000002{{..}} 0
49+
# ONLY-RW-NEXT: .mytext PROGBITS 00000000000002{{..}} 0
50+
# ONLY-RW-NEXT: .jcr PROGBITS 00000000000002{{..}} 0
51+
# ONLY-RW-NEXT: .rw1 PROGBITS 00000000000002{{..}} 0
52+
# ONLY-RW-NEXT: .rw2 PROGBITS 0000000000001{{...}} 0
53+
# ONLY-RW-NEXT: .rw3 PROGBITS 0000000000001{{...}} 0
54+
# ONLY-RW-NEXT: .bss NOBITS 0000000000001{{...}} 0
3155

32-
.section .jcr, "aw"
33-
.quad 0
56+
#--- a.s
57+
.section .rw1, "aw"; .byte 0
58+
.section .rw2, "aw"; .byte 0
59+
.section .rw3, "aw"; .byte 0
60+
.section .jcr, "aw"; .byte 0
61+
.section .bss, "aw",@nobits; .byte 0
62+
.section .note.my, "a", @note; .byte 0
63+
.section .interp, "a", @progbits; .byte 0
64+
.text; nop
65+
.section .mytext,"ax"; nop
3466

35-
.section .bss, "aw",@nobits
36-
.quad 0
67+
#--- text-rw.lds
68+
SECTIONS {
69+
. = SIZEOF_HEADERS;
70+
.text : { *(.text) }
71+
. = ALIGN(CONSTANT(MAXPAGESIZE));
72+
.rw1 : { *(.rw1) }
73+
.rw2 : { *(.rw2) }
74+
}
75+
76+
#--- only-text.lds
77+
SECTIONS {
78+
. = SIZEOF_HEADERS;
79+
.text : { *(.text) }
80+
}
81+
82+
#--- text-align.lds
83+
SECTIONS {
84+
. = SIZEOF_HEADERS;
85+
.text : { *(.text) }
86+
. = ALIGN(CONSTANT(MAXPAGESIZE));
87+
}
88+
89+
#--- only-rw.lds
90+
SECTIONS {
91+
. = SIZEOF_HEADERS;
92+
.rw1 : { *(.rw1) }
93+
. = ALIGN(CONSTANT(MAXPAGESIZE));
94+
}

lld/test/ELF/linkerscript/orphans.s

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

0 commit comments

Comments
 (0)