150
|
1 // REQUIRES: x86
|
|
2 // RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s -o %t.o
|
|
3 // RUN: echo "SECTIONS { . = SIZEOF_HEADERS; .text : { *(.text) } }" > %t.script
|
|
4 // RUN: ld.lld -T %t.script %t.o -o %t
|
|
5 // RUN: llvm-readobj --symbols %t | FileCheck %s
|
|
6
|
|
7 // Test that _start is in the correct section.
|
|
8 // CHECK: Name: _start
|
173
|
9 // CHECK-NEXT: Value:
|
150
|
10 // CHECK-NEXT: Size: 0
|
|
11 // CHECK-NEXT: Binding: Global
|
|
12 // CHECK-NEXT: Type: None
|
|
13 // CHECK-NEXT: Other: 0
|
173
|
14 // CHECK-NEXT: Section: dn
|
|
15
|
|
16 // Show that --gc-sections works when there are many sections, and that
|
|
17 // referenced common and absolute symbols in such cases are not removed, nor are
|
|
18 // they incorrectly attributed to the sections with index 0xFFF1 or 0xFFF2.
|
|
19 // RUN: ld.lld %t.o -T %t.script -o %t --gc-sections
|
|
20 // RUN: llvm-readobj --symbols --sections %t | FileCheck %s --check-prefix=GC
|
|
21
|
|
22 // GC: Sections [
|
|
23 // GC-NEXT: Section {
|
|
24 // GC-NEXT: Index: 0
|
|
25 // GC-NEXT: Name: (0)
|
|
26 // GC: Section {
|
|
27 // GC-NEXT: Index: 1
|
|
28 // GC-NEXT: Name: dn
|
|
29 // GC: Section {
|
|
30 // GC-NEXT: Index: 2
|
|
31 // GC-NEXT: Name: .bss
|
|
32 // GC: Section {
|
|
33 // GC-NEXT: Index: 3
|
|
34 // GC-NEXT: Name: .comment
|
|
35 // GC: Section {
|
|
36 // GC-NEXT: Index: 4
|
|
37 // GC-NEXT: Name: .symtab
|
|
38 // GC: Section {
|
|
39 // GC-NEXT: Index: 5
|
|
40 // GC-NEXT: Name: .shstrtab
|
|
41 // GC: Section {
|
|
42 // GC-NEXT: Index: 6
|
|
43 // GC-NEXT: Name: .strtab
|
|
44 // GC-NOT: Section {
|
|
45
|
|
46 // GC: Symbols [
|
|
47 // GC-NEXT: Symbol {
|
|
48 // GC-NEXT: Name: (0)
|
|
49 // GC: Symbol {
|
|
50 // GC-NEXT: Name: sdn
|
|
51 // GC: Symbol {
|
|
52 // GC-NEXT: Name: _start
|
|
53 // GC: Symbol {
|
|
54 // GC-NEXT: Name: abs
|
|
55 // GC: Symbol {
|
|
56 // GC-NEXT: Name: common
|
|
57 // GC-NOT: Symbol {
|
150
|
58
|
|
59 .macro gen_sections4 x
|
|
60 .section a\x,"a"
|
173
|
61 .global sa\x
|
|
62 sa\x:
|
150
|
63 .section b\x,"a"
|
173
|
64 .global sa\x
|
|
65 sb\x:
|
150
|
66 .section c\x,"a"
|
173
|
67 .global sa\x
|
|
68 sc\x:
|
150
|
69 .section d\x,"a"
|
173
|
70 .global sa\x
|
|
71 sd\x:
|
150
|
72 .endm
|
|
73
|
|
74 .macro gen_sections8 x
|
|
75 gen_sections4 a\x
|
|
76 gen_sections4 b\x
|
|
77 .endm
|
|
78
|
|
79 .macro gen_sections16 x
|
|
80 gen_sections8 a\x
|
|
81 gen_sections8 b\x
|
|
82 .endm
|
|
83
|
|
84 .macro gen_sections32 x
|
|
85 gen_sections16 a\x
|
|
86 gen_sections16 b\x
|
|
87 .endm
|
|
88
|
|
89 .macro gen_sections64 x
|
|
90 gen_sections32 a\x
|
|
91 gen_sections32 b\x
|
|
92 .endm
|
|
93
|
|
94 .macro gen_sections128 x
|
|
95 gen_sections64 a\x
|
|
96 gen_sections64 b\x
|
|
97 .endm
|
|
98
|
|
99 .macro gen_sections256 x
|
|
100 gen_sections128 a\x
|
|
101 gen_sections128 b\x
|
|
102 .endm
|
|
103
|
|
104 .macro gen_sections512 x
|
|
105 gen_sections256 a\x
|
|
106 gen_sections256 b\x
|
|
107 .endm
|
|
108
|
|
109 .macro gen_sections1024 x
|
|
110 gen_sections512 a\x
|
|
111 gen_sections512 b\x
|
|
112 .endm
|
|
113
|
|
114 .macro gen_sections2048 x
|
|
115 gen_sections1024 a\x
|
|
116 gen_sections1024 b\x
|
|
117 .endm
|
|
118
|
|
119 .macro gen_sections4096 x
|
|
120 gen_sections2048 a\x
|
|
121 gen_sections2048 b\x
|
|
122 .endm
|
|
123
|
|
124 .macro gen_sections8192 x
|
|
125 gen_sections4096 a\x
|
|
126 gen_sections4096 b\x
|
|
127 .endm
|
|
128
|
|
129 .macro gen_sections16384 x
|
|
130 gen_sections8192 a\x
|
|
131 gen_sections8192 b\x
|
|
132 .endm
|
|
133
|
|
134 .macro gen_sections32768 x
|
|
135 gen_sections16384 a\x
|
|
136 gen_sections16384 b\x
|
|
137 .endm
|
|
138
|
|
139 gen_sections32768 a
|
|
140 gen_sections16384 b
|
|
141 gen_sections8192 c
|
|
142 gen_sections4096 d
|
|
143 gen_sections2048 e
|
|
144 gen_sections1024 f
|
|
145 gen_sections512 g
|
173
|
146 gen_sections256 h
|
|
147 gen_sections128 i
|
|
148 gen_sections64 j
|
|
149 gen_sections32 k
|
|
150 gen_sections16 l
|
|
151 gen_sections8 m
|
|
152 gen_sections4 n
|
|
153
|
|
154 .global abs
|
|
155 abs = 0x12345678
|
|
156
|
|
157 .comm common,4,4
|
150
|
158
|
|
159 .global _start
|
|
160 _start:
|
173
|
161 .quad abs
|
|
162 .quad common
|