Test for push being relaxed.
[oota-llvm.git] / test / MC / ELF / relocation-386.s
1 // RUN: llvm-mc -filetype=obj -triple i386-pc-linux-gnu %s -o - | elf-dump | FileCheck  %s
2
3 // Test that we produce the correct relocation types and that the relocations
4 // correctly point to the section or the symbol.
5
6 // Section 3 is bss
7 // CHECK:      # Section 0x00000003
8 // CHECK-NEXT: (('sh_name', 0x0000000d) # '.bss'
9
10 // CHECK:      # Symbol 0x00000001
11 // CHECK-NEXT: (('st_name', 0x00000005) # '.Lfoo'
12
13 // Symbol 4 is zed
14 // CHECK:      # Symbol 0x00000004
15 // CHECK-NEXT: (('st_name', 0x00000035) # 'zed'
16 // CHECK-NEXT:  ('st_value', 0x00000000)
17 // CHECK-NEXT:  ('st_size', 0x00000000)
18 // CHECK-NEXT:  ('st_bind', 0x00000000)
19 // CHECK-NEXT:  ('st_type', 0x00000006)
20 // CHECK-NEXT:  ('st_other', 0x00000000)
21 // CHECK-NEXT:  ('st_shndx', 0x00000004)
22
23 // Symbol 7 is section 3
24 // CHECK:      # Symbol 0x00000007
25 // CHECK-NEXT: (('st_name', 0x00000000) # ''
26 // CHECK-NEXT:  ('st_value', 0x00000000)
27 // CHECK-NEXT:  ('st_size', 0x00000000)
28 // CHECK-NEXT:  ('st_bind', 0x00000000)
29 // CHECK-NEXT:  ('st_type', 0x00000003)
30 // CHECK-NEXT:  ('st_other', 0x00000000)
31 // CHECK-NEXT:  ('st_shndx', 0x00000003)
32
33 // CHECK:      # Relocation 0x00000000
34 // CHECK-NEXT: (('r_offset', 0x00000002)
35 // CHECK-NEXT:  ('r_sym', 0x00000001)
36 // CHECK-NEXT:  ('r_type', 0x00000009)
37 // CHECK-NEXT: ),
38 // CHECK-NEXT:  # Relocation 0x00000001
39 // CHECK-NEXT: (('r_offset',
40 // CHECK-NEXT:  ('r_sym',
41 // CHECK-NEXT:  ('r_type', 0x00000004)
42 // CHECK-NEXT: ),
43 // CHECK-NEXT:  # Relocation 0x00000002
44 // CHECK-NEXT: (('r_offset',
45 // CHECK-NEXT:  ('r_sym',
46 // CHECK-NEXT:  ('r_type', 0x0000000a)
47 // CHECK-NEXT: ),
48
49 // Relocation 3 (bar3@GOTOFF) is done with symbol 7 (bss)
50 // CHECK-NEXT:  # Relocation 0x00000003
51 // CHECK-NEXT: (('r_offset',
52 // CHECK-NEXT:  ('r_sym', 0x00000007
53 // CHECK-NEXT:  ('r_type',
54 // CHECK-NEXT: ),
55
56 // Relocation 4 (bar2@GOT) is of type R_386_GOT32
57 // CHECK-NEXT:  # Relocation 0x00000004
58 // CHECK-NEXT: (('r_offset',
59 // CHECK-NEXT:  ('r_sym',
60 // CHECK-NEXT:  ('r_type', 0x00000003
61 // CHECK-NEXT: ),
62
63 // Relocation 5 (foo@TLSGD) is of type R_386_TLS_GD
64 // CHECK-NEXT: # Relocation 0x00000005
65 // CHECK-NEXT: (('r_offset', 0x00000020)
66 // CHECK-NEXT:  ('r_sym', 0x0000000d)
67 // CHECK-NEXT:  ('r_type', 0x00000012)
68 // CHECK-NEXT: ),
69
70 // Relocation 6 ($foo@TPOFF) is of type R_386_TLS_LE_32
71 // CHECK-NEXT: # Relocation 0x00000006
72 // CHECK-NEXT: (('r_offset', 0x00000025)
73 // CHECK-NEXT:  ('r_sym', 0x0000000d)
74 // CHECK-NEXT:  ('r_type', 0x00000022)
75 // CHECK-NEXT: ),
76
77 // Relocation 7 (foo@INDNTPOFF) is of type R_386_TLS_IE
78 // CHECK-NEXT: # Relocation 0x00000007
79 // CHECK-NEXT: (('r_offset', 0x0000002b)
80 // CHECK-NEXT:  ('r_sym', 0x0000000d)
81 // CHECK-NEXT:  ('r_type', 0x0000000f)
82 // CHECK-NEXT: ),
83
84 // Relocation 8 (foo@NTPOFF) is of type R_386_TLS_LE
85 // CHECK-NEXT: # Relocation 0x00000008
86 // CHECK-NEXT: (('r_offset', 0x00000031)
87 // CHECK-NEXT:  ('r_sym', 0x0000000d)
88 // CHECK-NEXT:  ('r_type', 0x00000011)
89 // CHECK-NEXT: ),
90
91 // Relocation 9 (foo@GOTNTPOFF) is of type R_386_TLS_GOTIE
92 // CHECK-NEXT: # Relocation 0x00000009
93 // CHECK-NEXT: (('r_offset', 0x00000037)
94 // CHECK-NEXT:  ('r_sym', 0x0000000d)
95 // CHECK-NEXT:  ('r_type', 0x00000010)
96 // CHECK-NEXT: ),
97
98 // Relocation 10 (foo@TLSLDM) is of type R_386_TLS_LDM
99 // CHECK-NEXT: # Relocation 0x0000000a
100 // CHECK-NEXT: (('r_offset', 0x0000003d)
101 // CHECK-NEXT:  ('r_sym', 0x0000000d)
102 // CHECK-NEXT:  ('r_type', 0x00000013)
103 // CHECK-NEXT: ),
104
105 // Relocation 11 (foo@DTPOFF) is of type R_386_TLS_LDO_32
106 // CHECK-NEXT: # Relocation 0x0000000b
107 // CHECK-NEXT: (('r_offset', 0x00000043)
108 // CHECK-NEXT:  ('r_sym', 0x0000000d)
109 // CHECK-NEXT:  ('r_type', 0x00000020)
110 // CHECK-NEXT: ),
111 // Relocation 12 (calll 4096) is of type R_386_PC32
112 // CHECK-NEXT: # Relocation 0x0000000c
113 // CHECK-NEXT: (('r_offset', 0x00000048)
114 // CHECK-NEXT:  ('r_sym', 0x00000000)
115 // CHECK-NEXT:  ('r_type', 0x00000002)
116 // CHECK-NEXT: ),
117 // Relocation 13 (zed@GOT) is of type R_386_GOT32 and uses the symbol
118 // CHECK-NEXT: # Relocation 0x0000000d
119 // CHECK-NEXT: (('r_offset', 0x0000004e)
120 // CHECK-NEXT:  ('r_sym', 0x00000004)
121 // CHECK-NEXT:  ('r_type', 0x00000003)
122 // CHECK-NEXT: ),
123 // Relocation 14 (zed@GOTOFF) is of type R_386_GOTOFF and uses the symbol
124 // CHECK-NEXT: # Relocation 0x0000000e
125 // CHECK-NEXT: (('r_offset', 0x00000054)
126 // CHECK-NEXT:  ('r_sym', 0x00000004)
127 // CHECK-NEXT:  ('r_type', 0x00000009)
128 // CHECK-NEXT: ),
129 // Relocation 15 (zed@INDNTPOFF) is of type R_386_TLS_IE and uses the symbol
130 // CHECK-NEXT: # Relocation 0x0000000f
131 // CHECK-NEXT: (('r_offset', 0x0000005a)
132 // CHECK-NEXT:  ('r_sym', 0x00000004)
133 // CHECK-NEXT:  ('r_type', 0x0000000f)
134 // CHECK-NEXT: ),
135 // Relocation 16 (zed@NTPOFF) is of type R_386_TLS_LE and uses the symbol
136 // CHECK-NEXT: # Relocation 0x00000010
137 // CHECK-NEXT: (('r_offset', 0x00000060)
138 // CHECK-NEXT:  ('r_sym', 0x00000004)
139 // CHECK-NEXT:  ('r_type', 0x00000011)
140 // CHECK-NEXT: ),
141 // Relocation 17 (zed@GOTNTPOFF) is of type R_386_TLS_GOTIE and uses the symbol
142 // CHECK-NEXT: # Relocation 0x00000011
143 // CHECK-NEXT: (('r_offset', 0x00000066)
144 // CHECK-NEXT:  ('r_sym', 0x00000004)
145 // CHECK-NEXT:  ('r_type', 0x00000010)
146 // CHECK-NEXT: ),
147 // Relocation 18 (zed@PLT) is of type R_386_PLT32 and uses the symbol
148 // CHECK-NEXT: # Relocation 0x00000012
149 // CHECK-NEXT: (('r_offset', 0x0000006b)
150 // CHECK-NEXT:  ('r_sym', 0x00000004)
151 // CHECK-NEXT:  ('r_type', 0x00000004)
152 // CHECK-NEXT: ),
153 // Relocation 19 (zed@TLSGD) is of type R_386_TLS_GD and uses the symbol
154 // CHECK-NEXT: # Relocation 0x00000013
155 // CHECK-NEXT: (('r_offset', 0x00000071)
156 // CHECK-NEXT:  ('r_sym', 0x00000004)
157 // CHECK-NEXT:  ('r_type', 0x00000012)
158 // CHECK-NEXT: ),
159 // Relocation 20 (zed@TLSLDM) is of type R_386_TLS_LDM and uses the symbol
160 // CHECK-NEXT: # Relocation 0x00000014
161 // CHECK-NEXT: (('r_offset', 0x00000077)
162 // CHECK-NEXT:  ('r_sym', 0x00000004)
163 // CHECK-NEXT:  ('r_type', 0x00000013)
164 // CHECK-NEXT: ),
165 // Relocation 21 (zed@TPOFF) is of type R_386_TLS_LE_32 and uses the symbol
166 // CHECK-NEXT:# Relocation 0x00000015
167 // CHECK-NEXT: (('r_offset', 0x0000007d)
168 // CHECK-NEXT:  ('r_sym', 0x00000004)
169 // CHECK-NEXT:  ('r_type', 0x00000022)
170 // CHECK-NEXT: ),
171 // Relocation 22 (zed@DTPOFF) is of type R_386_TLS_LDO_32 and uses the symbol
172 // CHECK-NEXT: Relocation 0x00000016
173 // CHECK-NEXT: (('r_offset', 0x00000083)
174 // CHECK-NEXT:  ('r_sym', 0x00000004)
175 // CHECK-NEXT:  ('r_type', 0x00000020)
176 // CHECK-NEXT: ),
177 // Relocation 23 ($bar) is of type R_386_32 and uses the section
178 // CHECK-NEXT: Relocation 0x00000017
179 // CHECK-NEXT: (('r_offset',
180 // CHECK-NEXT:  ('r_sym',
181 // CHECK-NEXT:  ('r_type', 0x00000001)
182 // CHECK-NEXT: ),
183
184         .text
185 bar:
186         leal    .Lfoo@GOTOFF(%ebx), %eax
187
188         .global bar2
189 bar2:
190         calll   bar2@PLT
191         addl    $_GLOBAL_OFFSET_TABLE_, %ebx
192         movb    bar3@GOTOFF(%ebx), %al
193
194         .type   bar3,@object
195         .local  bar3
196         .comm   bar3,1,1
197
198         movl    bar2j@GOT(%eax), %eax
199
200         leal foo@TLSGD(, %ebx,1), %eax
201         movl $foo@TPOFF, %edx
202         movl foo@INDNTPOFF, %ecx
203         addl foo@NTPOFF(%eax), %eax
204         addl foo@GOTNTPOFF(%ebx), %ecx
205         leal foo@TLSLDM(%ebx), %eax
206         leal foo@DTPOFF(%eax), %edx
207         calll 4096
208         movl zed@GOT(%eax), %eax
209         movl zed@GOTOFF(%eax), %eax
210         movl zed@INDNTPOFF(%eax), %eax
211         movl zed@NTPOFF(%eax), %eax
212         movl zed@GOTNTPOFF(%eax), %eax
213         call zed@PLT
214         movl zed@TLSGD(%eax), %eax
215         movl zed@TLSLDM(%eax), %eax
216         movl zed@TPOFF(%eax), %eax
217         movl zed@DTPOFF(%eax), %eax
218         pushl $bar
219
220         .section        zedsec,"awT",@progbits
221 zed:
222         .long 0
223
224         .section        .rodata.str1.16,"aMS",@progbits,1
225 .Lfoo:
226         .asciz   "bool llvm::llvm_start_multithreaded()"