1 |
/* ARC-specific support for 32-bit ELF |
/* ARC-specific support for 32-bit ELF |
2 |
Copyright 1994, 1995, 1997, 1999, 2001 Free Software Foundation, Inc. |
Copyright 1994, 1995, 1997, 1999, 2001, 2002 |
3 |
|
Free Software Foundation, Inc. |
4 |
Contributed by Doug Evans (dje@cygnus.com). |
Contributed by Doug Evans (dje@cygnus.com). |
5 |
|
|
6 |
This file is part of BFD, the Binary File Descriptor library. |
This file is part of BFD, the Binary File Descriptor library. |
29 |
static reloc_howto_type *bfd_elf32_bfd_reloc_type_lookup |
static reloc_howto_type *bfd_elf32_bfd_reloc_type_lookup |
30 |
PARAMS ((bfd *abfd, bfd_reloc_code_real_type code)); |
PARAMS ((bfd *abfd, bfd_reloc_code_real_type code)); |
31 |
static void arc_info_to_howto_rel |
static void arc_info_to_howto_rel |
32 |
PARAMS ((bfd *, arelent *, Elf32_Internal_Rel *)); |
PARAMS ((bfd *, arelent *, Elf_Internal_Rela *)); |
33 |
static boolean arc_elf_object_p |
static bfd_boolean arc_elf_object_p |
34 |
PARAMS ((bfd *)); |
PARAMS ((bfd *)); |
35 |
static void arc_elf_final_write_processing |
static void arc_elf_final_write_processing |
36 |
PARAMS ((bfd *, boolean)); |
PARAMS ((bfd *, bfd_boolean)); |
37 |
static bfd_reloc_status_type arc_elf_b22_pcrel |
static bfd_reloc_status_type arc_elf_b22_pcrel |
38 |
PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **)); |
PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **)); |
39 |
|
|
40 |
/* Try to minimize the amount of space occupied by relocation tables |
/* Try to minimize the amount of space occupied by relocation tables |
41 |
on the ROM (not that the ROM won't be swamped by other ELF overhead). */ |
on the ROM (not that the ROM won't be swamped by other ELF overhead). */ |
42 |
|
|
43 |
#define USE_REL |
#define USE_REL 1 |
44 |
|
|
45 |
static reloc_howto_type elf_arc_howto_table[] = |
static reloc_howto_type elf_arc_howto_table[] = |
46 |
{ |
{ |
49 |
0, /* rightshift */ |
0, /* rightshift */ |
50 |
2, /* size (0 = byte, 1 = short, 2 = long) */ |
2, /* size (0 = byte, 1 = short, 2 = long) */ |
51 |
32, /* bitsize */ |
32, /* bitsize */ |
52 |
false, /* pc_relative */ |
FALSE, /* pc_relative */ |
53 |
0, /* bitpos */ |
0, /* bitpos */ |
54 |
complain_overflow_bitfield, /* complain_on_overflow */ |
complain_overflow_bitfield, /* complain_on_overflow */ |
55 |
bfd_elf_generic_reloc, /* special_function */ |
bfd_elf_generic_reloc, /* special_function */ |
56 |
"R_ARC_NONE", /* name */ |
"R_ARC_NONE", /* name */ |
57 |
true, /* partial_inplace */ |
TRUE, /* partial_inplace */ |
58 |
0, /* src_mask */ |
0, /* src_mask */ |
59 |
0, /* dst_mask */ |
0, /* dst_mask */ |
60 |
false), /* pcrel_offset */ |
FALSE), /* pcrel_offset */ |
61 |
|
|
62 |
/* A standard 32 bit relocation. */ |
/* A standard 32 bit relocation. */ |
63 |
HOWTO (R_ARC_32, /* type */ |
HOWTO (R_ARC_32, /* type */ |
64 |
0, /* rightshift */ |
0, /* rightshift */ |
65 |
2, /* size (0 = byte, 1 = short, 2 = long) */ |
2, /* size (0 = byte, 1 = short, 2 = long) */ |
66 |
32, /* bitsize */ |
32, /* bitsize */ |
67 |
false, /* pc_relative */ |
FALSE, /* pc_relative */ |
68 |
0, /* bitpos */ |
0, /* bitpos */ |
69 |
complain_overflow_bitfield, /* complain_on_overflow */ |
complain_overflow_bitfield, /* complain_on_overflow */ |
70 |
bfd_elf_generic_reloc, /* special_function */ |
bfd_elf_generic_reloc, /* special_function */ |
71 |
"R_ARC_32", /* name */ |
"R_ARC_32", /* name */ |
72 |
true, /* partial_inplace */ |
TRUE, /* partial_inplace */ |
73 |
0xffffffff, /* src_mask */ |
0xffffffff, /* src_mask */ |
74 |
0xffffffff, /* dst_mask */ |
0xffffffff, /* dst_mask */ |
75 |
false), /* pcrel_offset */ |
FALSE), /* pcrel_offset */ |
76 |
|
|
77 |
/* A 26 bit absolute branch, right shifted by 2. */ |
/* A 26 bit absolute branch, right shifted by 2. */ |
78 |
HOWTO (R_ARC_B26, /* type */ |
HOWTO (R_ARC_B26, /* type */ |
79 |
2, /* rightshift */ |
2, /* rightshift */ |
80 |
2, /* size (0 = byte, 1 = short, 2 = long) */ |
2, /* size (0 = byte, 1 = short, 2 = long) */ |
81 |
26, /* bitsize */ |
26, /* bitsize */ |
82 |
false, /* pc_relative */ |
FALSE, /* pc_relative */ |
83 |
0, /* bitpos */ |
0, /* bitpos */ |
84 |
complain_overflow_bitfield, /* complain_on_overflow */ |
complain_overflow_bitfield, /* complain_on_overflow */ |
85 |
bfd_elf_generic_reloc, /* special_function */ |
bfd_elf_generic_reloc, /* special_function */ |
86 |
"R_ARC_B26", /* name */ |
"R_ARC_B26", /* name */ |
87 |
true, /* partial_inplace */ |
TRUE, /* partial_inplace */ |
88 |
0x00ffffff, /* src_mask */ |
0x00ffffff, /* src_mask */ |
89 |
0x00ffffff, /* dst_mask */ |
0x00ffffff, /* dst_mask */ |
90 |
false), /* pcrel_offset */ |
FALSE), /* pcrel_offset */ |
91 |
|
|
92 |
/* A relative 22 bit branch; bits 21-2 are stored in bits 26-7. */ |
/* A relative 22 bit branch; bits 21-2 are stored in bits 26-7. */ |
93 |
HOWTO (R_ARC_B22_PCREL, /* type */ |
HOWTO (R_ARC_B22_PCREL, /* type */ |
94 |
2, /* rightshift */ |
2, /* rightshift */ |
95 |
2, /* size (0 = byte, 1 = short, 2 = long) */ |
2, /* size (0 = byte, 1 = short, 2 = long) */ |
96 |
22, /* bitsize */ |
22, /* bitsize */ |
97 |
true, /* pc_relative */ |
TRUE, /* pc_relative */ |
98 |
7, /* bitpos */ |
7, /* bitpos */ |
99 |
complain_overflow_signed, /* complain_on_overflow */ |
complain_overflow_signed, /* complain_on_overflow */ |
100 |
arc_elf_b22_pcrel, /* special_function */ |
arc_elf_b22_pcrel, /* special_function */ |
101 |
"R_ARC_B22_PCREL", /* name */ |
"R_ARC_B22_PCREL", /* name */ |
102 |
true, /* partial_inplace */ |
TRUE, /* partial_inplace */ |
103 |
0x07ffff80, /* src_mask */ |
0x07ffff80, /* src_mask */ |
104 |
0x07ffff80, /* dst_mask */ |
0x07ffff80, /* dst_mask */ |
105 |
false), /* pcrel_offset */ |
FALSE), /* pcrel_offset */ |
106 |
}; |
}; |
107 |
|
|
108 |
/* Map BFD reloc types to ARC ELF reloc types. */ |
/* Map BFD reloc types to ARC ELF reloc types. */ |
142 |
arc_info_to_howto_rel (abfd, cache_ptr, dst) |
arc_info_to_howto_rel (abfd, cache_ptr, dst) |
143 |
bfd *abfd ATTRIBUTE_UNUSED; |
bfd *abfd ATTRIBUTE_UNUSED; |
144 |
arelent *cache_ptr; |
arelent *cache_ptr; |
145 |
Elf32_Internal_Rel *dst; |
Elf_Internal_Rela *dst; |
146 |
{ |
{ |
147 |
unsigned int r_type; |
unsigned int r_type; |
148 |
|
|
153 |
|
|
154 |
/* Set the right machine number for an ARC ELF file. */ |
/* Set the right machine number for an ARC ELF file. */ |
155 |
|
|
156 |
static boolean |
static bfd_boolean |
157 |
arc_elf_object_p (abfd) |
arc_elf_object_p (abfd) |
158 |
bfd *abfd; |
bfd *abfd; |
159 |
{ |
{ |
189 |
static void |
static void |
190 |
arc_elf_final_write_processing (abfd, linker) |
arc_elf_final_write_processing (abfd, linker) |
191 |
bfd *abfd; |
bfd *abfd; |
192 |
boolean linker ATTRIBUTE_UNUSED; |
bfd_boolean linker ATTRIBUTE_UNUSED; |
193 |
{ |
{ |
194 |
unsigned long val; |
unsigned long val; |
195 |
|
|
226 |
{ |
{ |
227 |
/* If linking, back up the final symbol address by the address of the |
/* If linking, back up the final symbol address by the address of the |
228 |
reloc. This cannot be accomplished by setting the pcrel_offset |
reloc. This cannot be accomplished by setting the pcrel_offset |
229 |
field to true, as bfd_install_relocation will detect this and refuse |
field to TRUE, as bfd_install_relocation will detect this and refuse |
230 |
to install the offset in the first place, but bfd_perform_relocation |
to install the offset in the first place, but bfd_perform_relocation |
231 |
will still insist on removing it. */ |
will still insist on removing it. */ |
232 |
if (output_bfd == (bfd *) NULL) |
if (output_bfd == (bfd *) NULL) |