[ELF] Make section member orders consistent
[llvm-project.git] / lld / test / ELF / many-sections.s
blob81be8a464aaac23a7bf0e385624e1c3556feedea
1 // REQUIRES: x86
2 // RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s -o %t
3 // RUN: llvm-readobj --symbols %t | FileCheck %s
5 // Verify that the symbol _start is in a section with an index >= SHN_LORESERVE.
6 // CHECK: Name: _start
7 // CHECK-NEXT: Value: 0x0
8 // CHECK-NEXT: Size: 0
9 // CHECK-NEXT: Binding: Global
10 // CHECK-NEXT: Type: None
11 // CHECK-NEXT: Other: 0
12 // CHECK-NEXT: Section: dm (0xFF00)
14 // RUN: ld.lld %t -o %t2
15 // RUN: llvm-readobj --symbols %t2 | FileCheck --check-prefix=LINKED %s
17 // Test also with a linker script.
18 // RUN: echo "SECTIONS { . = SIZEOF_HEADERS; .text : { *(.text) } }" > %t.script
19 // RUN: ld.lld -T %t.script %t -o %t2
20 // RUN: llvm-readobj --symbols %t2 | FileCheck --check-prefix=LINKED %s
22 // Test that _start is in the correct section.
23 // LINKED: Name: _start
24 // LINKED-NEXT: Value: 0x0
25 // LINKED-NEXT: Size: 0
26 // LINKED-NEXT: Binding: Global
27 // LINKED-NEXT: Type: None
28 // LINKED-NEXT: Other: 0
29 // LINKED-NEXT: Section: dm
31 .macro gen_sections4 x
32 .section a\x
33 .section b\x
34 .section c\x
35 .section d\x
36 .endm
38 .macro gen_sections8 x
39 gen_sections4 a\x
40 gen_sections4 b\x
41 .endm
43 .macro gen_sections16 x
44 gen_sections8 a\x
45 gen_sections8 b\x
46 .endm
48 .macro gen_sections32 x
49 gen_sections16 a\x
50 gen_sections16 b\x
51 .endm
53 .macro gen_sections64 x
54 gen_sections32 a\x
55 gen_sections32 b\x
56 .endm
58 .macro gen_sections128 x
59 gen_sections64 a\x
60 gen_sections64 b\x
61 .endm
63 .macro gen_sections256 x
64 gen_sections128 a\x
65 gen_sections128 b\x
66 .endm
68 .macro gen_sections512 x
69 gen_sections256 a\x
70 gen_sections256 b\x
71 .endm
73 .macro gen_sections1024 x
74 gen_sections512 a\x
75 gen_sections512 b\x
76 .endm
78 .macro gen_sections2048 x
79 gen_sections1024 a\x
80 gen_sections1024 b\x
81 .endm
83 .macro gen_sections4096 x
84 gen_sections2048 a\x
85 gen_sections2048 b\x
86 .endm
88 .macro gen_sections8192 x
89 gen_sections4096 a\x
90 gen_sections4096 b\x
91 .endm
93 .macro gen_sections16384 x
94 gen_sections8192 a\x
95 gen_sections8192 b\x
96 .endm
98 .macro gen_sections32768 x
99 gen_sections16384 a\x
100 gen_sections16384 b\x
101 .endm
103 .bss
104 .section bar
106 gen_sections32768 a
107 gen_sections16384 b
108 gen_sections8192 c
109 gen_sections4096 d
110 gen_sections2048 e
111 gen_sections1024 f
112 gen_sections512 g
113 gen_sections128 h
114 gen_sections64 i
115 gen_sections32 j
116 gen_sections16 k
117 gen_sections8 l
118 gen_sections4 m
120 .global _start
121 _start: