1 /* 32-bit ELF support for ARM old abi option.
2 Copyright 1999, 2000 Free Software Foundation, Inc.
4 This file is part of BFD, the Binary File Descriptor library.
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.
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.
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. */
29 #define NUM_ELEM(a) (sizeof (a) / sizeof (a)[0])
34 #define TARGET_LITTLE_SYM bfd_elf32_littlearm_oabi_vec
35 #define TARGET_LITTLE_NAME "elf32-littlearm-oabi"
36 #define TARGET_BIG_SYM bfd_elf32_bigarm_oabi_vec
37 #define TARGET_BIG_NAME "elf32-bigarm-oabi"
39 #define elf_info_to_howto elf32_arm_info_to_howto
40 #define elf_info_to_howto_rel 0
42 #define ARM_ELF_ABI_VERSION 0
43 #define ARM_ELF_OS_ABI_VERSION 0
45 static reloc_howto_type elf32_arm_howto_table
[] =
48 HOWTO (R_ARM_NONE
, /* type */
50 0, /* size (0 = byte, 1 = short, 2 = long) */
52 false, /* pc_relative */
54 complain_overflow_dont
, /* complain_on_overflow */
55 bfd_elf_generic_reloc
, /* special_function */
56 "R_ARM_NONE", /* name */
57 false, /* partial_inplace */
60 false), /* pcrel_offset */
62 HOWTO (R_ARM_PC24
, /* type */
64 2, /* size (0 = byte, 1 = short, 2 = long) */
66 true, /* pc_relative */
68 complain_overflow_signed
, /* complain_on_overflow */
69 bfd_elf_generic_reloc
, /* special_function */
70 "R_ARM_PC24", /* name */
71 false, /* partial_inplace */
72 0x00ffffff, /* src_mask */
73 0x00ffffff, /* dst_mask */
74 true), /* pcrel_offset */
77 HOWTO (R_ARM_ABS32
, /* type */
79 2, /* size (0 = byte, 1 = short, 2 = long) */
81 false, /* pc_relative */
83 complain_overflow_bitfield
, /* complain_on_overflow */
84 bfd_elf_generic_reloc
, /* special_function */
85 "R_ARM_ABS32", /* name */
86 false, /* partial_inplace */
87 0xffffffff, /* src_mask */
88 0xffffffff, /* dst_mask */
89 false), /* pcrel_offset */
91 /* standard 32bit pc-relative reloc */
92 HOWTO (R_ARM_REL32
, /* type */
94 2, /* size (0 = byte, 1 = short, 2 = long) */
96 true, /* pc_relative */
98 complain_overflow_bitfield
, /* complain_on_overflow */
99 bfd_elf_generic_reloc
, /* special_function */
100 "R_ARM_REL32", /* name */
101 false, /* partial_inplace */
102 0xffffffff, /* src_mask */
103 0xffffffff, /* dst_mask */
104 true), /* pcrel_offset */
107 HOWTO (R_ARM_ABS8
, /* type */
109 0, /* size (0 = byte, 1 = short, 2 = long) */
111 false, /* pc_relative */
113 complain_overflow_bitfield
, /* complain_on_overflow */
114 bfd_elf_generic_reloc
, /* special_function */
115 "R_ARM_ABS8", /* name */
116 false, /* partial_inplace */
117 0x000000ff, /* src_mask */
118 0x000000ff, /* dst_mask */
119 false), /* pcrel_offset */
121 /* 16 bit absolute */
122 HOWTO (R_ARM_ABS16
, /* type */
124 1, /* size (0 = byte, 1 = short, 2 = long) */
126 false, /* pc_relative */
128 complain_overflow_bitfield
, /* complain_on_overflow */
129 bfd_elf_generic_reloc
, /* special_function */
130 "R_ARM_ABS16", /* name */
131 false, /* partial_inplace */
134 false), /* pcrel_offset */
136 /* 12 bit absolute */
137 HOWTO (R_ARM_ABS12
, /* type */
139 2, /* size (0 = byte, 1 = short, 2 = long) */
141 false, /* pc_relative */
143 complain_overflow_bitfield
, /* complain_on_overflow */
144 bfd_elf_generic_reloc
, /* special_function */
145 "R_ARM_ABS12", /* name */
146 false, /* partial_inplace */
147 0x000008ff, /* src_mask */
148 0x000008ff, /* dst_mask */
149 false), /* pcrel_offset */
151 HOWTO (R_ARM_THM_ABS5
, /* type */
153 1, /* size (0 = byte, 1 = short, 2 = long) */
155 false, /* pc_relative */
157 complain_overflow_bitfield
, /* complain_on_overflow */
158 bfd_elf_generic_reloc
, /* special_function */
159 "R_ARM_THM_ABS5", /* name */
160 false, /* partial_inplace */
161 0x000007e0, /* src_mask */
162 0x000007e0, /* dst_mask */
163 false), /* pcrel_offset */
165 HOWTO (R_ARM_THM_PC22
, /* type */
167 2, /* size (0 = byte, 1 = short, 2 = long) */
169 true, /* pc_relative */
171 complain_overflow_signed
, /* complain_on_overflow */
172 bfd_elf_generic_reloc
, /* special_function */
173 "R_ARM_THM_PC22", /* name */
174 false, /* partial_inplace */
175 0x07ff07ff, /* src_mask */
176 0x07ff07ff, /* dst_mask */
177 true), /* pcrel_offset */
179 HOWTO (R_ARM_SBREL32
, /* type */
181 0, /* size (0 = byte, 1 = short, 2 = long) */
183 false, /* pc_relative */
185 complain_overflow_dont
,/* complain_on_overflow */
186 bfd_elf_generic_reloc
, /* special_function */
187 "R_ARM_SBREL32", /* name */
188 false, /* partial_inplace */
191 false), /* pcrel_offset */
193 HOWTO (R_ARM_AMP_VCALL9
, /* type */
195 1, /* size (0 = byte, 1 = short, 2 = long) */
197 true, /* pc_relative */
199 complain_overflow_signed
, /* complain_on_overflow */
200 bfd_elf_generic_reloc
, /* special_function */
201 "R_ARM_AMP_VCALL9", /* name */
202 false, /* partial_inplace */
203 0x000000ff, /* src_mask */
204 0x000000ff, /* dst_mask */
205 true), /* pcrel_offset */
207 /* 12 bit pc relative */
208 HOWTO (R_ARM_THM_PC11
, /* type */
210 1, /* size (0 = byte, 1 = short, 2 = long) */
212 true, /* pc_relative */
214 complain_overflow_signed
, /* complain_on_overflow */
215 bfd_elf_generic_reloc
, /* special_function */
216 "R_ARM_THM_PC11", /* name */
217 false, /* partial_inplace */
218 0x000007ff, /* src_mask */
219 0x000007ff, /* dst_mask */
220 true), /* pcrel_offset */
222 /* 12 bit pc relative */
223 HOWTO (R_ARM_THM_PC9
, /* type */
225 1, /* size (0 = byte, 1 = short, 2 = long) */
227 true, /* pc_relative */
229 complain_overflow_signed
, /* complain_on_overflow */
230 bfd_elf_generic_reloc
, /* special_function */
231 "R_ARM_THM_PC9", /* name */
232 false, /* partial_inplace */
233 0x000000ff, /* src_mask */
234 0x000000ff, /* dst_mask */
235 true), /* pcrel_offset */
237 /* GNU extension to record C++ vtable hierarchy */
238 HOWTO (R_ARM_GNU_VTINHERIT
, /* type */
240 2, /* size (0 = byte, 1 = short, 2 = long) */
242 false, /* pc_relative */
244 complain_overflow_dont
, /* complain_on_overflow */
245 NULL
, /* special_function */
246 "R_ARM_GNU_VTINHERIT", /* name */
247 false, /* partial_inplace */
250 false), /* pcrel_offset */
252 /* GNU extension to record C++ vtable member usage */
253 HOWTO (R_ARM_GNU_VTENTRY
, /* type */
255 2, /* size (0 = byte, 1 = short, 2 = long) */
257 false, /* pc_relative */
259 complain_overflow_dont
, /* complain_on_overflow */
260 _bfd_elf_rel_vtable_reloc_fn
, /* special_function */
261 "R_ARM_GNU_VTENTRY", /* name */
262 false, /* partial_inplace */
265 false), /* pcrel_offset */
267 /* XXX - gap in index numbering here. */
269 HOWTO (R_ARM_PLT32
, /* type */
271 2, /* size (0 = byte, 1 = short, 2 = long) */
273 true, /* pc_relative */
275 complain_overflow_bitfield
,/* complain_on_overflow */
276 bfd_elf_generic_reloc
, /* special_function */
277 "R_ARM_PLT32", /* name */
278 true, /* partial_inplace */
279 0x00ffffff, /* src_mask */
280 0x00ffffff, /* dst_mask */
281 true), /* pcrel_offset */
283 /* XXX - gap in index numbering here. */
285 HOWTO (R_ARM_RREL32
, /* type */
287 0, /* size (0 = byte, 1 = short, 2 = long) */
289 false, /* pc_relative */
291 complain_overflow_dont
, /* complain_on_overflow */
292 bfd_elf_generic_reloc
, /* special_function */
293 "R_ARM_RREL32", /* name */
294 false, /* partial_inplace */
297 false), /* pcrel_offset */
299 HOWTO (R_ARM_RABS32
, /* type */
301 0, /* size (0 = byte, 1 = short, 2 = long) */
303 false, /* pc_relative */
305 complain_overflow_dont
, /* complain_on_overflow */
306 bfd_elf_generic_reloc
, /* special_function */
307 "R_ARM_RABS32", /* name */
308 false, /* partial_inplace */
311 false), /* pcrel_offset */
313 HOWTO (R_ARM_RPC24
, /* type */
315 0, /* size (0 = byte, 1 = short, 2 = long) */
317 false, /* pc_relative */
319 complain_overflow_dont
, /* complain_on_overflow */
320 bfd_elf_generic_reloc
, /* special_function */
321 "R_ARM_RPC24", /* name */
322 false, /* partial_inplace */
325 false), /* pcrel_offset */
327 HOWTO (R_ARM_RBASE
, /* type */
329 0, /* size (0 = byte, 1 = short, 2 = long) */
331 false, /* pc_relative */
333 complain_overflow_dont
, /* complain_on_overflow */
334 bfd_elf_generic_reloc
, /* special_function */
335 "R_ARM_RBASE", /* name */
336 false, /* partial_inplace */
339 false) /* pcrel_offset */
342 /* Locate a reloc in the howto table. This function must be used
343 when the entry number is is > R_ARM_GNU_VTINHERIT. */
344 static reloc_howto_type
*
350 for (i
= NUM_ELEM (elf32_arm_howto_table
); i
--;)
351 if (elf32_arm_howto_table
[i
].type
== r_type
)
352 return elf32_arm_howto_table
+ i
;
358 elf32_arm_info_to_howto (abfd
, bfd_reloc
, elf_reloc
)
359 bfd
*abfd ATTRIBUTE_UNUSED
;
361 Elf32_Internal_Rela
*elf_reloc
;
365 r_type
= ELF32_R_TYPE (elf_reloc
->r_info
);
367 if (r_type
<= R_ARM_GNU_VTINHERIT
)
368 bfd_reloc
->howto
= & elf32_arm_howto_table
[r_type
];
370 bfd_reloc
->howto
= find_howto (r_type
);
373 struct elf32_arm_reloc_map
375 bfd_reloc_code_real_type bfd_reloc_val
;
376 unsigned char elf_reloc_val
;
379 static const struct elf32_arm_reloc_map elf32_arm_reloc_map
[] =
381 {BFD_RELOC_NONE
, R_ARM_NONE
},
382 {BFD_RELOC_ARM_PCREL_BRANCH
, R_ARM_PC24
},
383 {BFD_RELOC_32
, R_ARM_ABS32
},
384 {BFD_RELOC_32_PCREL
, R_ARM_REL32
},
385 {BFD_RELOC_8
, R_ARM_ABS8
},
386 {BFD_RELOC_16
, R_ARM_ABS16
},
387 {BFD_RELOC_ARM_OFFSET_IMM
, R_ARM_ABS12
},
388 {BFD_RELOC_ARM_THUMB_OFFSET
, R_ARM_THM_ABS5
},
389 {BFD_RELOC_THUMB_PCREL_BRANCH23
, R_ARM_THM_PC22
},
390 {BFD_RELOC_NONE
, R_ARM_SBREL32
},
391 {BFD_RELOC_NONE
, R_ARM_AMP_VCALL9
},
392 {BFD_RELOC_THUMB_PCREL_BRANCH12
, R_ARM_THM_PC11
},
393 {BFD_RELOC_THUMB_PCREL_BRANCH9
, R_ARM_THM_PC9
},
394 {BFD_RELOC_VTABLE_INHERIT
, R_ARM_GNU_VTINHERIT
},
395 {BFD_RELOC_VTABLE_ENTRY
, R_ARM_GNU_VTENTRY
}
398 static reloc_howto_type
*
399 elf32_arm_reloc_type_lookup (abfd
, code
)
400 bfd
* abfd ATTRIBUTE_UNUSED
;
401 bfd_reloc_code_real_type code
;
405 for (i
= NUM_ELEM (elf32_arm_reloc_map
); i
--;)
406 if (elf32_arm_reloc_map
[i
].bfd_reloc_val
== code
)
407 return & elf32_arm_howto_table
[elf32_arm_reloc_map
[i
].elf_reloc_val
];
409 if (code
== BFD_RELOC_ARM_PLT32
)
410 return find_howto (R_ARM_PLT32
);
415 #define bfd_elf32_arm_allocate_interworking_sections \
416 bfd_elf32_arm_oabi_allocate_interworking_sections
417 #define bfd_elf32_arm_get_bfd_for_interworking \
418 bfd_elf32_arm_oabi_get_bfd_for_interworking
419 #define bfd_elf32_arm_process_before_allocation \
420 bfd_elf32_arm_oabi_process_before_allocation
422 #include "elf32-arm.h"