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