Commit | Line | Data |
---|---|---|
252b5132 RH |
1 | /* 32-bit ELF support for ARM new abi option. |
2 | Copyright 1999 Free Software Foundation, Inc. | |
3 | ||
4 | This file is part of BFD, the Binary File Descriptor library. | |
5 | ||
6 | This program is free software; you can redistribute it and/or modify | |
7 | it under the terms of the GNU General Public License as published by | |
8 | the Free Software Foundation; either version 2 of the License, or | |
9 | (at your option) any later version. | |
10 | ||
11 | This program is distributed in the hope that it will be useful, | |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | GNU General Public License for more details. | |
15 | ||
16 | You should have received a copy of the GNU General Public License | |
17 | along with this program; if not, write to the Free Software | |
18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ | |
19 | ||
20 | #include "elf/arm.h" | |
21 | #include "bfd.h" | |
22 | #include "sysdep.h" | |
23 | #include "libbfd.h" | |
24 | #include "elf-bfd.h" | |
25 | ||
26 | #ifndef NUM_ELEM | |
27 | #define NUM_ELEM(a) (sizeof (a) / (sizeof (a)[0])) | |
28 | #endif | |
29 | ||
30 | #define USE_REL | |
31 | ||
32 | #define TARGET_LITTLE_SYM bfd_elf32_littlearm_vec | |
33 | #define TARGET_LITTLE_NAME "elf32-littlearm" | |
34 | #define TARGET_BIG_SYM bfd_elf32_bigarm_vec | |
35 | #define TARGET_BIG_NAME "elf32-bigarm" | |
36 | ||
37 | #define elf_info_to_howto 0 | |
ba96a88f | 38 | #define elf_info_to_howto_rel elf32_arm_info_to_howto |
252b5132 | 39 | |
ba96a88f NC |
40 | #define ARM_ELF_ABI_VERSION 0 |
41 | #define ARM_ELF_OS_ABI_VERSION ELFOSABI_ARM | |
252b5132 RH |
42 | |
43 | static reloc_howto_type * elf32_arm_reloc_type_lookup | |
44 | PARAMS ((bfd * abfd, bfd_reloc_code_real_type code)); | |
45 | ||
46 | static reloc_howto_type elf32_arm_howto_table[] = | |
47 | { | |
48 | /* No relocation */ | |
49 | HOWTO (R_ARM_NONE, /* type */ | |
50 | 0, /* rightshift */ | |
51 | 0, /* size (0 = byte, 1 = short, 2 = long) */ | |
52 | 0, /* bitsize */ | |
53 | false, /* pc_relative */ | |
54 | 0, /* bitpos */ | |
55 | complain_overflow_dont,/* complain_on_overflow */ | |
56 | bfd_elf_generic_reloc, /* special_function */ | |
57 | "R_ARM_NONE", /* name */ | |
58 | false, /* partial_inplace */ | |
59 | 0, /* src_mask */ | |
60 | 0, /* dst_mask */ | |
61 | false), /* pcrel_offset */ | |
62 | ||
63 | HOWTO (R_ARM_PC24, /* type */ | |
64 | 2, /* rightshift */ | |
65 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
66 | 24, /* bitsize */ | |
67 | true, /* pc_relative */ | |
68 | 0, /* bitpos */ | |
69 | complain_overflow_signed,/* complain_on_overflow */ | |
70 | bfd_elf_generic_reloc, /* special_function */ | |
71 | "R_ARM_PC24", /* name */ | |
72 | false, /* partial_inplace */ | |
73 | 0x00ffffff, /* src_mask */ | |
74 | 0x00ffffff, /* dst_mask */ | |
75 | true), /* pcrel_offset */ | |
76 | ||
77 | /* 32 bit absolute */ | |
78 | HOWTO (R_ARM_ABS32, /* type */ | |
79 | 0, /* rightshift */ | |
80 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
81 | 32, /* bitsize */ | |
82 | false, /* pc_relative */ | |
83 | 0, /* bitpos */ | |
84 | complain_overflow_bitfield,/* complain_on_overflow */ | |
85 | bfd_elf_generic_reloc, /* special_function */ | |
86 | "R_ARM_ABS32", /* name */ | |
87 | false, /* partial_inplace */ | |
88 | 0xffffffff, /* src_mask */ | |
89 | 0xffffffff, /* dst_mask */ | |
90 | false), /* pcrel_offset */ | |
91 | ||
92 | /* standard 32bit pc-relative reloc */ | |
93 | HOWTO (R_ARM_REL32, /* type */ | |
94 | 0, /* rightshift */ | |
95 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
96 | 32, /* bitsize */ | |
97 | true, /* pc_relative */ | |
98 | 0, /* bitpos */ | |
99 | complain_overflow_bitfield,/* complain_on_overflow */ | |
100 | bfd_elf_generic_reloc, /* special_function */ | |
101 | "R_ARM_REL32", /* name */ | |
102 | false, /* partial_inplace */ | |
103 | 0xffffffff, /* src_mask */ | |
104 | 0xffffffff, /* dst_mask */ | |
105 | true), /* pcrel_offset */ | |
106 | ||
107 | /* 8 bit absolute */ | |
108 | HOWTO (R_ARM_PC13, /* type */ | |
109 | 0, /* rightshift */ | |
110 | 0, /* size (0 = byte, 1 = short, 2 = long) */ | |
111 | 8, /* bitsize */ | |
112 | false, /* pc_relative */ | |
113 | 0, /* bitpos */ | |
114 | complain_overflow_bitfield,/* complain_on_overflow */ | |
115 | bfd_elf_generic_reloc, /* special_function */ | |
116 | "R_ARM_PC13", /* name */ | |
117 | false, /* partial_inplace */ | |
118 | 0x000000ff, /* src_mask */ | |
119 | 0x000000ff, /* dst_mask */ | |
120 | false), /* pcrel_offset */ | |
121 | ||
122 | /* 16 bit absolute */ | |
123 | HOWTO (R_ARM_ABS16, /* type */ | |
124 | 0, /* rightshift */ | |
125 | 1, /* size (0 = byte, 1 = short, 2 = long) */ | |
126 | 16, /* bitsize */ | |
127 | false, /* pc_relative */ | |
128 | 0, /* bitpos */ | |
129 | complain_overflow_bitfield,/* complain_on_overflow */ | |
130 | bfd_elf_generic_reloc, /* special_function */ | |
131 | "R_ARM_ABS16", /* name */ | |
132 | false, /* partial_inplace */ | |
133 | 0, /* src_mask */ | |
134 | 0, /* dst_mask */ | |
135 | false), /* pcrel_offset */ | |
136 | ||
137 | /* 12 bit absolute */ | |
138 | HOWTO (R_ARM_ABS12, /* type */ | |
139 | 0, /* rightshift */ | |
140 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
141 | 12, /* bitsize */ | |
142 | false, /* pc_relative */ | |
143 | 0, /* bitpos */ | |
144 | complain_overflow_bitfield,/* complain_on_overflow */ | |
145 | bfd_elf_generic_reloc, /* special_function */ | |
146 | "R_ARM_ABS12", /* name */ | |
147 | false, /* partial_inplace */ | |
148 | 0x000008ff, /* src_mask */ | |
149 | 0x000008ff, /* dst_mask */ | |
150 | false), /* pcrel_offset */ | |
151 | ||
152 | HOWTO (R_ARM_THM_ABS5, /* type */ | |
153 | 6, /* rightshift */ | |
154 | 1, /* size (0 = byte, 1 = short, 2 = long) */ | |
155 | 5, /* bitsize */ | |
156 | false, /* pc_relative */ | |
157 | 0, /* bitpos */ | |
158 | complain_overflow_bitfield,/* complain_on_overflow */ | |
159 | bfd_elf_generic_reloc, /* special_function */ | |
160 | "R_ARM_THM_ABS5", /* name */ | |
161 | false, /* partial_inplace */ | |
162 | 0x000007e0, /* src_mask */ | |
163 | 0x000007e0, /* dst_mask */ | |
164 | false), /* pcrel_offset */ | |
165 | ||
166 | /* 8 bit absolute */ | |
167 | HOWTO (R_ARM_ABS8, /* type */ | |
168 | 0, /* rightshift */ | |
169 | 0, /* size (0 = byte, 1 = short, 2 = long) */ | |
170 | 8, /* bitsize */ | |
171 | false, /* pc_relative */ | |
172 | 0, /* bitpos */ | |
173 | complain_overflow_bitfield,/* complain_on_overflow */ | |
174 | bfd_elf_generic_reloc, /* special_function */ | |
175 | "R_ARM_ABS8", /* name */ | |
176 | false, /* partial_inplace */ | |
177 | 0x000000ff, /* src_mask */ | |
178 | 0x000000ff, /* dst_mask */ | |
179 | false), /* pcrel_offset */ | |
180 | ||
181 | HOWTO (R_ARM_SBREL32, /* type */ | |
182 | 0, /* rightshift */ | |
183 | 0, /* size (0 = byte, 1 = short, 2 = long) */ | |
184 | 0, /* bitsize */ | |
185 | false, /* pc_relative */ | |
186 | 0, /* bitpos */ | |
187 | complain_overflow_dont,/* complain_on_overflow */ | |
188 | bfd_elf_generic_reloc, /* special_function */ | |
189 | "R_ARM_SBREL32", /* name */ | |
190 | false, /* partial_inplace */ | |
191 | 0, /* src_mask */ | |
192 | 0, /* dst_mask */ | |
193 | false), /* pcrel_offset */ | |
194 | ||
195 | HOWTO (R_ARM_THM_PC22, /* type */ | |
196 | 1, /* rightshift */ | |
197 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
198 | 23, /* bitsize */ | |
199 | true, /* pc_relative */ | |
200 | 0, /* bitpos */ | |
201 | complain_overflow_signed,/* complain_on_overflow */ | |
202 | bfd_elf_generic_reloc, /* special_function */ | |
203 | "R_ARM_THM_PC22", /* name */ | |
204 | false, /* partial_inplace */ | |
205 | 0x07ff07ff, /* src_mask */ | |
206 | 0x07ff07ff, /* dst_mask */ | |
207 | true), /* pcrel_offset */ | |
208 | ||
209 | HOWTO (R_ARM_THM_PC8, /* type */ | |
210 | 1, /* rightshift */ | |
211 | 1, /* size (0 = byte, 1 = short, 2 = long) */ | |
212 | 8, /* bitsize */ | |
213 | true, /* pc_relative */ | |
214 | 0, /* bitpos */ | |
215 | complain_overflow_signed,/* complain_on_overflow */ | |
216 | bfd_elf_generic_reloc, /* special_function */ | |
217 | "R_ARM_THM_PC8", /* name */ | |
218 | false, /* partial_inplace */ | |
219 | 0x000000ff, /* src_mask */ | |
220 | 0x000000ff, /* dst_mask */ | |
221 | true), /* pcrel_offset */ | |
222 | ||
223 | HOWTO (R_ARM_AMP_VCALL9, /* type */ | |
224 | 1, /* rightshift */ | |
225 | 1, /* size (0 = byte, 1 = short, 2 = long) */ | |
226 | 8, /* bitsize */ | |
227 | true, /* pc_relative */ | |
228 | 0, /* bitpos */ | |
229 | complain_overflow_signed,/* complain_on_overflow */ | |
230 | bfd_elf_generic_reloc, /* special_function */ | |
231 | "R_ARM_AMP_VCALL9", /* name */ | |
232 | false, /* partial_inplace */ | |
233 | 0x000000ff, /* src_mask */ | |
234 | 0x000000ff, /* dst_mask */ | |
235 | true), /* pcrel_offset */ | |
236 | ||
237 | HOWTO (R_ARM_SWI24, /* type */ | |
238 | 0, /* rightshift */ | |
239 | 0, /* size (0 = byte, 1 = short, 2 = long) */ | |
240 | 0, /* bitsize */ | |
241 | false, /* pc_relative */ | |
242 | 0, /* bitpos */ | |
243 | complain_overflow_signed,/* complain_on_overflow */ | |
244 | bfd_elf_generic_reloc, /* special_function */ | |
245 | "R_ARM_SWI24", /* name */ | |
246 | false, /* partial_inplace */ | |
247 | 0x00000000, /* src_mask */ | |
248 | 0x00000000, /* dst_mask */ | |
249 | false), /* pcrel_offset */ | |
250 | ||
251 | HOWTO (R_ARM_THM_SWI8, /* type */ | |
252 | 0, /* rightshift */ | |
253 | 0, /* size (0 = byte, 1 = short, 2 = long) */ | |
254 | 0, /* bitsize */ | |
255 | false, /* pc_relative */ | |
256 | 0, /* bitpos */ | |
257 | complain_overflow_signed,/* complain_on_overflow */ | |
258 | bfd_elf_generic_reloc, /* special_function */ | |
259 | "R_ARM_SWI8", /* name */ | |
260 | false, /* partial_inplace */ | |
261 | 0x00000000, /* src_mask */ | |
262 | 0x00000000, /* dst_mask */ | |
263 | false), /* pcrel_offset */ | |
264 | ||
265 | /* These next two relocs are defined, but I do not know what they do. */ | |
266 | ||
267 | HOWTO (R_ARM_XPC25, /* type */ | |
268 | 0, /* rightshift */ | |
269 | 0, /* size (0 = byte, 1 = short, 2 = long) */ | |
270 | 0, /* bitsize */ | |
271 | false, /* pc_relative */ | |
272 | 0, /* bitpos */ | |
273 | complain_overflow_signed,/* complain_on_overflow */ | |
274 | bfd_elf_generic_reloc, /* special_function */ | |
275 | "R_ARM_XPC25", /* name */ | |
276 | false, /* partial_inplace */ | |
277 | 0x00000000, /* src_mask */ | |
278 | 0x00000000, /* dst_mask */ | |
279 | false), /* pcrel_offset */ | |
280 | ||
281 | HOWTO (R_ARM_THM_XPC22, /* type */ | |
282 | 0, /* rightshift */ | |
283 | 0, /* size (0 = byte, 1 = short, 2 = long) */ | |
284 | 0, /* bitsize */ | |
285 | false, /* pc_relative */ | |
286 | 0, /* bitpos */ | |
287 | complain_overflow_signed,/* complain_on_overflow */ | |
288 | bfd_elf_generic_reloc, /* special_function */ | |
289 | "R_ARM_THM_XPC22", /* name */ | |
290 | false, /* partial_inplace */ | |
291 | 0x00000000, /* src_mask */ | |
292 | 0x00000000, /* dst_mask */ | |
293 | false), /* pcrel_offset */ | |
294 | ||
295 | /* These next three relocs are not defined, but we need to fill the space. */ | |
296 | ||
297 | HOWTO (R_ARM_NONE, /* type */ | |
298 | 0, /* rightshift */ | |
299 | 0, /* size (0 = byte, 1 = short, 2 = long) */ | |
300 | 0, /* bitsize */ | |
301 | false, /* pc_relative */ | |
302 | 0, /* bitpos */ | |
303 | complain_overflow_dont,/* complain_on_overflow */ | |
304 | bfd_elf_generic_reloc, /* special_function */ | |
305 | "R_ARM_unknown_17", /* name */ | |
306 | false, /* partial_inplace */ | |
307 | 0, /* src_mask */ | |
308 | 0, /* dst_mask */ | |
309 | false), /* pcrel_offset */ | |
310 | ||
311 | HOWTO (R_ARM_NONE, /* type */ | |
312 | 0, /* rightshift */ | |
313 | 0, /* size (0 = byte, 1 = short, 2 = long) */ | |
314 | 0, /* bitsize */ | |
315 | false, /* pc_relative */ | |
316 | 0, /* bitpos */ | |
317 | complain_overflow_dont,/* complain_on_overflow */ | |
318 | bfd_elf_generic_reloc, /* special_function */ | |
319 | "R_ARM_unknown_18", /* name */ | |
320 | false, /* partial_inplace */ | |
321 | 0, /* src_mask */ | |
322 | 0, /* dst_mask */ | |
323 | false), /* pcrel_offset */ | |
324 | ||
325 | HOWTO (R_ARM_NONE, /* type */ | |
326 | 0, /* rightshift */ | |
327 | 0, /* size (0 = byte, 1 = short, 2 = long) */ | |
328 | 0, /* bitsize */ | |
329 | false, /* pc_relative */ | |
330 | 0, /* bitpos */ | |
331 | complain_overflow_dont,/* complain_on_overflow */ | |
332 | bfd_elf_generic_reloc, /* special_function */ | |
333 | "R_ARM_unknown_19", /* name */ | |
334 | false, /* partial_inplace */ | |
335 | 0, /* src_mask */ | |
336 | 0, /* dst_mask */ | |
337 | false), /* pcrel_offset */ | |
338 | ||
339 | /* Relocs used in ARM Linux */ | |
340 | ||
341 | HOWTO (R_ARM_COPY, /* type */ | |
342 | 0, /* rightshift */ | |
343 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
344 | 32, /* bitsize */ | |
345 | false, /* pc_relative */ | |
346 | 0, /* bitpos */ | |
347 | complain_overflow_bitfield,/* complain_on_overflow */ | |
348 | bfd_elf_generic_reloc, /* special_function */ | |
349 | "R_ARM_COPY", /* name */ | |
350 | true, /* partial_inplace */ | |
351 | 0xffffffff, /* src_mask */ | |
352 | 0xffffffff, /* dst_mask */ | |
353 | false), /* pcrel_offset */ | |
354 | ||
355 | HOWTO (R_ARM_GLOB_DAT, /* type */ | |
356 | 0, /* rightshift */ | |
357 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
358 | 32, /* bitsize */ | |
359 | false, /* pc_relative */ | |
360 | 0, /* bitpos */ | |
361 | complain_overflow_bitfield,/* complain_on_overflow */ | |
362 | bfd_elf_generic_reloc, /* special_function */ | |
363 | "R_ARM_GLOB_DAT", /* name */ | |
364 | true, /* partial_inplace */ | |
365 | 0xffffffff, /* src_mask */ | |
366 | 0xffffffff, /* dst_mask */ | |
367 | false), /* pcrel_offset */ | |
368 | ||
369 | HOWTO (R_ARM_JUMP_SLOT, /* type */ | |
370 | 0, /* rightshift */ | |
371 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
372 | 32, /* bitsize */ | |
373 | false, /* pc_relative */ | |
374 | 0, /* bitpos */ | |
375 | complain_overflow_bitfield,/* complain_on_overflow */ | |
376 | bfd_elf_generic_reloc, /* special_function */ | |
377 | "R_ARM_JUMP_SLOT", /* name */ | |
378 | true, /* partial_inplace */ | |
379 | 0xffffffff, /* src_mask */ | |
380 | 0xffffffff, /* dst_mask */ | |
381 | false), /* pcrel_offset */ | |
382 | ||
383 | HOWTO (R_ARM_RELATIVE, /* type */ | |
384 | 0, /* rightshift */ | |
385 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
386 | 32, /* bitsize */ | |
387 | false, /* pc_relative */ | |
388 | 0, /* bitpos */ | |
389 | complain_overflow_bitfield,/* complain_on_overflow */ | |
390 | bfd_elf_generic_reloc, /* special_function */ | |
391 | "R_ARM_RELATIVE", /* name */ | |
392 | true, /* partial_inplace */ | |
393 | 0xffffffff, /* src_mask */ | |
394 | 0xffffffff, /* dst_mask */ | |
395 | false), /* pcrel_offset */ | |
396 | ||
397 | HOWTO (R_ARM_GOTOFF, /* type */ | |
398 | 0, /* rightshift */ | |
399 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
400 | 32, /* bitsize */ | |
401 | false, /* pc_relative */ | |
402 | 0, /* bitpos */ | |
403 | complain_overflow_bitfield,/* complain_on_overflow */ | |
404 | bfd_elf_generic_reloc, /* special_function */ | |
405 | "R_ARM_GOTOFF", /* name */ | |
406 | true, /* partial_inplace */ | |
407 | 0xffffffff, /* src_mask */ | |
408 | 0xffffffff, /* dst_mask */ | |
409 | false), /* pcrel_offset */ | |
410 | ||
411 | HOWTO (R_ARM_GOTPC, /* type */ | |
412 | 0, /* rightshift */ | |
413 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
414 | 32, /* bitsize */ | |
415 | true, /* pc_relative */ | |
416 | 0, /* bitpos */ | |
417 | complain_overflow_bitfield,/* complain_on_overflow */ | |
418 | bfd_elf_generic_reloc, /* special_function */ | |
419 | "R_ARM_GOTPC", /* name */ | |
420 | true, /* partial_inplace */ | |
421 | 0xffffffff, /* src_mask */ | |
422 | 0xffffffff, /* dst_mask */ | |
423 | true), /* pcrel_offset */ | |
424 | ||
425 | HOWTO (R_ARM_GOT32, /* type */ | |
426 | 0, /* rightshift */ | |
427 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
428 | 32, /* bitsize */ | |
429 | false, /* pc_relative */ | |
430 | 0, /* bitpos */ | |
431 | complain_overflow_bitfield,/* complain_on_overflow */ | |
432 | bfd_elf_generic_reloc, /* special_function */ | |
433 | "R_ARM_GOT32", /* name */ | |
434 | true, /* partial_inplace */ | |
435 | 0xffffffff, /* src_mask */ | |
436 | 0xffffffff, /* dst_mask */ | |
437 | false), /* pcrel_offset */ | |
438 | ||
439 | HOWTO (R_ARM_PLT32, /* type */ | |
440 | 2, /* rightshift */ | |
441 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
442 | 26, /* bitsize */ | |
443 | true, /* pc_relative */ | |
444 | 0, /* bitpos */ | |
445 | complain_overflow_bitfield,/* complain_on_overflow */ | |
446 | bfd_elf_generic_reloc, /* special_function */ | |
447 | "R_ARM_PLT32", /* name */ | |
448 | true, /* partial_inplace */ | |
449 | 0x00ffffff, /* src_mask */ | |
450 | 0x00ffffff, /* dst_mask */ | |
451 | true), /* pcrel_offset */ | |
452 | ||
453 | /* End of relocs used in ARM Linux */ | |
454 | ||
455 | HOWTO (R_ARM_RREL32, /* type */ | |
456 | 0, /* rightshift */ | |
457 | 0, /* size (0 = byte, 1 = short, 2 = long) */ | |
458 | 0, /* bitsize */ | |
459 | false, /* pc_relative */ | |
460 | 0, /* bitpos */ | |
461 | complain_overflow_dont,/* complain_on_overflow */ | |
462 | bfd_elf_generic_reloc, /* special_function */ | |
463 | "R_ARM_RREL32", /* name */ | |
464 | false, /* partial_inplace */ | |
465 | 0, /* src_mask */ | |
466 | 0, /* dst_mask */ | |
467 | false), /* pcrel_offset */ | |
468 | ||
469 | HOWTO (R_ARM_RABS32, /* type */ | |
470 | 0, /* rightshift */ | |
471 | 0, /* size (0 = byte, 1 = short, 2 = long) */ | |
472 | 0, /* bitsize */ | |
473 | false, /* pc_relative */ | |
474 | 0, /* bitpos */ | |
475 | complain_overflow_dont,/* complain_on_overflow */ | |
476 | bfd_elf_generic_reloc, /* special_function */ | |
477 | "R_ARM_RABS32", /* name */ | |
478 | false, /* partial_inplace */ | |
479 | 0, /* src_mask */ | |
480 | 0, /* dst_mask */ | |
481 | false), /* pcrel_offset */ | |
482 | ||
483 | HOWTO (R_ARM_RPC24, /* type */ | |
484 | 0, /* rightshift */ | |
485 | 0, /* size (0 = byte, 1 = short, 2 = long) */ | |
486 | 0, /* bitsize */ | |
487 | false, /* pc_relative */ | |
488 | 0, /* bitpos */ | |
489 | complain_overflow_dont,/* complain_on_overflow */ | |
490 | bfd_elf_generic_reloc, /* special_function */ | |
491 | "R_ARM_RPC24", /* name */ | |
492 | false, /* partial_inplace */ | |
493 | 0, /* src_mask */ | |
494 | 0, /* dst_mask */ | |
495 | false), /* pcrel_offset */ | |
496 | ||
497 | HOWTO (R_ARM_RBASE, /* type */ | |
498 | 0, /* rightshift */ | |
499 | 0, /* size (0 = byte, 1 = short, 2 = long) */ | |
500 | 0, /* bitsize */ | |
501 | false, /* pc_relative */ | |
502 | 0, /* bitpos */ | |
503 | complain_overflow_dont,/* complain_on_overflow */ | |
504 | bfd_elf_generic_reloc, /* special_function */ | |
505 | "R_ARM_RBASE", /* name */ | |
506 | false, /* partial_inplace */ | |
507 | 0, /* src_mask */ | |
508 | 0, /* dst_mask */ | |
509 | false), /* pcrel_offset */ | |
510 | ||
511 | }; | |
512 | ||
513 | /* GNU extension to record C++ vtable hierarchy */ | |
514 | static reloc_howto_type elf32_arm_vtinherit_howto = | |
515 | HOWTO (R_ARM_GNU_VTINHERIT, /* type */ | |
516 | 0, /* rightshift */ | |
517 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
518 | 0, /* bitsize */ | |
519 | false, /* pc_relative */ | |
520 | 0, /* bitpos */ | |
521 | complain_overflow_dont, /* complain_on_overflow */ | |
522 | NULL, /* special_function */ | |
523 | "R_ARM_GNU_VTINHERIT", /* name */ | |
524 | false, /* partial_inplace */ | |
525 | 0, /* src_mask */ | |
526 | 0, /* dst_mask */ | |
527 | false); /* pcrel_offset */ | |
528 | ||
529 | /* GNU extension to record C++ vtable member usage */ | |
530 | static reloc_howto_type elf32_arm_vtentry_howto = | |
531 | HOWTO (R_ARM_GNU_VTENTRY, /* type */ | |
532 | 0, /* rightshift */ | |
533 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
534 | 0, /* bitsize */ | |
535 | false, /* pc_relative */ | |
536 | 0, /* bitpos */ | |
537 | complain_overflow_dont, /* complain_on_overflow */ | |
538 | _bfd_elf_rel_vtable_reloc_fn, /* special_function */ | |
539 | "R_ARM_GNU_VTENTRY", /* name */ | |
540 | false, /* partial_inplace */ | |
541 | 0, /* src_mask */ | |
542 | 0, /* dst_mask */ | |
543 | false); /* pcrel_offset */ | |
544 | ||
545 | /* 12 bit pc relative */ | |
546 | static reloc_howto_type elf32_arm_thm_pc11_howto = | |
547 | HOWTO (R_ARM_THM_PC11, /* type */ | |
548 | 1, /* rightshift */ | |
549 | 1, /* size (0 = byte, 1 = short, 2 = long) */ | |
550 | 11, /* bitsize */ | |
551 | true, /* pc_relative */ | |
552 | 0, /* bitpos */ | |
553 | complain_overflow_signed, /* complain_on_overflow */ | |
554 | bfd_elf_generic_reloc, /* special_function */ | |
555 | "R_ARM_THM_PC11", /* name */ | |
556 | false, /* partial_inplace */ | |
557 | 0x000007ff, /* src_mask */ | |
558 | 0x000007ff, /* dst_mask */ | |
559 | true); /* pcrel_offset */ | |
560 | ||
561 | /* 12 bit pc relative */ | |
562 | static reloc_howto_type elf32_arm_thm_pc9_howto = | |
563 | HOWTO (R_ARM_THM_PC9, /* type */ | |
564 | 1, /* rightshift */ | |
565 | 1, /* size (0 = byte, 1 = short, 2 = long) */ | |
566 | 8, /* bitsize */ | |
567 | true, /* pc_relative */ | |
568 | 0, /* bitpos */ | |
569 | complain_overflow_signed, /* complain_on_overflow */ | |
570 | bfd_elf_generic_reloc, /* special_function */ | |
571 | "R_ARM_THM_PC9", /* name */ | |
572 | false, /* partial_inplace */ | |
573 | 0x000000ff, /* src_mask */ | |
574 | 0x000000ff, /* dst_mask */ | |
575 | true); /* pcrel_offset */ | |
576 | ||
577 | ||
578 | static void | |
ba96a88f | 579 | elf32_arm_info_to_howto (abfd, bfd_reloc, elf_reloc) |
5f771d47 | 580 | bfd * abfd ATTRIBUTE_UNUSED; |
252b5132 RH |
581 | arelent * bfd_reloc; |
582 | Elf32_Internal_Rel * elf_reloc; | |
583 | { | |
584 | unsigned int r_type; | |
585 | ||
586 | r_type = ELF32_R_TYPE (elf_reloc->r_info); | |
587 | ||
588 | switch (r_type) | |
589 | { | |
590 | case R_ARM_GNU_VTINHERIT: | |
591 | bfd_reloc->howto = & elf32_arm_vtinherit_howto; | |
592 | break; | |
593 | ||
594 | case R_ARM_GNU_VTENTRY: | |
595 | bfd_reloc->howto = & elf32_arm_vtentry_howto; | |
596 | break; | |
597 | ||
598 | case R_ARM_THM_PC11: | |
599 | bfd_reloc->howto = & elf32_arm_thm_pc11_howto; | |
600 | break; | |
601 | ||
602 | case R_ARM_THM_PC9: | |
603 | bfd_reloc->howto = & elf32_arm_thm_pc9_howto; | |
604 | break; | |
605 | ||
606 | default: | |
607 | if (r_type >= NUM_ELEM (elf32_arm_howto_table)) | |
608 | bfd_reloc->howto = NULL; | |
609 | else | |
610 | bfd_reloc->howto = & elf32_arm_howto_table[r_type]; | |
611 | break; | |
612 | } | |
613 | } | |
614 | ||
615 | struct elf32_arm_reloc_map | |
616 | { | |
617 | bfd_reloc_code_real_type bfd_reloc_val; | |
618 | unsigned char elf_reloc_val; | |
619 | }; | |
620 | ||
621 | static const struct elf32_arm_reloc_map elf32_arm_reloc_map[] = | |
622 | { | |
623 | {BFD_RELOC_NONE, R_ARM_NONE}, | |
624 | {BFD_RELOC_ARM_PCREL_BRANCH, R_ARM_PC24}, | |
625 | {BFD_RELOC_32, R_ARM_ABS32}, | |
626 | {BFD_RELOC_32_PCREL, R_ARM_REL32}, | |
627 | {BFD_RELOC_8, R_ARM_ABS8}, | |
628 | {BFD_RELOC_16, R_ARM_ABS16}, | |
629 | {BFD_RELOC_ARM_OFFSET_IMM, R_ARM_ABS12}, | |
630 | {BFD_RELOC_ARM_THUMB_OFFSET, R_ARM_THM_ABS5}, | |
631 | {BFD_RELOC_THUMB_PCREL_BRANCH23, R_ARM_THM_PC22}, | |
632 | {BFD_RELOC_ARM_COPY, R_ARM_COPY}, | |
633 | {BFD_RELOC_ARM_GLOB_DAT, R_ARM_GLOB_DAT}, | |
634 | {BFD_RELOC_ARM_JUMP_SLOT, R_ARM_JUMP_SLOT}, | |
635 | {BFD_RELOC_ARM_RELATIVE, R_ARM_RELATIVE}, | |
636 | {BFD_RELOC_ARM_GOTOFF, R_ARM_GOTOFF}, | |
637 | {BFD_RELOC_ARM_GOTPC, R_ARM_GOTPC}, | |
638 | {BFD_RELOC_ARM_GOT32, R_ARM_GOT32}, | |
639 | {BFD_RELOC_ARM_PLT32, R_ARM_PLT32} | |
640 | }; | |
641 | ||
642 | static reloc_howto_type * | |
643 | elf32_arm_reloc_type_lookup (abfd, code) | |
5f771d47 | 644 | bfd *abfd ATTRIBUTE_UNUSED; |
252b5132 RH |
645 | bfd_reloc_code_real_type code; |
646 | { | |
647 | unsigned int i; | |
648 | ||
649 | switch (code) | |
650 | { | |
651 | case BFD_RELOC_VTABLE_INHERIT: | |
652 | return & elf32_arm_vtinherit_howto; | |
653 | ||
654 | case BFD_RELOC_VTABLE_ENTRY: | |
655 | return & elf32_arm_vtentry_howto; | |
656 | ||
657 | case BFD_RELOC_THUMB_PCREL_BRANCH12: | |
658 | return & elf32_arm_thm_pc11_howto; | |
659 | ||
660 | case BFD_RELOC_THUMB_PCREL_BRANCH9: | |
661 | return & elf32_arm_thm_pc9_howto; | |
662 | ||
663 | default: | |
664 | for (i = 0; i < NUM_ELEM (elf32_arm_reloc_map); i ++) | |
665 | if (elf32_arm_reloc_map[i].bfd_reloc_val == code) | |
666 | return & elf32_arm_howto_table[elf32_arm_reloc_map[i].elf_reloc_val]; | |
667 | ||
668 | return NULL; | |
669 | } | |
670 | } | |
671 | ||
672 | #include "elf32-arm.h" |