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