|
25 | 25 | # SEC-DEFAULT: 7 .shstrtab 0000003b {{[0-9a-f]*}}
|
26 | 26 | # SEC-DEFAULT: 8 .strtab 00000008 {{[0-9a-f]*}}
|
27 | 27 |
|
28 |
| -## Sections are placed in the order specified by the linker script. .data has |
29 |
| -## a PT_LOAD segment, even if it is preceded by a non-alloc section. To |
30 |
| -## allow this, place non-alloc orphan sections at the end and advance |
31 |
| -## location counters for non-alloc non-orphan sections. |
| 28 | +# Sections are put in order specified in linker script, other than alloc |
| 29 | +# sections going first. |
32 | 30 | # RUN: echo "SECTIONS { \
|
33 | 31 | # RUN: .bss : { *(.bss) } \
|
34 | 32 | # RUN: other : { *(other) } \
|
35 | 33 | # RUN: .shstrtab : { *(.shstrtab) } \
|
36 | 34 | # RUN: .symtab : { *(.symtab) } \
|
37 | 35 | # RUN: .strtab : { *(.strtab) } \
|
38 | 36 | # RUN: .data : { *(.data) } \
|
39 |
| -# RUN: .text : { *(.text) } }" > %t3.lds |
40 |
| -# RUN: ld.lld -o %t3a -T %t3.lds %t |
41 |
| -# RUN: llvm-readelf -S -l %t3a | FileCheck --check-prefix=SEC-ORDER %s |
42 |
| -# RUN: ld.lld -o %t3b -T %t3.lds --unique %t |
43 |
| -# RUN: llvm-readelf -S -l %t3b | FileCheck --check-prefix=SEC-ORDER %s |
| 37 | +# RUN: .text : { *(.text) } }" > %t.script |
| 38 | +# RUN: ld.lld -o %t3 --script %t.script %t |
| 39 | +# RUN: llvm-objdump --section-headers %t3 | \ |
| 40 | +# RUN: FileCheck -check-prefix=SEC-ORDER %s |
44 | 41 |
|
45 |
| -# SEC-ORDER: [Nr] Name Type Address Off Size ES Flg |
46 |
| -# SEC-ORDER: [ 0] NULL 0000000000000000 000000 000000 00 |
47 |
| -# SEC-ORDER-NEXT: [ 1] .bss NOBITS 0000000000000000 001000 000002 00 WA |
48 |
| -# SEC-ORDER-NEXT: [ 2] other PROGBITS 0000000000000002 001002 000003 00 WA |
49 |
| -# SEC-ORDER-NEXT: [ 3] .shstrtab STRTAB 0000000000000005 001005 00003b 00 |
50 |
| -# SEC-ORDER-NEXT: [ 4] .symtab SYMTAB 0000000000000040 001040 000030 18 |
51 |
| -# SEC-ORDER-NEXT: [ 5] .strtab STRTAB 0000000000000070 001070 000008 00 |
52 |
| -# SEC-ORDER-NEXT: [ 6] .data PROGBITS 0000000000000078 001078 000020 00 WA |
53 |
| -# SEC-ORDER-NEXT: [ 7] .text PROGBITS 0000000000000098 001098 00000e 00 AX |
54 |
| -# SEC-ORDER-NEXT: [ 8] .comment PROGBITS 0000000000000000 0010a6 000008 01 MS |
55 |
| - |
56 |
| -# SEC-ORDER: Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align |
57 |
| -# SEC-ORDER-NEXT: LOAD 0x001000 0x0000000000000000 0x0000000000000000 0x000098 0x000098 RW 0x1000 |
58 |
| -# SEC-ORDER-NEXT: LOAD 0x001098 0x0000000000000098 0x0000000000000098 0x00000e 0x00000e R E 0x1000 |
59 |
| -# SEC-ORDER-NEXT: GNU_STACK 0x000000 0x0000000000000000 0x0000000000000000 0x000000 0x000000 RW 0 |
| 42 | +# Idx Name Size |
| 43 | +# SEC-ORDER: 1 .bss 00000002 {{[0-9a-f]*}} BSS |
| 44 | +# SEC-ORDER: 2 other 00000003 {{[0-9a-f]*}} DATA |
| 45 | +# SEC-ORDER: 3 .shstrtab 0000003b {{[0-9a-f]*}} |
| 46 | +# SEC-ORDER: 4 .symtab 00000030 {{[0-9a-f]*}} |
| 47 | +# SEC-ORDER: 5 .strtab 00000008 {{[0-9a-f]*}} |
| 48 | +# SEC-ORDER: 6 .comment 00000008 {{[0-9a-f]*}} |
| 49 | +# SEC-ORDER: 7 .data 00000020 {{[0-9a-f]*}} DATA |
| 50 | +# SEC-ORDER: 8 .text 0000000e {{[0-9a-f]*}} TEXT |
60 | 51 |
|
61 | 52 | # .text and .data have swapped names but proper sizes and types.
|
62 | 53 | # RUN: echo "SECTIONS { \
|
|
98 | 89 | # SEC-MULTI-NEXT: .shstrtab 00000035 {{[0-9a-f]*}}
|
99 | 90 | # SEC-MULTI-NEXT: .strtab 00000008 {{[0-9a-f]*}}
|
100 | 91 |
|
101 |
| -## other is placed in a PT_LOAD segment even if it is preceded by a non-alloc section. |
102 |
| -## The current implementation places .data, .bss, .comment and other in the same PT_LOAD. |
103 |
| -# RUN: echo 'SECTIONS { \ |
104 |
| -# RUN: .text : { *(.text) } \ |
105 |
| -# RUN: .data : { *(.data) } \ |
106 |
| -# RUN: .comment : { *(.comment) } \ |
107 |
| -# RUN: other : { *(other) } }' > %t5.lds |
108 |
| -# RUN: ld.lld -o %t5 -T %t5.lds %t |
109 |
| -# RUN: llvm-readelf -S -l %t5 | FileCheck --check-prefix=SEP-BY-NONALLOC %s |
110 |
| - |
111 |
| -# SEP-BY-NONALLOC: [Nr] Name Type Address Off Size ES Flg |
112 |
| -# SEP-BY-NONALLOC: [ 1] .text PROGBITS 0000000000000000 001000 00000e 00 AX |
113 |
| -# SEP-BY-NONALLOC-NEXT: [ 2] .data PROGBITS 000000000000000e 00100e 000020 00 WA |
114 |
| -# SEP-BY-NONALLOC-NEXT: [ 3] .bss NOBITS 000000000000002e 00102e 000002 00 WA |
115 |
| -# SEP-BY-NONALLOC-NEXT: [ 4] .comment PROGBITS 0000000000000030 00102e 000008 01 MS |
116 |
| -# SEP-BY-NONALLOC-NEXT: [ 5] other PROGBITS 0000000000000038 001038 000003 00 WA |
117 |
| - |
118 |
| -# SEP-BY-NONALLOC: Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align |
119 |
| -# SEP-BY-NONALLOC-NEXT: LOAD 0x001000 0x0000000000000000 0x0000000000000000 0x00000e 0x00000e R E 0x1000 |
120 |
| -# SEP-BY-NONALLOC-NEXT: LOAD 0x00100e 0x000000000000000e 0x000000000000000e 0x00002d 0x00002d RW 0x1000 |
121 |
| -# SEP-BY-NONALLOC-NEXT: GNU_STACK 0x000000 0x0000000000000000 0x0000000000000000 0x000000 0x000000 RW 0 |
122 |
| - |
123 | 92 | # Input section pattern contains additional semicolon.
|
124 | 93 | # Case found in linux kernel script. Check we are able to parse it.
|
125 | 94 | # RUN: echo "SECTIONS { .text : { ;;*(.text);;S = 0;; } }" > %t.script
|
|
0 commit comments