]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - bfd/elfarm-nabi.c
4c22f42996d2507d44dfbda6cc630d44138b1f68
[thirdparty/binutils-gdb.git] / bfd / elfarm-nabi.c
1 /* 32-bit ELF support for ARM new abi option.
2 Copyright 1999, 2000, 2001, 2002 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 1
31
32 #define elf_info_to_howto 0
33 #define elf_info_to_howto_rel elf32_arm_info_to_howto
34
35 #define ARM_ELF_ABI_VERSION 0
36 #define ARM_ELF_OS_ABI_VERSION ELFOSABI_ARM
37
38 static reloc_howto_type * elf32_arm_reloc_type_lookup
39 PARAMS ((bfd * abfd, bfd_reloc_code_real_type code));
40 static bfd_boolean elf32_arm_nabi_grok_prstatus
41 PARAMS ((bfd *abfd, Elf_Internal_Note *note));
42 static bfd_boolean elf32_arm_nabi_grok_psinfo
43 PARAMS ((bfd *abfd, Elf_Internal_Note *note));
44
45 /* Note: code such as elf32_arm_reloc_type_lookup expect to use e.g.
46 R_ARM_PC24 as an index into this, and find the R_ARM_PC24 HOWTO
47 in that slot. */
48
49 static reloc_howto_type elf32_arm_howto_table[] =
50 {
51 /* No relocation */
52 HOWTO (R_ARM_NONE, /* type */
53 0, /* rightshift */
54 0, /* size (0 = byte, 1 = short, 2 = long) */
55 0, /* bitsize */
56 FALSE, /* pc_relative */
57 0, /* bitpos */
58 complain_overflow_dont,/* complain_on_overflow */
59 bfd_elf_generic_reloc, /* special_function */
60 "R_ARM_NONE", /* name */
61 FALSE, /* partial_inplace */
62 0, /* src_mask */
63 0, /* dst_mask */
64 FALSE), /* pcrel_offset */
65
66 HOWTO (R_ARM_PC24, /* type */
67 2, /* rightshift */
68 2, /* size (0 = byte, 1 = short, 2 = long) */
69 24, /* bitsize */
70 TRUE, /* pc_relative */
71 0, /* bitpos */
72 complain_overflow_signed,/* complain_on_overflow */
73 bfd_elf_generic_reloc, /* special_function */
74 "R_ARM_PC24", /* name */
75 FALSE, /* partial_inplace */
76 0x00ffffff, /* src_mask */
77 0x00ffffff, /* dst_mask */
78 TRUE), /* pcrel_offset */
79
80 /* 32 bit absolute */
81 HOWTO (R_ARM_ABS32, /* type */
82 0, /* rightshift */
83 2, /* size (0 = byte, 1 = short, 2 = long) */
84 32, /* bitsize */
85 FALSE, /* pc_relative */
86 0, /* bitpos */
87 complain_overflow_bitfield,/* complain_on_overflow */
88 bfd_elf_generic_reloc, /* special_function */
89 "R_ARM_ABS32", /* name */
90 FALSE, /* partial_inplace */
91 0xffffffff, /* src_mask */
92 0xffffffff, /* dst_mask */
93 FALSE), /* pcrel_offset */
94
95 /* standard 32bit pc-relative reloc */
96 HOWTO (R_ARM_REL32, /* type */
97 0, /* rightshift */
98 2, /* size (0 = byte, 1 = short, 2 = long) */
99 32, /* bitsize */
100 TRUE, /* pc_relative */
101 0, /* bitpos */
102 complain_overflow_bitfield,/* complain_on_overflow */
103 bfd_elf_generic_reloc, /* special_function */
104 "R_ARM_REL32", /* name */
105 FALSE, /* partial_inplace */
106 0xffffffff, /* src_mask */
107 0xffffffff, /* dst_mask */
108 TRUE), /* pcrel_offset */
109
110 /* 8 bit absolute */
111 HOWTO (R_ARM_PC13, /* type */
112 0, /* rightshift */
113 0, /* size (0 = byte, 1 = short, 2 = long) */
114 8, /* bitsize */
115 FALSE, /* pc_relative */
116 0, /* bitpos */
117 complain_overflow_bitfield,/* complain_on_overflow */
118 bfd_elf_generic_reloc, /* special_function */
119 "R_ARM_PC13", /* name */
120 FALSE, /* partial_inplace */
121 0x000000ff, /* src_mask */
122 0x000000ff, /* dst_mask */
123 FALSE), /* pcrel_offset */
124
125 /* 16 bit absolute */
126 HOWTO (R_ARM_ABS16, /* type */
127 0, /* rightshift */
128 1, /* size (0 = byte, 1 = short, 2 = long) */
129 16, /* bitsize */
130 FALSE, /* pc_relative */
131 0, /* bitpos */
132 complain_overflow_bitfield,/* complain_on_overflow */
133 bfd_elf_generic_reloc, /* special_function */
134 "R_ARM_ABS16", /* name */
135 FALSE, /* partial_inplace */
136 0x0000ffff, /* src_mask */
137 0x0000ffff, /* dst_mask */
138 FALSE), /* pcrel_offset */
139
140 /* 12 bit absolute */
141 HOWTO (R_ARM_ABS12, /* type */
142 0, /* rightshift */
143 2, /* size (0 = byte, 1 = short, 2 = long) */
144 12, /* bitsize */
145 FALSE, /* pc_relative */
146 0, /* bitpos */
147 complain_overflow_bitfield,/* complain_on_overflow */
148 bfd_elf_generic_reloc, /* special_function */
149 "R_ARM_ABS12", /* name */
150 FALSE, /* partial_inplace */
151 0x000008ff, /* src_mask */
152 0x000008ff, /* dst_mask */
153 FALSE), /* pcrel_offset */
154
155 HOWTO (R_ARM_THM_ABS5, /* type */
156 6, /* rightshift */
157 1, /* size (0 = byte, 1 = short, 2 = long) */
158 5, /* bitsize */
159 FALSE, /* pc_relative */
160 0, /* bitpos */
161 complain_overflow_bitfield,/* complain_on_overflow */
162 bfd_elf_generic_reloc, /* special_function */
163 "R_ARM_THM_ABS5", /* name */
164 FALSE, /* partial_inplace */
165 0x000007e0, /* src_mask */
166 0x000007e0, /* dst_mask */
167 FALSE), /* pcrel_offset */
168
169 /* 8 bit absolute */
170 HOWTO (R_ARM_ABS8, /* type */
171 0, /* rightshift */
172 0, /* size (0 = byte, 1 = short, 2 = long) */
173 8, /* bitsize */
174 FALSE, /* pc_relative */
175 0, /* bitpos */
176 complain_overflow_bitfield,/* complain_on_overflow */
177 bfd_elf_generic_reloc, /* special_function */
178 "R_ARM_ABS8", /* name */
179 FALSE, /* partial_inplace */
180 0x000000ff, /* src_mask */
181 0x000000ff, /* dst_mask */
182 FALSE), /* pcrel_offset */
183
184 HOWTO (R_ARM_SBREL32, /* type */
185 0, /* rightshift */
186 2, /* size (0 = byte, 1 = short, 2 = long) */
187 32, /* bitsize */
188 FALSE, /* pc_relative */
189 0, /* bitpos */
190 complain_overflow_dont,/* complain_on_overflow */
191 bfd_elf_generic_reloc, /* special_function */
192 "R_ARM_SBREL32", /* name */
193 FALSE, /* partial_inplace */
194 0xffffffff, /* src_mask */
195 0xffffffff, /* dst_mask */
196 FALSE), /* pcrel_offset */
197
198 HOWTO (R_ARM_THM_PC22, /* type */
199 1, /* rightshift */
200 2, /* size (0 = byte, 1 = short, 2 = long) */
201 23, /* bitsize */
202 TRUE, /* pc_relative */
203 0, /* bitpos */
204 complain_overflow_signed,/* complain_on_overflow */
205 bfd_elf_generic_reloc, /* special_function */
206 "R_ARM_THM_PC22", /* name */
207 FALSE, /* partial_inplace */
208 0x07ff07ff, /* src_mask */
209 0x07ff07ff, /* dst_mask */
210 TRUE), /* pcrel_offset */
211
212 HOWTO (R_ARM_THM_PC8, /* type */
213 1, /* rightshift */
214 1, /* size (0 = byte, 1 = short, 2 = long) */
215 8, /* bitsize */
216 TRUE, /* pc_relative */
217 0, /* bitpos */
218 complain_overflow_signed,/* complain_on_overflow */
219 bfd_elf_generic_reloc, /* special_function */
220 "R_ARM_THM_PC8", /* name */
221 FALSE, /* partial_inplace */
222 0x000000ff, /* src_mask */
223 0x000000ff, /* dst_mask */
224 TRUE), /* pcrel_offset */
225
226 HOWTO (R_ARM_AMP_VCALL9, /* type */
227 1, /* rightshift */
228 1, /* size (0 = byte, 1 = short, 2 = long) */
229 8, /* bitsize */
230 TRUE, /* pc_relative */
231 0, /* bitpos */
232 complain_overflow_signed,/* complain_on_overflow */
233 bfd_elf_generic_reloc, /* special_function */
234 "R_ARM_AMP_VCALL9", /* name */
235 FALSE, /* partial_inplace */
236 0x000000ff, /* src_mask */
237 0x000000ff, /* dst_mask */
238 TRUE), /* pcrel_offset */
239
240 HOWTO (R_ARM_SWI24, /* type */
241 0, /* rightshift */
242 0, /* size (0 = byte, 1 = short, 2 = long) */
243 0, /* bitsize */
244 FALSE, /* pc_relative */
245 0, /* bitpos */
246 complain_overflow_signed,/* complain_on_overflow */
247 bfd_elf_generic_reloc, /* special_function */
248 "R_ARM_SWI24", /* name */
249 FALSE, /* partial_inplace */
250 0x00000000, /* src_mask */
251 0x00000000, /* dst_mask */
252 FALSE), /* pcrel_offset */
253
254 HOWTO (R_ARM_THM_SWI8, /* type */
255 0, /* rightshift */
256 0, /* size (0 = byte, 1 = short, 2 = long) */
257 0, /* bitsize */
258 FALSE, /* pc_relative */
259 0, /* bitpos */
260 complain_overflow_signed,/* complain_on_overflow */
261 bfd_elf_generic_reloc, /* special_function */
262 "R_ARM_SWI8", /* name */
263 FALSE, /* partial_inplace */
264 0x00000000, /* src_mask */
265 0x00000000, /* dst_mask */
266 FALSE), /* pcrel_offset */
267
268 /* BLX instruction for the ARM. */
269 HOWTO (R_ARM_XPC25, /* type */
270 2, /* rightshift */
271 2, /* size (0 = byte, 1 = short, 2 = long) */
272 25, /* bitsize */
273 TRUE, /* pc_relative */
274 0, /* bitpos */
275 complain_overflow_signed,/* complain_on_overflow */
276 bfd_elf_generic_reloc, /* special_function */
277 "R_ARM_XPC25", /* name */
278 FALSE, /* partial_inplace */
279 0x00ffffff, /* src_mask */
280 0x00ffffff, /* dst_mask */
281 TRUE), /* pcrel_offset */
282
283 /* BLX instruction for the Thumb. */
284 HOWTO (R_ARM_THM_XPC22, /* type */
285 2, /* rightshift */
286 2, /* size (0 = byte, 1 = short, 2 = long) */
287 22, /* bitsize */
288 TRUE, /* pc_relative */
289 0, /* bitpos */
290 complain_overflow_signed,/* complain_on_overflow */
291 bfd_elf_generic_reloc, /* special_function */
292 "R_ARM_THM_XPC22", /* name */
293 FALSE, /* partial_inplace */
294 0x07ff07ff, /* src_mask */
295 0x07ff07ff, /* dst_mask */
296 TRUE), /* pcrel_offset */
297
298 /* These next three relocs are not defined, but we need to fill the space. */
299
300 HOWTO (R_ARM_NONE, /* type */
301 0, /* rightshift */
302 0, /* size (0 = byte, 1 = short, 2 = long) */
303 0, /* bitsize */
304 FALSE, /* pc_relative */
305 0, /* bitpos */
306 complain_overflow_dont,/* complain_on_overflow */
307 bfd_elf_generic_reloc, /* special_function */
308 "R_ARM_unknown_17", /* name */
309 FALSE, /* partial_inplace */
310 0, /* src_mask */
311 0, /* dst_mask */
312 FALSE), /* pcrel_offset */
313
314 HOWTO (R_ARM_NONE, /* type */
315 0, /* rightshift */
316 0, /* size (0 = byte, 1 = short, 2 = long) */
317 0, /* bitsize */
318 FALSE, /* pc_relative */
319 0, /* bitpos */
320 complain_overflow_dont,/* complain_on_overflow */
321 bfd_elf_generic_reloc, /* special_function */
322 "R_ARM_unknown_18", /* name */
323 FALSE, /* partial_inplace */
324 0, /* src_mask */
325 0, /* dst_mask */
326 FALSE), /* pcrel_offset */
327
328 HOWTO (R_ARM_NONE, /* type */
329 0, /* rightshift */
330 0, /* size (0 = byte, 1 = short, 2 = long) */
331 0, /* bitsize */
332 FALSE, /* pc_relative */
333 0, /* bitpos */
334 complain_overflow_dont,/* complain_on_overflow */
335 bfd_elf_generic_reloc, /* special_function */
336 "R_ARM_unknown_19", /* name */
337 FALSE, /* partial_inplace */
338 0, /* src_mask */
339 0, /* dst_mask */
340 FALSE), /* pcrel_offset */
341
342 /* Relocs used in ARM Linux */
343
344 HOWTO (R_ARM_COPY, /* type */
345 0, /* rightshift */
346 2, /* size (0 = byte, 1 = short, 2 = long) */
347 32, /* bitsize */
348 FALSE, /* pc_relative */
349 0, /* bitpos */
350 complain_overflow_bitfield,/* complain_on_overflow */
351 bfd_elf_generic_reloc, /* special_function */
352 "R_ARM_COPY", /* name */
353 TRUE, /* partial_inplace */
354 0xffffffff, /* src_mask */
355 0xffffffff, /* dst_mask */
356 FALSE), /* pcrel_offset */
357
358 HOWTO (R_ARM_GLOB_DAT, /* type */
359 0, /* rightshift */
360 2, /* size (0 = byte, 1 = short, 2 = long) */
361 32, /* bitsize */
362 FALSE, /* pc_relative */
363 0, /* bitpos */
364 complain_overflow_bitfield,/* complain_on_overflow */
365 bfd_elf_generic_reloc, /* special_function */
366 "R_ARM_GLOB_DAT", /* name */
367 TRUE, /* partial_inplace */
368 0xffffffff, /* src_mask */
369 0xffffffff, /* dst_mask */
370 FALSE), /* pcrel_offset */
371
372 HOWTO (R_ARM_JUMP_SLOT, /* type */
373 0, /* rightshift */
374 2, /* size (0 = byte, 1 = short, 2 = long) */
375 32, /* bitsize */
376 FALSE, /* pc_relative */
377 0, /* bitpos */
378 complain_overflow_bitfield,/* complain_on_overflow */
379 bfd_elf_generic_reloc, /* special_function */
380 "R_ARM_JUMP_SLOT", /* name */
381 TRUE, /* partial_inplace */
382 0xffffffff, /* src_mask */
383 0xffffffff, /* dst_mask */
384 FALSE), /* pcrel_offset */
385
386 HOWTO (R_ARM_RELATIVE, /* type */
387 0, /* rightshift */
388 2, /* size (0 = byte, 1 = short, 2 = long) */
389 32, /* bitsize */
390 FALSE, /* pc_relative */
391 0, /* bitpos */
392 complain_overflow_bitfield,/* complain_on_overflow */
393 bfd_elf_generic_reloc, /* special_function */
394 "R_ARM_RELATIVE", /* name */
395 TRUE, /* partial_inplace */
396 0xffffffff, /* src_mask */
397 0xffffffff, /* dst_mask */
398 FALSE), /* pcrel_offset */
399
400 HOWTO (R_ARM_GOTOFF, /* type */
401 0, /* rightshift */
402 2, /* size (0 = byte, 1 = short, 2 = long) */
403 32, /* bitsize */
404 FALSE, /* pc_relative */
405 0, /* bitpos */
406 complain_overflow_bitfield,/* complain_on_overflow */
407 bfd_elf_generic_reloc, /* special_function */
408 "R_ARM_GOTOFF", /* name */
409 TRUE, /* partial_inplace */
410 0xffffffff, /* src_mask */
411 0xffffffff, /* dst_mask */
412 FALSE), /* pcrel_offset */
413
414 HOWTO (R_ARM_GOTPC, /* type */
415 0, /* rightshift */
416 2, /* size (0 = byte, 1 = short, 2 = long) */
417 32, /* bitsize */
418 TRUE, /* pc_relative */
419 0, /* bitpos */
420 complain_overflow_bitfield,/* complain_on_overflow */
421 bfd_elf_generic_reloc, /* special_function */
422 "R_ARM_GOTPC", /* name */
423 TRUE, /* partial_inplace */
424 0xffffffff, /* src_mask */
425 0xffffffff, /* dst_mask */
426 TRUE), /* pcrel_offset */
427
428 HOWTO (R_ARM_GOT32, /* type */
429 0, /* rightshift */
430 2, /* size (0 = byte, 1 = short, 2 = long) */
431 32, /* bitsize */
432 FALSE, /* pc_relative */
433 0, /* bitpos */
434 complain_overflow_bitfield,/* complain_on_overflow */
435 bfd_elf_generic_reloc, /* special_function */
436 "R_ARM_GOT32", /* name */
437 TRUE, /* partial_inplace */
438 0xffffffff, /* src_mask */
439 0xffffffff, /* dst_mask */
440 FALSE), /* pcrel_offset */
441
442 HOWTO (R_ARM_PLT32, /* type */
443 2, /* rightshift */
444 2, /* size (0 = byte, 1 = short, 2 = long) */
445 26, /* bitsize */
446 TRUE, /* pc_relative */
447 0, /* bitpos */
448 complain_overflow_bitfield,/* complain_on_overflow */
449 bfd_elf_generic_reloc, /* special_function */
450 "R_ARM_PLT32", /* name */
451 TRUE, /* partial_inplace */
452 0x00ffffff, /* src_mask */
453 0x00ffffff, /* dst_mask */
454 TRUE), /* pcrel_offset */
455
456 HOWTO (R_ARM_CALL, /* type */
457 2, /* rightshift */
458 2, /* size (0 = byte, 1 = short, 2 = long) */
459 24, /* bitsize */
460 TRUE, /* pc_relative */
461 0, /* bitpos */
462 complain_overflow_signed,/* complain_on_overflow */
463 bfd_elf_generic_reloc, /* special_function */
464 "R_ARM_CALL", /* name */
465 FALSE, /* partial_inplace */
466 0x00ffffff, /* src_mask */
467 0x00ffffff, /* dst_mask */
468 TRUE), /* pcrel_offset */
469
470 HOWTO (R_ARM_JUMP24, /* type */
471 2, /* rightshift */
472 2, /* size (0 = byte, 1 = short, 2 = long) */
473 24, /* bitsize */
474 TRUE, /* pc_relative */
475 0, /* bitpos */
476 complain_overflow_signed,/* complain_on_overflow */
477 bfd_elf_generic_reloc, /* special_function */
478 "R_ARM_JUMP24", /* name */
479 FALSE, /* partial_inplace */
480 0x00ffffff, /* src_mask */
481 0x00ffffff, /* dst_mask */
482 TRUE), /* pcrel_offset */
483
484 HOWTO (R_ARM_NONE, /* type */
485 0, /* rightshift */
486 0, /* size (0 = byte, 1 = short, 2 = long) */
487 0, /* bitsize */
488 FALSE, /* pc_relative */
489 0, /* bitpos */
490 complain_overflow_dont,/* complain_on_overflow */
491 bfd_elf_generic_reloc, /* special_function */
492 "R_ARM_unknown_30", /* name */
493 FALSE, /* partial_inplace */
494 0, /* src_mask */
495 0, /* dst_mask */
496 FALSE), /* pcrel_offset */
497
498 HOWTO (R_ARM_NONE, /* type */
499 0, /* rightshift */
500 0, /* size (0 = byte, 1 = short, 2 = long) */
501 0, /* bitsize */
502 FALSE, /* pc_relative */
503 0, /* bitpos */
504 complain_overflow_dont,/* complain_on_overflow */
505 bfd_elf_generic_reloc, /* special_function */
506 "R_ARM_unknown_31", /* name */
507 FALSE, /* partial_inplace */
508 0, /* src_mask */
509 0, /* dst_mask */
510 FALSE), /* pcrel_offset */
511
512 HOWTO (R_ARM_ALU_PCREL7_0, /* type */
513 0, /* rightshift */
514 2, /* size (0 = byte, 1 = short, 2 = long) */
515 12, /* bitsize */
516 TRUE, /* pc_relative */
517 0, /* bitpos */
518 complain_overflow_dont,/* complain_on_overflow */
519 bfd_elf_generic_reloc, /* special_function */
520 "R_ARM_ALU_PCREL_7_0", /* name */
521 FALSE, /* partial_inplace */
522 0x00000fff, /* src_mask */
523 0x00000fff, /* dst_mask */
524 TRUE), /* pcrel_offset */
525
526 HOWTO (R_ARM_ALU_PCREL15_8, /* type */
527 0, /* rightshift */
528 2, /* size (0 = byte, 1 = short, 2 = long) */
529 12, /* bitsize */
530 TRUE, /* pc_relative */
531 8, /* bitpos */
532 complain_overflow_dont,/* complain_on_overflow */
533 bfd_elf_generic_reloc, /* special_function */
534 "R_ARM_ALU_PCREL_15_8",/* name */
535 FALSE, /* partial_inplace */
536 0x00000fff, /* src_mask */
537 0x00000fff, /* dst_mask */
538 TRUE), /* pcrel_offset */
539
540 HOWTO (R_ARM_ALU_PCREL23_15, /* type */
541 0, /* rightshift */
542 2, /* size (0 = byte, 1 = short, 2 = long) */
543 12, /* bitsize */
544 TRUE, /* pc_relative */
545 16, /* bitpos */
546 complain_overflow_dont,/* complain_on_overflow */
547 bfd_elf_generic_reloc, /* special_function */
548 "R_ARM_ALU_PCREL_23_15",/* name */
549 FALSE, /* partial_inplace */
550 0x00000fff, /* src_mask */
551 0x00000fff, /* dst_mask */
552 TRUE), /* pcrel_offset */
553
554 HOWTO (R_ARM_LDR_SBREL_11_0, /* type */
555 0, /* rightshift */
556 2, /* size (0 = byte, 1 = short, 2 = long) */
557 12, /* bitsize */
558 FALSE, /* pc_relative */
559 0, /* bitpos */
560 complain_overflow_dont,/* complain_on_overflow */
561 bfd_elf_generic_reloc, /* special_function */
562 "R_ARM_LDR_SBREL_11_0",/* name */
563 FALSE, /* partial_inplace */
564 0x00000fff, /* src_mask */
565 0x00000fff, /* dst_mask */
566 FALSE), /* pcrel_offset */
567
568 HOWTO (R_ARM_ALU_SBREL_19_12, /* type */
569 0, /* rightshift */
570 2, /* size (0 = byte, 1 = short, 2 = long) */
571 8, /* bitsize */
572 FALSE, /* pc_relative */
573 12, /* bitpos */
574 complain_overflow_dont,/* complain_on_overflow */
575 bfd_elf_generic_reloc, /* special_function */
576 "R_ARM_ALU_SBREL_19_12",/* name */
577 FALSE, /* partial_inplace */
578 0x000ff000, /* src_mask */
579 0x000ff000, /* dst_mask */
580 FALSE), /* pcrel_offset */
581
582 HOWTO (R_ARM_ALU_SBREL_27_20, /* type */
583 0, /* rightshift */
584 2, /* size (0 = byte, 1 = short, 2 = long) */
585 8, /* bitsize */
586 FALSE, /* pc_relative */
587 20, /* bitpos */
588 complain_overflow_dont,/* complain_on_overflow */
589 bfd_elf_generic_reloc, /* special_function */
590 "R_ARM_ALU_SBREL_27_20",/* name */
591 FALSE, /* partial_inplace */
592 0x0ff00000, /* src_mask */
593 0x0ff00000, /* dst_mask */
594 FALSE), /* pcrel_offset */
595
596 HOWTO (R_ARM_TARGET1, /* type */
597 0, /* rightshift */
598 2, /* size (0 = byte, 1 = short, 2 = long) */
599 32, /* bitsize */
600 FALSE, /* pc_relative */
601 0, /* bitpos */
602 complain_overflow_dont,/* complain_on_overflow */
603 bfd_elf_generic_reloc, /* special_function */
604 "R_ARM_TARGET1", /* name */
605 FALSE, /* partial_inplace */
606 0xffffffff, /* src_mask */
607 0xffffffff, /* dst_mask */
608 FALSE), /* pcrel_offset */
609
610 HOWTO (R_ARM_ROSEGREL32, /* type */
611 0, /* rightshift */
612 2, /* size (0 = byte, 1 = short, 2 = long) */
613 32, /* bitsize */
614 FALSE, /* pc_relative */
615 0, /* bitpos */
616 complain_overflow_dont,/* complain_on_overflow */
617 bfd_elf_generic_reloc, /* special_function */
618 "R_ARM_ROSEGREL32", /* name */
619 FALSE, /* partial_inplace */
620 0xffffffff, /* src_mask */
621 0xffffffff, /* dst_mask */
622 FALSE), /* pcrel_offset */
623
624 HOWTO (R_ARM_V4BX, /* type */
625 0, /* rightshift */
626 2, /* size (0 = byte, 1 = short, 2 = long) */
627 32, /* bitsize */
628 FALSE, /* pc_relative */
629 0, /* bitpos */
630 complain_overflow_dont,/* complain_on_overflow */
631 bfd_elf_generic_reloc, /* special_function */
632 "R_ARM_V4BX", /* name */
633 FALSE, /* partial_inplace */
634 0xffffffff, /* src_mask */
635 0xffffffff, /* dst_mask */
636 FALSE), /* pcrel_offset */
637
638 HOWTO (R_ARM_TARGET2, /* type */
639 0, /* rightshift */
640 2, /* size (0 = byte, 1 = short, 2 = long) */
641 32, /* bitsize */
642 FALSE, /* pc_relative */
643 0, /* bitpos */
644 complain_overflow_signed,/* complain_on_overflow */
645 bfd_elf_generic_reloc, /* special_function */
646 "R_ARM_TARGET2", /* name */
647 FALSE, /* partial_inplace */
648 0xffffffff, /* src_mask */
649 0xffffffff, /* dst_mask */
650 TRUE), /* pcrel_offset */
651
652 HOWTO (R_ARM_PREL31, /* type */
653 0, /* rightshift */
654 2, /* size (0 = byte, 1 = short, 2 = long) */
655 31, /* bitsize */
656 TRUE, /* pc_relative */
657 0, /* bitpos */
658 complain_overflow_signed,/* complain_on_overflow */
659 bfd_elf_generic_reloc, /* special_function */
660 "R_ARM_PREL31", /* name */
661 FALSE, /* partial_inplace */
662 0x7fffffff, /* src_mask */
663 0x7fffffff, /* dst_mask */
664 TRUE), /* pcrel_offset */
665 };
666
667 /* GNU extension to record C++ vtable hierarchy */
668 static reloc_howto_type elf32_arm_vtinherit_howto =
669 HOWTO (R_ARM_GNU_VTINHERIT, /* type */
670 0, /* rightshift */
671 2, /* size (0 = byte, 1 = short, 2 = long) */
672 0, /* bitsize */
673 FALSE, /* pc_relative */
674 0, /* bitpos */
675 complain_overflow_dont, /* complain_on_overflow */
676 NULL, /* special_function */
677 "R_ARM_GNU_VTINHERIT", /* name */
678 FALSE, /* partial_inplace */
679 0, /* src_mask */
680 0, /* dst_mask */
681 FALSE); /* pcrel_offset */
682
683 /* GNU extension to record C++ vtable member usage */
684 static reloc_howto_type elf32_arm_vtentry_howto =
685 HOWTO (R_ARM_GNU_VTENTRY, /* type */
686 0, /* rightshift */
687 2, /* size (0 = byte, 1 = short, 2 = long) */
688 0, /* bitsize */
689 FALSE, /* pc_relative */
690 0, /* bitpos */
691 complain_overflow_dont, /* complain_on_overflow */
692 _bfd_elf_rel_vtable_reloc_fn, /* special_function */
693 "R_ARM_GNU_VTENTRY", /* name */
694 FALSE, /* partial_inplace */
695 0, /* src_mask */
696 0, /* dst_mask */
697 FALSE); /* pcrel_offset */
698
699 /* 12 bit pc relative */
700 static reloc_howto_type elf32_arm_thm_pc11_howto =
701 HOWTO (R_ARM_THM_PC11, /* type */
702 1, /* rightshift */
703 1, /* size (0 = byte, 1 = short, 2 = long) */
704 11, /* bitsize */
705 TRUE, /* pc_relative */
706 0, /* bitpos */
707 complain_overflow_signed, /* complain_on_overflow */
708 bfd_elf_generic_reloc, /* special_function */
709 "R_ARM_THM_PC11", /* name */
710 FALSE, /* partial_inplace */
711 0x000007ff, /* src_mask */
712 0x000007ff, /* dst_mask */
713 TRUE); /* pcrel_offset */
714
715 /* 12 bit pc relative */
716 static reloc_howto_type elf32_arm_thm_pc9_howto =
717 HOWTO (R_ARM_THM_PC9, /* type */
718 1, /* rightshift */
719 1, /* size (0 = byte, 1 = short, 2 = long) */
720 8, /* bitsize */
721 TRUE, /* pc_relative */
722 0, /* bitpos */
723 complain_overflow_signed, /* complain_on_overflow */
724 bfd_elf_generic_reloc, /* special_function */
725 "R_ARM_THM_PC9", /* name */
726 FALSE, /* partial_inplace */
727 0x000000ff, /* src_mask */
728 0x000000ff, /* dst_mask */
729 TRUE); /* pcrel_offset */
730
731 /* Place relative GOT-indirect. */
732 static reloc_howto_type elf32_arm_got_prel =
733 HOWTO (R_ARM_GOT_PREL, /* type */
734 0, /* rightshift */
735 2, /* size (0 = byte, 1 = short, 2 = long) */
736 32, /* bitsize */
737 TRUE, /* pc_relative */
738 0, /* bitpos */
739 complain_overflow_dont, /* complain_on_overflow */
740 bfd_elf_generic_reloc, /* special_function */
741 "R_ARM_GOT_PREL", /* name */
742 FALSE, /* partial_inplace */
743 0xffffffff, /* src_mask */
744 0xffffffff, /* dst_mask */
745 TRUE); /* pcrel_offset */
746
747 /* Currently unused relocations. */
748 static reloc_howto_type elf32_arm_r_howto[4] =
749 {
750 HOWTO (R_ARM_RREL32, /* type */
751 0, /* rightshift */
752 0, /* size (0 = byte, 1 = short, 2 = long) */
753 0, /* bitsize */
754 FALSE, /* pc_relative */
755 0, /* bitpos */
756 complain_overflow_dont,/* complain_on_overflow */
757 bfd_elf_generic_reloc, /* special_function */
758 "R_ARM_RREL32", /* name */
759 FALSE, /* partial_inplace */
760 0, /* src_mask */
761 0, /* dst_mask */
762 FALSE), /* pcrel_offset */
763
764 HOWTO (R_ARM_RABS32, /* type */
765 0, /* rightshift */
766 0, /* size (0 = byte, 1 = short, 2 = long) */
767 0, /* bitsize */
768 FALSE, /* pc_relative */
769 0, /* bitpos */
770 complain_overflow_dont,/* complain_on_overflow */
771 bfd_elf_generic_reloc, /* special_function */
772 "R_ARM_RABS32", /* name */
773 FALSE, /* partial_inplace */
774 0, /* src_mask */
775 0, /* dst_mask */
776 FALSE), /* pcrel_offset */
777
778 HOWTO (R_ARM_RPC24, /* type */
779 0, /* rightshift */
780 0, /* size (0 = byte, 1 = short, 2 = long) */
781 0, /* bitsize */
782 FALSE, /* pc_relative */
783 0, /* bitpos */
784 complain_overflow_dont,/* complain_on_overflow */
785 bfd_elf_generic_reloc, /* special_function */
786 "R_ARM_RPC24", /* name */
787 FALSE, /* partial_inplace */
788 0, /* src_mask */
789 0, /* dst_mask */
790 FALSE), /* pcrel_offset */
791
792 HOWTO (R_ARM_RBASE, /* type */
793 0, /* rightshift */
794 0, /* size (0 = byte, 1 = short, 2 = long) */
795 0, /* bitsize */
796 FALSE, /* pc_relative */
797 0, /* bitpos */
798 complain_overflow_dont,/* complain_on_overflow */
799 bfd_elf_generic_reloc, /* special_function */
800 "R_ARM_RBASE", /* name */
801 FALSE, /* partial_inplace */
802 0, /* src_mask */
803 0, /* dst_mask */
804 FALSE) /* pcrel_offset */
805 };
806
807 static reloc_howto_type *
808 elf32_arm_howto_from_type (unsigned int r_type)
809 {
810 if (r_type < NUM_ELEM (elf32_arm_howto_table))
811 return &elf32_arm_howto_table[r_type];
812
813 switch (r_type)
814 {
815 case R_ARM_GOT_PREL:
816 return &elf32_arm_got_prel;
817
818 case R_ARM_GNU_VTINHERIT:
819 return &elf32_arm_vtinherit_howto;
820
821 case R_ARM_GNU_VTENTRY:
822 return &elf32_arm_vtentry_howto;
823
824 case R_ARM_THM_PC11:
825 return &elf32_arm_thm_pc11_howto;
826
827 case R_ARM_THM_PC9:
828 return &elf32_arm_thm_pc9_howto;
829
830 case R_ARM_RREL32:
831 case R_ARM_RABS32:
832 case R_ARM_RPC24:
833 case R_ARM_RBASE:
834 return &elf32_arm_r_howto[r_type - R_ARM_RREL32];
835
836 default:
837 return NULL;
838 }
839 }
840
841 static void
842 elf32_arm_info_to_howto (bfd * abfd ATTRIBUTE_UNUSED, arelent * bfd_reloc,
843 Elf_Internal_Rela * elf_reloc)
844 {
845 unsigned int r_type;
846
847 r_type = ELF32_R_TYPE (elf_reloc->r_info);
848 bfd_reloc->howto = elf32_arm_howto_from_type (r_type);
849 }
850
851 struct elf32_arm_reloc_map
852 {
853 bfd_reloc_code_real_type bfd_reloc_val;
854 unsigned char elf_reloc_val;
855 };
856
857 /* All entries in this list must also be present in elf32_arm_howto_table. */
858 static const struct elf32_arm_reloc_map elf32_arm_reloc_map[] =
859 {
860 {BFD_RELOC_NONE, R_ARM_NONE},
861 {BFD_RELOC_ARM_PCREL_BRANCH, R_ARM_PC24},
862 {BFD_RELOC_ARM_PCREL_BLX, R_ARM_XPC25},
863 {BFD_RELOC_THUMB_PCREL_BLX, R_ARM_THM_XPC22},
864 {BFD_RELOC_32, R_ARM_ABS32},
865 {BFD_RELOC_32_PCREL, R_ARM_REL32},
866 {BFD_RELOC_8, R_ARM_ABS8},
867 {BFD_RELOC_16, R_ARM_ABS16},
868 {BFD_RELOC_ARM_OFFSET_IMM, R_ARM_ABS12},
869 {BFD_RELOC_ARM_THUMB_OFFSET, R_ARM_THM_ABS5},
870 {BFD_RELOC_THUMB_PCREL_BRANCH23, R_ARM_THM_PC22},
871 {BFD_RELOC_ARM_COPY, R_ARM_COPY},
872 {BFD_RELOC_ARM_GLOB_DAT, R_ARM_GLOB_DAT},
873 {BFD_RELOC_ARM_JUMP_SLOT, R_ARM_JUMP_SLOT},
874 {BFD_RELOC_ARM_RELATIVE, R_ARM_RELATIVE},
875 {BFD_RELOC_ARM_GOTOFF, R_ARM_GOTOFF},
876 {BFD_RELOC_ARM_GOTPC, R_ARM_GOTPC},
877 {BFD_RELOC_ARM_GOT32, R_ARM_GOT32},
878 {BFD_RELOC_ARM_PLT32, R_ARM_PLT32},
879 {BFD_RELOC_ARM_TARGET1, R_ARM_TARGET1},
880 {BFD_RELOC_ARM_ROSEGREL32, R_ARM_ROSEGREL32},
881 {BFD_RELOC_ARM_SBREL32, R_ARM_SBREL32},
882 {BFD_RELOC_ARM_PREL31, R_ARM_PREL31},
883 {BFD_RELOC_ARM_TARGET2, R_ARM_TARGET2}
884 };
885
886 static reloc_howto_type *
887 elf32_arm_reloc_type_lookup (abfd, code)
888 bfd *abfd ATTRIBUTE_UNUSED;
889 bfd_reloc_code_real_type code;
890 {
891 unsigned int i;
892
893 switch (code)
894 {
895 case BFD_RELOC_VTABLE_INHERIT:
896 return & elf32_arm_vtinherit_howto;
897
898 case BFD_RELOC_VTABLE_ENTRY:
899 return & elf32_arm_vtentry_howto;
900
901 case BFD_RELOC_THUMB_PCREL_BRANCH12:
902 return & elf32_arm_thm_pc11_howto;
903
904 case BFD_RELOC_THUMB_PCREL_BRANCH9:
905 return & elf32_arm_thm_pc9_howto;
906
907 default:
908 for (i = 0; i < NUM_ELEM (elf32_arm_reloc_map); i ++)
909 if (elf32_arm_reloc_map[i].bfd_reloc_val == code)
910 return & elf32_arm_howto_table[elf32_arm_reloc_map[i].elf_reloc_val];
911
912 return NULL;
913 }
914 }
915
916 /* Support for core dump NOTE sections */
917 static bfd_boolean
918 elf32_arm_nabi_grok_prstatus (abfd, note)
919 bfd *abfd;
920 Elf_Internal_Note *note;
921 {
922 int offset;
923 size_t size;
924
925 switch (note->descsz)
926 {
927 default:
928 return FALSE;
929
930 case 148: /* Linux/ARM 32-bit*/
931 /* pr_cursig */
932 elf_tdata (abfd)->core_signal = bfd_get_16 (abfd, note->descdata + 12);
933
934 /* pr_pid */
935 elf_tdata (abfd)->core_pid = bfd_get_32 (abfd, note->descdata + 24);
936
937 /* pr_reg */
938 offset = 72;
939 size = 72;
940
941 break;
942 }
943
944 /* Make a ".reg/999" section. */
945 return _bfd_elfcore_make_pseudosection (abfd, ".reg",
946 size, note->descpos + offset);
947 }
948
949 static bfd_boolean
950 elf32_arm_nabi_grok_psinfo (abfd, note)
951 bfd *abfd;
952 Elf_Internal_Note *note;
953 {
954 switch (note->descsz)
955 {
956 default:
957 return FALSE;
958
959 case 124: /* Linux/ARM elf_prpsinfo */
960 elf_tdata (abfd)->core_program
961 = _bfd_elfcore_strndup (abfd, note->descdata + 28, 16);
962 elf_tdata (abfd)->core_command
963 = _bfd_elfcore_strndup (abfd, note->descdata + 44, 80);
964 }
965
966 /* Note that for some reason, a spurious space is tacked
967 onto the end of the args in some (at least one anyway)
968 implementations, so strip it off if it exists. */
969
970 {
971 char *command = elf_tdata (abfd)->core_command;
972 int n = strlen (command);
973
974 if (0 < n && command[n - 1] == ' ')
975 command[n - 1] = '\0';
976 }
977
978 return TRUE;
979 }
980
981 #define TARGET_LITTLE_SYM bfd_elf32_littlearm_vec
982 #define TARGET_LITTLE_NAME "elf32-littlearm"
983 #define TARGET_BIG_SYM bfd_elf32_bigarm_vec
984 #define TARGET_BIG_NAME "elf32-bigarm"
985
986 #define elf_backend_grok_prstatus elf32_arm_nabi_grok_prstatus
987 #define elf_backend_grok_psinfo elf32_arm_nabi_grok_psinfo
988
989 #include "elf32-arm.h"
990
991 /* Symbian OS Targets */
992
993 #undef TARGET_LITTLE_SYM
994 #define TARGET_LITTLE_SYM bfd_elf32_littlearm_symbian_vec
995 #undef TARGET_LITTLE_NAME
996 #define TARGET_LITTLE_NAME "elf32-littlearm-symbian"
997 #undef TARGET_BIG_SYM
998 #define TARGET_BIG_SYM bfd_elf32_bigarm_symbian_vec
999 #undef TARGET_BIG_NAME
1000 #define TARGET_BIG_NAME "elf32-bigarm-symbian"
1001
1002 /* Like elf32_arm_link_hash_table_create -- but overrides
1003 appropriately for Symbian OS. */
1004 static struct bfd_link_hash_table *
1005 elf32_arm_symbian_link_hash_table_create (bfd *abfd)
1006 {
1007 struct bfd_link_hash_table *ret;
1008
1009 ret = elf32_arm_link_hash_table_create (abfd);
1010 if (ret)
1011 {
1012 struct elf32_arm_link_hash_table *htab
1013 = (struct elf32_arm_link_hash_table *)ret;
1014 /* There is no PLT header for Symbian OS. */
1015 htab->plt_header_size = 0;
1016 /* The PLT entries are each three instructions. */
1017 htab->plt_entry_size = 4 * NUM_ELEM (elf32_arm_symbian_plt_entry);
1018 htab->symbian_p = 1;
1019 }
1020 return ret;
1021 }
1022
1023 /* In a BPABI executable, the dynamic linking sections do not go in
1024 the loadable read-only segment. The post-linker may wish to refer
1025 to these sections, but they are not part of the final program
1026 image. */
1027 static struct bfd_elf_special_section const
1028 elf32_arm_symbian_special_sections[]=
1029 {
1030 { ".dynamic", 8, 0, SHT_DYNAMIC, 0 },
1031 { ".dynstr", 7, 0, SHT_STRTAB, 0 },
1032 { ".dynsym", 7, 0, SHT_DYNSYM, 0 },
1033 { ".got", 4, 0, SHT_PROGBITS, 0 },
1034 { ".hash", 5, 0, SHT_HASH, 0 },
1035 { NULL, 0, 0, 0, 0 }
1036 };
1037
1038 static bfd_boolean
1039 elf32_arm_symbian_modify_segment_map
1040 PARAMS ((bfd *, struct bfd_link_info *));
1041
1042 static bfd_boolean
1043 elf32_arm_symbian_modify_segment_map (abfd, info)
1044 bfd *abfd;
1045 struct bfd_link_info *info ATTRIBUTE_UNUSED;
1046 {
1047 struct elf_segment_map *m;
1048 asection *dynsec;
1049
1050 /* The first PT_LOAD segment will have the program headers and file
1051 headers in it by default -- but BPABI object files should not
1052 include these headers in any loadable segment. */
1053 for (m = elf_tdata (abfd)->segment_map; m != NULL; m = m->next)
1054 if (m->p_type == PT_LOAD)
1055 {
1056 m->includes_filehdr = 0;
1057 m->includes_phdrs = 0;
1058 }
1059
1060 /* BPABI shared libraries and executables should have a PT_DYNAMIC
1061 segment. However, because the .dynamic section is not marked
1062 with SEC_LOAD, the generic ELF code will not create such a
1063 segment. */
1064 dynsec = bfd_get_section_by_name (abfd, ".dynamic");
1065 if (dynsec)
1066 {
1067 m = _bfd_elf_make_dynamic_segment (abfd, dynsec);
1068 m->next = elf_tdata (abfd)->segment_map;
1069 elf_tdata (abfd)->segment_map = m;
1070 }
1071
1072 return TRUE;
1073 }
1074
1075 #undef elf32_bed
1076 #define elf32_bed elf32_arm_symbian_bed
1077
1078 /* The dynamic sections are not allocated on SymbianOS; the postlinker
1079 will process them and then discard them. */
1080 #undef ELF_DYNAMIC_SEC_FLAGS
1081 #define ELF_DYNAMIC_SEC_FLAGS \
1082 (SEC_HAS_CONTENTS | SEC_IN_MEMORY | SEC_LINKER_CREATED)
1083
1084 #undef bfd_elf32_bfd_link_hash_table_create
1085 #define bfd_elf32_bfd_link_hash_table_create \
1086 elf32_arm_symbian_link_hash_table_create
1087
1088 #undef elf_backend_special_sections
1089 #define elf_backend_special_sections elf32_arm_symbian_special_sections
1090
1091 #undef elf_backend_modify_segment_map
1092 #define elf_backend_modify_segment_map elf32_arm_symbian_modify_segment_map
1093
1094 /* There is no .got section for BPABI objects, and hence no header. */
1095 #undef elf_backend_got_header_size
1096 #define elf_backend_got_header_size 0
1097
1098 /* Similarly, there is no .got.plt section. */
1099 #undef elf_backend_want_got_plt
1100 #define elf_backend_want_got_plt 0
1101
1102 #include "elf32-target.h"
1103