Commit | Line | Data |
---|---|---|
252b5132 | 1 | /* BFD back-end for raw ARM a.out binaries. |
b90efa5b | 2 | Copyright (C) 1994-2015 Free Software Foundation, Inc. |
252b5132 | 3 | Contributed by Richard Earnshaw (rwe@pegasus.esprit.ec.org) |
c4dfa77f | 4 | |
7920ce38 | 5 | This file is part of BFD, the Binary File Descriptor library. |
252b5132 | 6 | |
7920ce38 NC |
7 | This program is free software; you can redistribute it and/or modify |
8 | it under the terms of the GNU General Public License as published by | |
cd123cb7 | 9 | the Free Software Foundation; either version 3 of the License, or |
7920ce38 | 10 | (at your option) any later version. |
252b5132 | 11 | |
7920ce38 NC |
12 | This program is distributed in the hope that it will be useful, |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | GNU General Public License for more details. | |
252b5132 | 16 | |
7920ce38 NC |
17 | You should have received a copy of the GNU General Public License |
18 | along with this program; if not, write to the Free Software | |
3e110533 | 19 | Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ |
252b5132 | 20 | |
1725a96e | 21 | #include "sysdep.h" |
3db64b00 | 22 | #include "bfd.h" |
e43d48cc | 23 | |
5c4491d3 | 24 | /* Avoid multiple definitions from aoutx if supporting standard a.out |
1725a96e | 25 | as well as our own. */ |
e43d48cc AM |
26 | /* Do not "beautify" the CONCAT* macro args. Traditional C will not |
27 | remove whitespace added here, and thus will fail to concatenate | |
28 | the tokens. */ | |
29 | #define NAME(x,y) CONCAT3 (aoutarm,_32_,y) | |
1725a96e | 30 | |
dc810e39 AM |
31 | #define N_TXTADDR(x) \ |
32 | ((N_MAGIC (x) == NMAGIC) \ | |
33 | ? (bfd_vma) 0x8000 \ | |
34 | : ((N_MAGIC (x) != ZMAGIC) \ | |
35 | ? (bfd_vma) 0 \ | |
36 | : ((N_SHARED_LIB (x)) \ | |
37 | ? ((x).a_entry & ~(bfd_vma) (TARGET_PAGE_SIZE - 1)) \ | |
38 | : (bfd_vma) TEXT_START_ADDR))) | |
252b5132 RH |
39 | |
40 | #define TEXT_START_ADDR 0x8000 | |
41 | #define TARGET_PAGE_SIZE 0x8000 | |
42 | #define SEGMENT_SIZE TARGET_PAGE_SIZE | |
43 | #define DEFAULT_ARCH bfd_arch_arm | |
44 | ||
6d00b590 | 45 | #define MY(OP) CONCAT2 (arm_aout_,OP) |
252b5132 RH |
46 | #define N_BADMAG(x) ((((x).a_info & ~007200) != ZMAGIC) && \ |
47 | (((x).a_info & ~006000) != OMAGIC) && \ | |
48 | ((x).a_info != NMAGIC)) | |
49 | #define N_MAGIC(x) ((x).a_info & ~07200) | |
50 | ||
6d00b590 AM |
51 | #define MY_bfd_reloc_type_lookup arm_aout_bfd_reloc_type_lookup |
52 | #define MY_bfd_reloc_name_lookup arm_aout_bfd_reloc_name_lookup | |
252b5132 | 53 | |
dc810e39 AM |
54 | #include "libaout.h" |
55 | #include "aout/aout64.h" | |
56 | ||
1725a96e | 57 | \f |
7920ce38 NC |
58 | static bfd_reloc_status_type |
59 | MY (fix_pcrel_26) (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **); | |
60 | static bfd_reloc_status_type | |
61 | MY (fix_pcrel_26_done) (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **); | |
62 | ||
63 | reloc_howto_type MY (howto_table)[] = | |
64 | { | |
65 | /* Type rs size bsz pcrel bitpos ovrf sf name part_inpl | |
66 | readmask setmask pcdone. */ | |
67 | HOWTO (0, 0, 0, 8, FALSE, 0, complain_overflow_bitfield, 0, "8", TRUE, | |
68 | 0x000000ff, 0x000000ff, FALSE), | |
69 | HOWTO (1, 0, 1, 16, FALSE, 0, complain_overflow_bitfield, 0, "16", TRUE, | |
70 | 0x0000ffff, 0x0000ffff, FALSE), | |
71 | HOWTO (2, 0, 2, 32, FALSE, 0, complain_overflow_bitfield, 0, "32", TRUE, | |
72 | 0xffffffff, 0xffffffff, FALSE), | |
73 | HOWTO (3, 2, 2, 26, TRUE, 0, complain_overflow_signed, MY (fix_pcrel_26), | |
74 | "ARM26", TRUE, 0x00ffffff, 0x00ffffff, TRUE), | |
75 | HOWTO (4, 0, 0, 8, TRUE, 0, complain_overflow_signed, 0, "DISP8", TRUE, | |
76 | 0x000000ff, 0x000000ff, TRUE), | |
77 | HOWTO (5, 0, 1, 16, TRUE, 0, complain_overflow_signed, 0, "DISP16", TRUE, | |
78 | 0x0000ffff, 0x0000ffff, TRUE), | |
79 | HOWTO (6, 0, 2, 32, TRUE, 0, complain_overflow_signed, 0, "DISP32", TRUE, | |
80 | 0xffffffff, 0xffffffff, TRUE), | |
81 | HOWTO (7, 2, 2, 26, FALSE, 0, complain_overflow_signed, | |
82 | MY (fix_pcrel_26_done), "ARM26D", TRUE, 0x0, 0x0, | |
83 | FALSE), | |
84 | EMPTY_HOWTO (-1), | |
85 | HOWTO (9, 0, -1, 16, FALSE, 0, complain_overflow_bitfield, 0, "NEG16", TRUE, | |
86 | 0x0000ffff, 0x0000ffff, FALSE), | |
87 | HOWTO (10, 0, -2, 32, FALSE, 0, complain_overflow_bitfield, 0, "NEG32", TRUE, | |
88 | 0xffffffff, 0xffffffff, FALSE) | |
89 | }; | |
252b5132 RH |
90 | |
91 | #define RELOC_ARM_BITS_NEG_BIG ((unsigned int) 0x08) | |
92 | #define RELOC_ARM_BITS_NEG_LITTLE ((unsigned int) 0x10) | |
93 | ||
7920ce38 NC |
94 | static reloc_howto_type * |
95 | MY (reloc_howto) (bfd *abfd, | |
96 | struct reloc_std_external *rel, | |
97 | int *r_index, | |
98 | int *r_extern, | |
99 | int *r_pcrel) | |
252b5132 RH |
100 | { |
101 | unsigned int r_length; | |
102 | unsigned int r_pcrel_done; | |
103 | unsigned int r_neg; | |
91d6fa6a | 104 | int howto_index; |
252b5132 RH |
105 | |
106 | *r_pcrel = 0; | |
107 | if (bfd_header_big_endian (abfd)) | |
108 | { | |
109 | *r_index = ((rel->r_index[0] << 16) | |
110 | | (rel->r_index[1] << 8) | |
111 | | rel->r_index[2]); | |
112 | *r_extern = (0 != (rel->r_type[0] & RELOC_STD_BITS_EXTERN_BIG)); | |
113 | r_pcrel_done = (0 != (rel->r_type[0] & RELOC_STD_BITS_PCREL_BIG)); | |
114 | r_neg = (0 != (rel->r_type[0] & RELOC_ARM_BITS_NEG_BIG)); | |
115 | r_length = ((rel->r_type[0] & RELOC_STD_BITS_LENGTH_BIG) | |
116 | >> RELOC_STD_BITS_LENGTH_SH_BIG); | |
117 | } | |
118 | else | |
119 | { | |
120 | *r_index = ((rel->r_index[2] << 16) | |
121 | | (rel->r_index[1] << 8) | |
122 | | rel->r_index[0]); | |
123 | *r_extern = (0 != (rel->r_type[0] & RELOC_STD_BITS_EXTERN_LITTLE)); | |
124 | r_pcrel_done = (0 != (rel->r_type[0] & RELOC_STD_BITS_PCREL_LITTLE)); | |
125 | r_neg = (0 != (rel->r_type[0] & RELOC_ARM_BITS_NEG_LITTLE)); | |
126 | r_length = ((rel->r_type[0] & RELOC_STD_BITS_LENGTH_LITTLE) | |
127 | >> RELOC_STD_BITS_LENGTH_SH_LITTLE); | |
128 | } | |
91d6fa6a NC |
129 | howto_index = r_length + 4 * r_pcrel_done + 8 * r_neg; |
130 | if (howto_index == 3) | |
252b5132 RH |
131 | *r_pcrel = 1; |
132 | ||
91d6fa6a | 133 | return MY (howto_table) + howto_index; |
252b5132 | 134 | } |
c4dfa77f | 135 | |
252b5132 | 136 | #define MY_reloc_howto(BFD, REL, IN, EX, PC) \ |
7920ce38 | 137 | MY (reloc_howto) (BFD, REL, &IN, &EX, &PC) |
252b5132 | 138 | |
7920ce38 NC |
139 | static void |
140 | MY (put_reloc) (bfd *abfd, | |
141 | int r_extern, | |
142 | int r_index, | |
143 | bfd_vma value, | |
144 | reloc_howto_type *howto, | |
145 | struct reloc_std_external *reloc) | |
252b5132 RH |
146 | { |
147 | unsigned int r_length; | |
148 | int r_pcrel; | |
149 | int r_neg; | |
150 | ||
151 | PUT_WORD (abfd, value, reloc->r_address); | |
1725a96e NC |
152 | /* Size as a power of two. */ |
153 | r_length = howto->size; | |
252b5132 | 154 | |
c4dfa77f | 155 | /* Special case for branch relocations. */ |
252b5132 RH |
156 | if (howto->type == 3 || howto->type == 7) |
157 | r_length = 3; | |
158 | ||
1725a96e NC |
159 | r_pcrel = howto->type & 4; /* PC Relative done? */ |
160 | r_neg = howto->type & 8; /* Negative relocation. */ | |
161 | ||
252b5132 RH |
162 | if (bfd_header_big_endian (abfd)) |
163 | { | |
164 | reloc->r_index[0] = r_index >> 16; | |
165 | reloc->r_index[1] = r_index >> 8; | |
166 | reloc->r_index[2] = r_index; | |
167 | reloc->r_type[0] = | |
168 | ((r_extern ? RELOC_STD_BITS_EXTERN_BIG : 0) | |
169 | | (r_pcrel ? RELOC_STD_BITS_PCREL_BIG : 0) | |
170 | | (r_neg ? RELOC_ARM_BITS_NEG_BIG : 0) | |
171 | | (r_length << RELOC_STD_BITS_LENGTH_SH_BIG)); | |
172 | } | |
173 | else | |
174 | { | |
175 | reloc->r_index[2] = r_index >> 16; | |
176 | reloc->r_index[1] = r_index >> 8; | |
177 | reloc->r_index[0] = r_index; | |
178 | reloc->r_type[0] = | |
179 | ((r_extern ? RELOC_STD_BITS_EXTERN_LITTLE : 0) | |
180 | | (r_pcrel ? RELOC_STD_BITS_PCREL_LITTLE : 0) | |
181 | | (r_neg ? RELOC_ARM_BITS_NEG_LITTLE : 0) | |
182 | | (r_length << RELOC_STD_BITS_LENGTH_SH_LITTLE)); | |
183 | } | |
184 | } | |
c4dfa77f | 185 | |
252b5132 | 186 | #define MY_put_reloc(BFD, EXT, IDX, VAL, HOWTO, RELOC) \ |
7920ce38 | 187 | MY (put_reloc) (BFD, EXT, IDX, VAL, HOWTO, RELOC) |
252b5132 | 188 | |
7920ce38 NC |
189 | static void |
190 | MY (relocatable_reloc) (reloc_howto_type *howto, | |
191 | bfd *abfd, | |
192 | struct reloc_std_external *reloc, | |
193 | bfd_vma *amount, | |
194 | bfd_vma r_addr) | |
252b5132 RH |
195 | { |
196 | if (howto->type == 3) | |
197 | { | |
c4dfa77f | 198 | if (reloc->r_type[0] |
252b5132 RH |
199 | & (bfd_header_big_endian (abfd) |
200 | ? RELOC_STD_BITS_EXTERN_BIG : RELOC_STD_BITS_EXTERN_LITTLE)) | |
7920ce38 NC |
201 | /* The reloc is still external, so don't modify anything. */ |
202 | *amount = 0; | |
252b5132 RH |
203 | else |
204 | { | |
205 | *amount -= r_addr; | |
206 | /* Change the r_pcrel value -- on the ARM, this bit is set once the | |
207 | relocation is done. */ | |
208 | if (bfd_header_big_endian (abfd)) | |
209 | reloc->r_type[0] |= RELOC_STD_BITS_PCREL_BIG; | |
210 | else | |
211 | reloc->r_type[0] |= RELOC_STD_BITS_PCREL_LITTLE; | |
212 | } | |
213 | } | |
214 | else if (howto->type == 7) | |
215 | *amount = 0; | |
216 | } | |
217 | ||
218 | #define MY_relocatable_reloc(HOW, BFD, REL, AMOUNT, ADDR) \ | |
7920ce38 | 219 | MY (relocatable_reloc) (HOW, BFD, REL, &(AMOUNT), ADDR) |
252b5132 RH |
220 | |
221 | static bfd_reloc_status_type | |
7920ce38 NC |
222 | MY (fix_pcrel_26_done) (bfd *abfd ATTRIBUTE_UNUSED, |
223 | arelent *reloc_entry ATTRIBUTE_UNUSED, | |
224 | asymbol *symbol ATTRIBUTE_UNUSED, | |
225 | void * data ATTRIBUTE_UNUSED, | |
226 | asection *input_section ATTRIBUTE_UNUSED, | |
227 | bfd *output_bfd ATTRIBUTE_UNUSED, | |
228 | char **error_message ATTRIBUTE_UNUSED) | |
252b5132 RH |
229 | { |
230 | /* This is dead simple at present. */ | |
231 | return bfd_reloc_ok; | |
232 | } | |
233 | ||
234 | static bfd_reloc_status_type | |
7920ce38 NC |
235 | MY (fix_pcrel_26) (bfd *abfd, |
236 | arelent *reloc_entry, | |
237 | asymbol *symbol, | |
238 | void * data, | |
239 | asection *input_section, | |
240 | bfd *output_bfd, | |
241 | char **error_message ATTRIBUTE_UNUSED) | |
252b5132 RH |
242 | { |
243 | bfd_vma relocation; | |
244 | bfd_size_type addr = reloc_entry->address; | |
dc810e39 | 245 | bfd_vma target = bfd_get_32 (abfd, (bfd_byte *) data + addr); |
252b5132 | 246 | bfd_reloc_status_type flag = bfd_reloc_ok; |
c4dfa77f | 247 | |
1725a96e | 248 | /* If this is an undefined symbol, return error. */ |
45dfa85a | 249 | if (bfd_is_und_section (symbol->section) |
252b5132 RH |
250 | && (symbol->flags & BSF_WEAK) == 0) |
251 | return output_bfd ? bfd_reloc_ok : bfd_reloc_undefined; | |
252 | ||
253 | /* If the sections are different, and we are doing a partial relocation, | |
254 | just ignore it for now. */ | |
255 | if (symbol->section->name != input_section->name | |
7920ce38 | 256 | && output_bfd != NULL) |
252b5132 RH |
257 | return bfd_reloc_ok; |
258 | ||
259 | relocation = (target & 0x00ffffff) << 2; | |
1725a96e | 260 | relocation = (relocation ^ 0x02000000) - 0x02000000; /* Sign extend. */ |
252b5132 RH |
261 | relocation += symbol->value; |
262 | relocation += symbol->section->output_section->vma; | |
263 | relocation += symbol->section->output_offset; | |
264 | relocation += reloc_entry->addend; | |
265 | relocation -= input_section->output_section->vma; | |
266 | relocation -= input_section->output_offset; | |
267 | relocation -= addr; | |
268 | if (relocation & 3) | |
269 | return bfd_reloc_overflow; | |
270 | ||
1725a96e | 271 | /* Check for overflow. */ |
252b5132 RH |
272 | if (relocation & 0x02000000) |
273 | { | |
274 | if ((relocation & ~ (bfd_vma) 0x03ffffff) != ~ (bfd_vma) 0x03ffffff) | |
275 | flag = bfd_reloc_overflow; | |
276 | } | |
dc810e39 | 277 | else if (relocation & ~ (bfd_vma) 0x03ffffff) |
252b5132 RH |
278 | flag = bfd_reloc_overflow; |
279 | ||
dc810e39 | 280 | target &= ~ (bfd_vma) 0x00ffffff; |
252b5132 RH |
281 | target |= (relocation >> 2) & 0x00ffffff; |
282 | bfd_put_32 (abfd, target, (bfd_byte *) data + addr); | |
283 | ||
284 | /* Now the ARM magic... Change the reloc type so that it is marked as done. | |
285 | Strictly this is only necessary if we are doing a partial relocation. */ | |
7920ce38 | 286 | reloc_entry->howto = &MY (howto_table)[7]; |
c4dfa77f | 287 | |
252b5132 RH |
288 | return flag; |
289 | } | |
290 | ||
7920ce38 NC |
291 | static reloc_howto_type * |
292 | MY (bfd_reloc_type_lookup) (bfd *abfd, | |
293 | bfd_reloc_code_real_type code) | |
252b5132 | 294 | { |
7920ce38 NC |
295 | #define ASTD(i,j) case i: return & MY (howto_table)[j] |
296 | ||
252b5132 | 297 | if (code == BFD_RELOC_CTOR) |
30d10e9e | 298 | switch (bfd_arch_bits_per_address (abfd)) |
252b5132 RH |
299 | { |
300 | case 32: | |
301 | code = BFD_RELOC_32; | |
302 | break; | |
1725a96e | 303 | default: |
7920ce38 | 304 | return NULL; |
252b5132 RH |
305 | } |
306 | ||
307 | switch (code) | |
308 | { | |
309 | ASTD (BFD_RELOC_16, 1); | |
310 | ASTD (BFD_RELOC_32, 2); | |
311 | ASTD (BFD_RELOC_ARM_PCREL_BRANCH, 3); | |
312 | ASTD (BFD_RELOC_8_PCREL, 4); | |
313 | ASTD (BFD_RELOC_16_PCREL, 5); | |
314 | ASTD (BFD_RELOC_32_PCREL, 6); | |
1725a96e | 315 | default: |
7920ce38 | 316 | return NULL; |
252b5132 RH |
317 | } |
318 | } | |
319 | ||
157090f7 AM |
320 | static reloc_howto_type * |
321 | MY (bfd_reloc_name_lookup) (bfd *abfd ATTRIBUTE_UNUSED, | |
322 | const char *r_name) | |
323 | { | |
324 | unsigned int i; | |
325 | ||
326 | for (i = 0; | |
327 | i < sizeof (MY (howto_table)) / sizeof (MY (howto_table)[0]); | |
328 | i++) | |
329 | if (MY (howto_table)[i].name != NULL | |
330 | && strcasecmp (MY (howto_table)[i].name, r_name) == 0) | |
331 | return &MY (howto_table)[i]; | |
332 | ||
333 | return NULL; | |
334 | } | |
335 | ||
7920ce38 NC |
336 | #define MY_swap_std_reloc_in MY (swap_std_reloc_in) |
337 | #define MY_swap_std_reloc_out MY (swap_std_reloc_out) | |
338 | #define MY_get_section_contents _bfd_generic_get_section_contents | |
339 | ||
340 | void MY_swap_std_reloc_in (bfd *, struct reloc_std_external *, arelent *, asymbol **, bfd_size_type); | |
341 | void MY_swap_std_reloc_out (bfd *, arelent *, struct reloc_std_external *); | |
252b5132 RH |
342 | |
343 | #include "aoutx.h" | |
344 | ||
7920ce38 NC |
345 | void |
346 | MY_swap_std_reloc_in (bfd *abfd, | |
347 | struct reloc_std_external *bytes, | |
348 | arelent *cache_ptr, | |
349 | asymbol **symbols, | |
350 | bfd_size_type symcount ATTRIBUTE_UNUSED) | |
252b5132 RH |
351 | { |
352 | int r_index; | |
353 | int r_extern; | |
354 | int r_pcrel; | |
355 | struct aoutdata *su = &(abfd->tdata.aout_data->a); | |
356 | ||
dc810e39 | 357 | cache_ptr->address = H_GET_32 (abfd, bytes->r_address); |
252b5132 RH |
358 | |
359 | cache_ptr->howto = MY_reloc_howto (abfd, bytes, r_index, r_extern, r_pcrel); | |
360 | ||
361 | MOVE_ADDRESS (0); | |
362 | } | |
363 | ||
364 | void | |
7920ce38 NC |
365 | MY_swap_std_reloc_out (bfd *abfd, |
366 | arelent *g, | |
367 | struct reloc_std_external *natptr) | |
252b5132 RH |
368 | { |
369 | int r_index; | |
370 | asymbol *sym = *(g->sym_ptr_ptr); | |
371 | int r_extern; | |
372 | int r_length; | |
373 | int r_pcrel; | |
374 | int r_neg = 0; /* Negative relocs use the BASEREL bit. */ | |
375 | asection *output_section = sym->section->output_section; | |
376 | ||
7920ce38 | 377 | PUT_WORD (abfd, g->address, natptr->r_address); |
252b5132 | 378 | |
7920ce38 | 379 | r_length = g->howto->size ; /* Size as a power of two. */ |
252b5132 RH |
380 | if (r_length < 0) |
381 | { | |
382 | r_length = -r_length; | |
383 | r_neg = 1; | |
384 | } | |
385 | ||
7920ce38 | 386 | r_pcrel = (int) g->howto->pc_relative; /* Relative to PC? */ |
252b5132 RH |
387 | |
388 | /* For RISC iX, in pc-relative relocs the r_pcrel bit means that the | |
7920ce38 | 389 | relocation has been done already (Only for the 26-bit one I think). */ |
252b5132 RH |
390 | if (g->howto->type == 3) |
391 | { | |
392 | r_length = 3; | |
393 | r_pcrel = 0; | |
394 | } | |
395 | else if (g->howto->type == 7) | |
c4dfa77f | 396 | { |
252b5132 RH |
397 | r_length = 3; |
398 | r_pcrel = 1; | |
399 | } | |
252b5132 | 400 | |
7920ce38 | 401 | /* Name was clobbered by aout_write_syms to be symbol index. */ |
252b5132 RH |
402 | |
403 | /* If this relocation is relative to a symbol then set the | |
404 | r_index to the symbols index, and the r_extern bit. | |
405 | ||
406 | Absolute symbols can come in in two ways, either as an offset | |
407 | from the abs section, or as a symbol which has an abs value. | |
7920ce38 | 408 | check for that here. */ |
252b5132 RH |
409 | |
410 | if (bfd_is_com_section (output_section) | |
45dfa85a AM |
411 | || bfd_is_abs_section (output_section) |
412 | || bfd_is_und_section (output_section)) | |
252b5132 | 413 | { |
45dfa85a | 414 | if (bfd_abs_section_ptr->symbol == sym) |
252b5132 RH |
415 | { |
416 | /* Whoops, looked like an abs symbol, but is really an offset | |
1725a96e | 417 | from the abs section. */ |
252b5132 RH |
418 | r_index = 0; |
419 | r_extern = 0; | |
420 | } | |
421 | else | |
422 | { | |
1725a96e | 423 | /* Fill in symbol. */ |
252b5132 RH |
424 | r_extern = 1; |
425 | r_index = (*(g->sym_ptr_ptr))->KEEPIT; | |
426 | } | |
427 | } | |
428 | else | |
429 | { | |
1725a96e | 430 | /* Just an ordinary section. */ |
252b5132 RH |
431 | r_extern = 0; |
432 | r_index = output_section->target_index; | |
433 | } | |
434 | ||
1725a96e | 435 | /* Now the fun stuff. */ |
252b5132 RH |
436 | if (bfd_header_big_endian (abfd)) |
437 | { | |
438 | natptr->r_index[0] = r_index >> 16; | |
439 | natptr->r_index[1] = r_index >> 8; | |
440 | natptr->r_index[2] = r_index; | |
441 | natptr->r_type[0] = | |
442 | ( (r_extern ? RELOC_STD_BITS_EXTERN_BIG: 0) | |
443 | | (r_pcrel ? RELOC_STD_BITS_PCREL_BIG: 0) | |
444 | | (r_neg ? RELOC_ARM_BITS_NEG_BIG: 0) | |
445 | | (r_length << RELOC_STD_BITS_LENGTH_SH_BIG)); | |
446 | } | |
447 | else | |
448 | { | |
449 | natptr->r_index[2] = r_index >> 16; | |
450 | natptr->r_index[1] = r_index >> 8; | |
451 | natptr->r_index[0] = r_index; | |
452 | natptr->r_type[0] = | |
453 | ( (r_extern ? RELOC_STD_BITS_EXTERN_LITTLE: 0) | |
454 | | (r_pcrel ? RELOC_STD_BITS_PCREL_LITTLE: 0) | |
455 | | (r_neg ? RELOC_ARM_BITS_NEG_LITTLE: 0) | |
456 | | (r_length << RELOC_STD_BITS_LENGTH_SH_LITTLE)); | |
457 | } | |
458 | } | |
459 | ||
460 | #define MY_BFD_TARGET | |
461 | ||
462 | #include "aout-target.h" | |
463 | ||
6d00b590 | 464 | extern const bfd_target arm_aout_be_vec; |
c3c89269 | 465 | |
6d00b590 | 466 | const bfd_target arm_aout_le_vec = |
7920ce38 NC |
467 | { |
468 | "a.out-arm-little", /* Name. */ | |
469 | bfd_target_aout_flavour, | |
470 | BFD_ENDIAN_LITTLE, /* Target byte order (little). */ | |
471 | BFD_ENDIAN_LITTLE, /* Target headers byte order (little). */ | |
472 | (HAS_RELOC | EXEC_P | /* Object flags. */ | |
473 | HAS_LINENO | HAS_DEBUG | | |
474 | HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT | D_PAGED), | |
475 | (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC | SEC_CODE | SEC_DATA), | |
476 | MY_symbol_leading_char, | |
477 | AR_PAD_CHAR, /* AR_pad_char. */ | |
478 | 15, /* AR_max_namelen. */ | |
0aabe54e | 479 | 0, /* match priority. */ |
7920ce38 NC |
480 | bfd_getl64, bfd_getl_signed_64, bfd_putl64, |
481 | bfd_getl32, bfd_getl_signed_32, bfd_putl32, | |
482 | bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* Data. */ | |
483 | bfd_getl64, bfd_getl_signed_64, bfd_putl64, | |
484 | bfd_getl32, bfd_getl_signed_32, bfd_putl32, | |
485 | bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* Headers. */ | |
486 | {_bfd_dummy_target, MY_object_p, /* bfd_check_format. */ | |
487 | bfd_generic_archive_p, MY_core_file_p}, | |
488 | {bfd_false, MY_mkobject, /* bfd_set_format. */ | |
489 | _bfd_generic_mkarchive, bfd_false}, | |
490 | {bfd_false, MY_write_object_contents, /* bfd_write_contents. */ | |
491 | _bfd_write_archive_contents, bfd_false}, | |
492 | ||
493 | BFD_JUMP_TABLE_GENERIC (MY), | |
494 | BFD_JUMP_TABLE_COPY (MY), | |
495 | BFD_JUMP_TABLE_CORE (MY), | |
496 | BFD_JUMP_TABLE_ARCHIVE (MY), | |
497 | BFD_JUMP_TABLE_SYMBOLS (MY), | |
498 | BFD_JUMP_TABLE_RELOCS (MY), | |
499 | BFD_JUMP_TABLE_WRITE (MY), | |
500 | BFD_JUMP_TABLE_LINK (MY), | |
501 | BFD_JUMP_TABLE_DYNAMIC (MY), | |
502 | ||
6d00b590 | 503 | & arm_aout_be_vec, |
7920ce38 NC |
504 | |
505 | (void *) MY_backend_data, | |
506 | }; | |
252b5132 | 507 | |
6d00b590 | 508 | const bfd_target arm_aout_be_vec = |
7920ce38 NC |
509 | { |
510 | "a.out-arm-big", /* Name. */ | |
511 | bfd_target_aout_flavour, | |
512 | BFD_ENDIAN_BIG, /* Target byte order (big). */ | |
513 | BFD_ENDIAN_BIG, /* Target headers byte order (big). */ | |
514 | (HAS_RELOC | EXEC_P | /* Object flags. */ | |
515 | HAS_LINENO | HAS_DEBUG | | |
516 | HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT | D_PAGED), | |
517 | (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC | SEC_CODE | SEC_DATA), | |
518 | MY_symbol_leading_char, | |
0aabe54e AM |
519 | AR_PAD_CHAR, /* AR_pad_char. */ |
520 | 15, /* AR_max_namelen. */ | |
521 | 0, /* match priority. */ | |
7920ce38 NC |
522 | bfd_getb64, bfd_getb_signed_64, bfd_putb64, |
523 | bfd_getb32, bfd_getb_signed_32, bfd_putb32, | |
524 | bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* Data. */ | |
525 | bfd_getb64, bfd_getb_signed_64, bfd_putb64, | |
526 | bfd_getb32, bfd_getb_signed_32, bfd_putb32, | |
527 | bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* Headers. */ | |
528 | {_bfd_dummy_target, MY_object_p, /* bfd_check_format. */ | |
529 | bfd_generic_archive_p, MY_core_file_p}, | |
530 | {bfd_false, MY_mkobject, /* bfd_set_format. */ | |
531 | _bfd_generic_mkarchive, bfd_false}, | |
532 | {bfd_false, MY_write_object_contents, /* bfd_write_contents. */ | |
533 | _bfd_write_archive_contents, bfd_false}, | |
534 | ||
535 | BFD_JUMP_TABLE_GENERIC (MY), | |
536 | BFD_JUMP_TABLE_COPY (MY), | |
537 | BFD_JUMP_TABLE_CORE (MY), | |
538 | BFD_JUMP_TABLE_ARCHIVE (MY), | |
539 | BFD_JUMP_TABLE_SYMBOLS (MY), | |
540 | BFD_JUMP_TABLE_RELOCS (MY), | |
541 | BFD_JUMP_TABLE_WRITE (MY), | |
542 | BFD_JUMP_TABLE_LINK (MY), | |
543 | BFD_JUMP_TABLE_DYNAMIC (MY), | |
544 | ||
6d00b590 | 545 | & arm_aout_le_vec, |
7920ce38 NC |
546 | |
547 | (void *) MY_backend_data, | |
548 | }; |