00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #define TARGET_IS_BIG_ENDIAN_P
00028 #define N_HEADER_IN_TEXT(x) 1
00029 #define TEXT_START_ADDR 1024
00030 #define TARGET_PAGE_SIZE 128
00031 #define SEGMENT_SIZE TARGET_PAGE_SIZE
00032 #define DEFAULT_ARCH bfd_arch_tic30
00033 #define ARCH_SIZE 32
00034
00035
00036
00037
00038 #define MY(OP) CONCAT2 (tic30_aout_,OP)
00039 #define TARGETNAME "a.out-tic30"
00040 #define NAME(x,y) CONCAT3 (tic30_aout,_32_,y)
00041
00042 #include "bfd.h"
00043 #include "sysdep.h"
00044 #include "libaout.h"
00045
00046 #include "aout/aout64.h"
00047 #include "aout/stab_gnu.h"
00048 #include "aout/ar.h"
00049
00050 static bfd_reloc_status_type tic30_aout_fix_16
00051 PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
00052 static bfd_reloc_status_type tic30_aout_fix_32
00053 PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
00054 static bfd_reloc_status_type tic30_aout_fix_pcrel_16
00055 PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
00056 static reloc_howto_type *tic30_aout_reloc_howto
00057 PARAMS ((bfd *, struct reloc_std_external *, int *, int *, int *));
00058 static bfd_reloc_status_type tic30_aout_relocate_contents
00059 PARAMS ((reloc_howto_type *, bfd *, bfd_vma, bfd_byte *));
00060 static bfd_reloc_status_type tic30_aout_final_link_relocate
00061 PARAMS ((reloc_howto_type *, bfd *, asection *, bfd_byte *, bfd_vma,
00062 bfd_vma, bfd_vma));
00063 static const bfd_target *tic30_aout_object_p
00064 PARAMS ((bfd *));
00065 static bfd_boolean tic30_aout_write_object_contents
00066 PARAMS ((bfd *));
00067 static bfd_boolean tic30_aout_set_sizes
00068 PARAMS ((bfd *));
00069 static const bfd_target * tic30_aout_callback
00070 PARAMS ((bfd *));
00071 static bfd_boolean MY_bfd_copy_private_section_data
00072 PARAMS ((bfd *, asection *, bfd *, asection *));
00073 static bfd_boolean MY_bfd_final_link
00074 PARAMS ((bfd *, struct bfd_link_info *));
00075 reloc_howto_type * tic30_aout_reloc_type_lookup
00076 PARAMS ((bfd *, bfd_reloc_code_real_type));
00077 enum machine_type tic30_aout_machine_type
00078 PARAMS ((enum bfd_architecture, unsigned long, bfd_boolean *));
00079 bfd_boolean tic30_aout_set_arch_mach
00080 PARAMS ((bfd *, enum bfd_architecture, unsigned long));
00081
00082 #define MY_reloc_howto(BFD, REL, IN, EX, PC) \
00083 tic30_aout_reloc_howto(BFD, REL, &IN, &EX, &PC)
00084 #define MY_final_link_relocate tic30_aout_final_link_relocate
00085 #define MY_object_p tic30_aout_object_p
00086 #define MY_mkobject NAME(aout,mkobject)
00087 #define MY_write_object_contents tic30_aout_write_object_contents
00088 #define MY_set_sizes tic30_aout_set_sizes
00089
00090 #ifndef MY_exec_hdr_flags
00091 #define MY_exec_hdr_flags 1
00092 #endif
00093
00094 #ifndef MY_backend_data
00095
00096 #ifndef MY_zmagic_contiguous
00097 #define MY_zmagic_contiguous 0
00098 #endif
00099 #ifndef MY_text_includes_header
00100 #define MY_text_includes_header 0
00101 #endif
00102 #ifndef MY_entry_is_text_address
00103 #define MY_entry_is_text_address 0
00104 #endif
00105 #ifndef MY_exec_header_not_counted
00106 #define MY_exec_header_not_counted 1
00107 #endif
00108 #ifndef MY_add_dynamic_symbols
00109 #define MY_add_dynamic_symbols 0
00110 #endif
00111 #ifndef MY_add_one_symbol
00112 #define MY_add_one_symbol 0
00113 #endif
00114 #ifndef MY_link_dynamic_object
00115 #define MY_link_dynamic_object 0
00116 #endif
00117 #ifndef MY_write_dynamic_symbol
00118 #define MY_write_dynamic_symbol 0
00119 #endif
00120 #ifndef MY_check_dynamic_reloc
00121 #define MY_check_dynamic_reloc 0
00122 #endif
00123 #ifndef MY_finish_dynamic_link
00124 #define MY_finish_dynamic_link 0
00125 #endif
00126
00127 static const struct aout_backend_data tic30_aout_backend_data =
00128 {
00129 MY_zmagic_contiguous,
00130 MY_text_includes_header,
00131 MY_entry_is_text_address,
00132 MY_exec_hdr_flags,
00133 0,
00134 MY_set_sizes,
00135 MY_exec_header_not_counted,
00136 MY_add_dynamic_symbols,
00137 MY_add_one_symbol,
00138 MY_link_dynamic_object,
00139 MY_write_dynamic_symbol,
00140 MY_check_dynamic_reloc,
00141 MY_finish_dynamic_link
00142 };
00143 #define MY_backend_data &tic30_aout_backend_data
00144 #endif
00145
00146
00147
00148
00149 #include "aoutx.h"
00150
00151
00152
00153
00154
00155 reloc_howto_type tic30_aout_howto_table[] =
00156 {
00157 EMPTY_HOWTO (-1),
00158 HOWTO (1, 2, 1, 16, FALSE, 0, 0, tic30_aout_fix_16,
00159 "16", FALSE, 0x0000FFFF, 0x0000FFFF, FALSE),
00160 HOWTO (2, 2, 2, 24, FALSE, 0, complain_overflow_bitfield, NULL,
00161 "24", FALSE, 0x00FFFFFF, 0x00FFFFFF, FALSE),
00162 HOWTO (3, 18, 3, 24, FALSE, 0, complain_overflow_bitfield, NULL,
00163 "LDP", FALSE, 0x00FF0000, 0x000000FF, FALSE),
00164 HOWTO (4, 2, 4, 32, FALSE, 0, complain_overflow_bitfield, tic30_aout_fix_32,
00165 "32", FALSE, 0xFFFFFFFF, 0xFFFFFFFF, FALSE),
00166 HOWTO (5, 2, 1, 16, TRUE, 0, complain_overflow_signed,
00167 tic30_aout_fix_pcrel_16, "PCREL", TRUE, 0x0000FFFF, 0x0000FFFF, TRUE),
00168 EMPTY_HOWTO (-1),
00169 EMPTY_HOWTO (-1),
00170 EMPTY_HOWTO (-1),
00171 EMPTY_HOWTO (-1),
00172 EMPTY_HOWTO (-1)
00173 };
00174
00175 extern reloc_howto_type *NAME (aout, reloc_type_lookup)
00176 PARAMS ((bfd *, bfd_reloc_code_real_type));
00177
00178 reloc_howto_type *
00179 tic30_aout_reloc_type_lookup (abfd, code)
00180 bfd *abfd ATTRIBUTE_UNUSED;
00181 bfd_reloc_code_real_type code;
00182 {
00183 switch (code)
00184 {
00185 case BFD_RELOC_8:
00186 case BFD_RELOC_TIC30_LDP:
00187 return &tic30_aout_howto_table[3];
00188 case BFD_RELOC_16:
00189 return &tic30_aout_howto_table[1];
00190 case BFD_RELOC_24:
00191 return &tic30_aout_howto_table[2];
00192 case BFD_RELOC_16_PCREL:
00193 return &tic30_aout_howto_table[5];
00194 case BFD_RELOC_32:
00195 return &tic30_aout_howto_table[4];
00196 default:
00197 return (reloc_howto_type *) NULL;
00198 }
00199 }
00200
00201 static reloc_howto_type *
00202 tic30_aout_reloc_howto (abfd, relocs, r_index, r_extern, r_pcrel)
00203 bfd *abfd;
00204 struct reloc_std_external *relocs;
00205 int *r_index;
00206 int *r_extern;
00207 int *r_pcrel;
00208 {
00209 unsigned int r_length;
00210 unsigned int r_pcrel_done;
00211 int index;
00212
00213 *r_pcrel = 0;
00214 if (bfd_header_big_endian (abfd))
00215 {
00216 *r_index = ((relocs->r_index[0] << 16) | (relocs->r_index[1] << 8) | relocs->r_index[2]);
00217 *r_extern = (0 != (relocs->r_type[0] & RELOC_STD_BITS_EXTERN_BIG));
00218 r_pcrel_done = (0 != (relocs->r_type[0] & RELOC_STD_BITS_PCREL_BIG));
00219 r_length = ((relocs->r_type[0] & RELOC_STD_BITS_LENGTH_BIG) >> RELOC_STD_BITS_LENGTH_SH_BIG);
00220 }
00221 else
00222 {
00223 *r_index = ((relocs->r_index[2] << 16) | (relocs->r_index[1] << 8) | relocs->r_index[0]);
00224 *r_extern = (0 != (relocs->r_type[0] & RELOC_STD_BITS_EXTERN_LITTLE));
00225 r_pcrel_done = (0 != (relocs->r_type[0] & RELOC_STD_BITS_PCREL_LITTLE));
00226 r_length = ((relocs->r_type[0] & RELOC_STD_BITS_LENGTH_LITTLE) >> RELOC_STD_BITS_LENGTH_SH_LITTLE);
00227 }
00228 index = r_length + 4 * r_pcrel_done;
00229 return tic30_aout_howto_table + index;
00230 }
00231
00232
00233
00234
00235
00236
00237
00238
00239 static bfd_reloc_status_type
00240 tic30_aout_fix_16 (abfd, reloc_entry, symbol, data, input_section, output_bfd, error_message)
00241 bfd *abfd;
00242 arelent *reloc_entry;
00243 asymbol *symbol;
00244 PTR data;
00245 asection *input_section ATTRIBUTE_UNUSED;
00246 bfd *output_bfd;
00247 char **error_message ATTRIBUTE_UNUSED;
00248 {
00249 bfd_vma relocation;
00250
00251
00252 if (symbol->section == &bfd_und_section && (symbol->flags & BSF_WEAK) == 0)
00253 return output_bfd ? bfd_reloc_ok : bfd_reloc_undefined;
00254
00255
00256 relocation = (symbol->section->vma >> 2);
00257 relocation += bfd_get_16 (abfd, (bfd_byte *) data + reloc_entry->address);
00258 bfd_put_16 (abfd, relocation, (bfd_byte *) data + reloc_entry->address);
00259 return bfd_reloc_ok;
00260 }
00261
00262
00263
00264
00265 static bfd_reloc_status_type
00266 tic30_aout_fix_32 (abfd, reloc_entry, symbol, data, input_section,
00267 output_bfd, error_message)
00268 bfd *abfd;
00269 arelent *reloc_entry;
00270 asymbol *symbol;
00271 PTR data;
00272 asection *input_section ATTRIBUTE_UNUSED;
00273 bfd *output_bfd;
00274 char **error_message ATTRIBUTE_UNUSED;
00275 {
00276 bfd_vma relocation;
00277
00278
00279 if (symbol->section == &bfd_und_section && (symbol->flags & BSF_WEAK) == 0)
00280 return output_bfd ? bfd_reloc_ok : bfd_reloc_undefined;
00281
00282
00283 relocation = (symbol->section->vma >> 2);
00284 relocation += bfd_get_32 (abfd, (bfd_byte *) data + reloc_entry->address);
00285 bfd_put_32 (abfd, relocation, (bfd_byte *) data + reloc_entry->address);
00286 return bfd_reloc_ok;
00287 }
00288
00289
00290
00291
00292
00293
00294
00295
00296 static bfd_reloc_status_type
00297 tic30_aout_fix_pcrel_16 (abfd, reloc_entry, symbol, data, input_section,
00298 output_bfd, error_message)
00299 bfd *abfd;
00300 arelent *reloc_entry;
00301 asymbol *symbol ATTRIBUTE_UNUSED;
00302 PTR data;
00303 asection *input_section ATTRIBUTE_UNUSED;
00304 bfd *output_bfd ATTRIBUTE_UNUSED;
00305 char **error_message ATTRIBUTE_UNUSED;
00306 {
00307 bfd_vma relocation = 1;
00308 bfd_byte offset_data = bfd_get_8 (abfd, (bfd_byte *) data + reloc_entry->address - 1);
00309
00310
00311
00312
00313 if (offset_data & 0x20)
00314 relocation -= 3;
00315 else
00316 relocation -= 1;
00317 bfd_put_16 (abfd, relocation, (bfd_byte *) data + reloc_entry->address);
00318 return bfd_reloc_ok;
00319 }
00320
00321
00322
00323 #define bfd_getb_24(BFD,ADDR) \
00324 (bfd_get_8 (BFD, ADDR ) << 16) | \
00325 (bfd_get_8 (BFD, ADDR + 1) << 8) | \
00326 (bfd_get_8 (BFD, ADDR + 2) )
00327
00328 #define bfd_putb_24(BFD,DATA,ADDR) \
00329 bfd_put_8 (BFD, (bfd_byte) ((DATA >> 16) & 0xFF), ADDR ); \
00330 bfd_put_8 (BFD, (bfd_byte) ((DATA >> 8) & 0xFF), ADDR + 1); \
00331 bfd_put_8 (BFD, (bfd_byte) ( DATA & 0xFF), ADDR + 2)
00332
00333
00334
00335
00336 static const bfd_target *
00337 tic30_aout_callback (abfd)
00338 bfd *abfd;
00339 {
00340 struct internal_exec *execp = exec_hdr (abfd);
00341 unsigned int arch_align_power;
00342 unsigned long arch_align;
00343
00344
00345 obj_textsec (abfd)->size = N_TXTSIZE (*execp);
00346
00347
00348 obj_textsec (abfd)->vma = N_TXTADDR (*execp);
00349 obj_datasec (abfd)->vma = N_DATADDR (*execp);
00350 obj_bsssec (abfd)->vma = N_BSSADDR (*execp);
00351
00352 obj_textsec (abfd)->lma = obj_textsec (abfd)->vma;
00353 obj_datasec (abfd)->lma = obj_datasec (abfd)->vma;
00354 obj_bsssec (abfd)->lma = obj_bsssec (abfd)->vma;
00355
00356
00357 obj_textsec (abfd)->filepos = N_TXTOFF (*execp);
00358 obj_datasec (abfd)->filepos = N_DATOFF (*execp);
00359
00360
00361 obj_textsec (abfd)->rel_filepos = N_TRELOFF (*execp);
00362 obj_datasec (abfd)->rel_filepos = N_DRELOFF (*execp);
00363
00364
00365 obj_sym_filepos (abfd) = N_SYMOFF (*execp);
00366 obj_str_filepos (abfd) = N_STROFF (*execp);
00367
00368
00369 #ifdef SET_ARCH_MACH
00370 SET_ARCH_MACH (abfd, *execp);
00371 #else
00372 bfd_default_set_arch_mach (abfd, DEFAULT_ARCH, 0L);
00373 #endif
00374
00375
00376
00377
00378
00379
00380
00381 arch_align_power = bfd_get_arch_info (abfd)->section_align_power;
00382 arch_align = 1 << arch_align_power;
00383 if ((BFD_ALIGN (obj_textsec (abfd)->size, arch_align)
00384 == obj_textsec (abfd)->size)
00385 && (BFD_ALIGN (obj_datasec (abfd)->size, arch_align)
00386 == obj_datasec (abfd)->size)
00387 && (BFD_ALIGN (obj_bsssec (abfd)->size, arch_align)
00388 == obj_bsssec (abfd)->size))
00389 {
00390 obj_textsec (abfd)->alignment_power = arch_align_power;
00391 obj_datasec (abfd)->alignment_power = arch_align_power;
00392 obj_bsssec (abfd)->alignment_power = arch_align_power;
00393 }
00394 return abfd->xvec;
00395 }
00396
00397 static bfd_reloc_status_type
00398 tic30_aout_final_link_relocate (howto, input_bfd, input_section, contents,
00399 address, value, addend)
00400 reloc_howto_type *howto;
00401 bfd *input_bfd;
00402 asection *input_section;
00403 bfd_byte *contents;
00404 bfd_vma address;
00405 bfd_vma value;
00406 bfd_vma addend;
00407 {
00408 bfd_vma relocation;
00409
00410 if (address > bfd_get_section_limit (input_bfd, input_section))
00411 return bfd_reloc_outofrange;
00412
00413 relocation = value + addend;
00414 if (howto->pc_relative)
00415 {
00416 relocation -= (input_section->output_section->vma + input_section->output_offset);
00417 if (howto->pcrel_offset)
00418 relocation -= address;
00419 }
00420 return tic30_aout_relocate_contents (howto, input_bfd, relocation,
00421 contents + address);
00422 }
00423
00424 bfd_reloc_status_type
00425 tic30_aout_relocate_contents (howto, input_bfd, relocation, location)
00426 reloc_howto_type *howto;
00427 bfd *input_bfd;
00428 bfd_vma relocation;
00429 bfd_byte *location;
00430 {
00431 bfd_vma x;
00432 bfd_boolean overflow;
00433
00434 if (howto->size < 0)
00435 relocation = -relocation;
00436
00437 switch (howto->size)
00438 {
00439 default:
00440 case 0:
00441 abort ();
00442 break;
00443 case 1:
00444 x = bfd_get_16 (input_bfd, location);
00445 break;
00446 case 2:
00447 x = bfd_getb_24 (input_bfd, location);
00448 break;
00449 case 3:
00450 x = bfd_get_8 (input_bfd, location);
00451 break;
00452 case 4:
00453 x = bfd_get_32 (input_bfd, location);
00454 break;
00455 }
00456
00457 overflow = FALSE;
00458
00459 if (howto->complain_on_overflow != complain_overflow_dont)
00460 {
00461 bfd_vma check;
00462 bfd_signed_vma signed_check;
00463 bfd_vma add;
00464 bfd_signed_vma signed_add;
00465
00466 if (howto->rightshift == 0)
00467 {
00468 check = relocation;
00469 signed_check = (bfd_signed_vma) relocation;
00470 }
00471 else
00472 {
00473 check = relocation >> howto->rightshift;
00474 if ((bfd_signed_vma) relocation >= 0)
00475 signed_check = check;
00476 else
00477 signed_check = (check | ((bfd_vma) - 1 & ~((bfd_vma) - 1 >> howto->rightshift)));
00478 }
00479 add = x & howto->src_mask;
00480 signed_add = add;
00481 if ((add & (((~howto->src_mask) >> 1) & howto->src_mask)) != 0)
00482 signed_add -= (((~howto->src_mask) >> 1) & howto->src_mask) << 1;
00483 if (howto->bitpos == 0)
00484 {
00485 check += add;
00486 signed_check += signed_add;
00487 }
00488 else
00489 {
00490 check += add >> howto->bitpos;
00491 if (signed_add >= 0)
00492 signed_check += add >> howto->bitpos;
00493 else
00494 signed_check += ((add >> howto->bitpos) | ((bfd_vma) - 1 & ~((bfd_vma) - 1 >> howto->bitpos)));
00495 }
00496 switch (howto->complain_on_overflow)
00497 {
00498 case complain_overflow_signed:
00499 {
00500 bfd_signed_vma reloc_signed_max = (1 << (howto->bitsize - 1)) - 1;
00501 bfd_signed_vma reloc_signed_min = ~reloc_signed_max;
00502 if (signed_check > reloc_signed_max || signed_check < reloc_signed_min)
00503 overflow = TRUE;
00504 }
00505 break;
00506 case complain_overflow_unsigned:
00507 {
00508 bfd_vma reloc_unsigned_max = (((1 << (howto->bitsize - 1)) - 1) << 1) | 1;
00509 if (check > reloc_unsigned_max)
00510 overflow = TRUE;
00511 }
00512 break;
00513 case complain_overflow_bitfield:
00514 {
00515 bfd_vma reloc_bits = (((1 << (howto->bitsize - 1)) - 1) << 1) | 1;
00516 if ((check & ~reloc_bits) != 0
00517 && (((bfd_vma) signed_check & ~reloc_bits)
00518 != ((bfd_vma) -1 & ~reloc_bits)))
00519 overflow = TRUE;
00520 }
00521 break;
00522 default:
00523 abort ();
00524 }
00525 }
00526 relocation >>= (bfd_vma) howto->rightshift;
00527 relocation <<= (bfd_vma) howto->bitpos;
00528 x = ((x & ~howto->dst_mask) | (((x & howto->src_mask) + relocation) & howto->dst_mask));
00529 switch (howto->size)
00530 {
00531 default:
00532 case 0:
00533 abort ();
00534 break;
00535 case 1:
00536 bfd_put_16 (input_bfd, x, location);
00537 break;
00538 case 2:
00539 bfd_putb_24 (input_bfd, x, location);
00540 break;
00541 case 3:
00542 bfd_put_8 (input_bfd, x, location);
00543 break;
00544 case 4:
00545 bfd_put_32 (input_bfd, x, location);
00546 break;
00547 }
00548 return overflow ? bfd_reloc_overflow : bfd_reloc_ok;
00549 }
00550
00551
00552
00553 static const bfd_target *
00554 tic30_aout_object_p (abfd)
00555 bfd *abfd;
00556 {
00557 struct external_exec exec_bytes;
00558 struct internal_exec exec;
00559 const bfd_target *target;
00560 bfd_size_type amt = EXEC_BYTES_SIZE;
00561
00562 if (bfd_bread ((PTR) &exec_bytes, amt, abfd) != amt)
00563 {
00564 if (bfd_get_error () != bfd_error_system_call)
00565 bfd_set_error (bfd_error_wrong_format);
00566 return 0;
00567 }
00568
00569 #ifdef SWAP_MAGIC
00570 exec.a_info = SWAP_MAGIC (exec_bytes.e_info);
00571 #else
00572 exec.a_info = H_GET_32 (abfd, exec_bytes.e_info);
00573 #endif
00574
00575 if (N_BADMAG (exec))
00576 return 0;
00577 #ifdef MACHTYPE_OK
00578 if (!(MACHTYPE_OK (N_MACHTYPE (exec))))
00579 return 0;
00580 #endif
00581
00582 NAME (aout, swap_exec_header_in) (abfd, &exec_bytes, &exec);
00583
00584 #ifdef SWAP_MAGIC
00585
00586 exec.a_info = SWAP_MAGIC (exec_bytes.e_info);
00587 #endif
00588
00589 target = NAME (aout, some_aout_object_p) (abfd, &exec, tic30_aout_callback);
00590
00591 #ifdef ENTRY_CAN_BE_ZERO
00592
00593
00594
00595
00596
00597
00598 if (exec.a_trsize + exec.a_drsize == 0
00599 && bfd_get_format (abfd) == bfd_object && abfd->my_archive == NULL)
00600 {
00601 struct stat buf;
00602 #ifndef S_IXUSR
00603 #define S_IXUSR 0100
00604 #endif
00605 if (stat (abfd->filename, &buf) == 0 && (buf.st_mode & S_IXUSR))
00606 abfd->flags |= EXEC_P;
00607 }
00608 #endif
00609
00610 return target;
00611 }
00612
00613
00614
00615
00616
00617
00618
00619 static bfd_boolean
00620 MY_bfd_copy_private_section_data (ibfd, isec, obfd, osec)
00621 bfd *ibfd;
00622 asection *isec ATTRIBUTE_UNUSED;
00623 bfd *obfd;
00624 asection *osec ATTRIBUTE_UNUSED;
00625 {
00626 if (bfd_get_flavour (obfd) == bfd_target_aout_flavour)
00627 obj_aout_subformat (obfd) = obj_aout_subformat (ibfd);
00628 return TRUE;
00629 }
00630
00631
00632
00633
00634
00635 static bfd_boolean
00636 tic30_aout_write_object_contents (abfd)
00637 bfd *abfd;
00638 {
00639 struct external_exec exec_bytes;
00640 struct internal_exec *execp = exec_hdr (abfd);
00641
00642 obj_reloc_entry_size (abfd) = RELOC_STD_SIZE;
00643
00644 {
00645 bfd_size_type text_size;
00646 file_ptr text_end;
00647
00648 if (adata (abfd).magic == undecided_magic)
00649 NAME (aout, adjust_sizes_and_vmas) (abfd, &text_size, &text_end);
00650
00651 execp->a_syms = bfd_get_symcount (abfd) * EXTERNAL_NLIST_SIZE;
00652 execp->a_entry = bfd_get_start_address (abfd);
00653
00654 execp->a_trsize = ((obj_textsec (abfd)->reloc_count) * obj_reloc_entry_size (abfd));
00655 execp->a_drsize = ((obj_datasec (abfd)->reloc_count) * obj_reloc_entry_size (abfd));
00656 NAME (aout, swap_exec_header_out) (abfd, execp, &exec_bytes);
00657
00658 if (adata (abfd).exec_bytes_size > 0)
00659 {
00660 bfd_size_type amt;
00661 if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0)
00662 return FALSE;
00663 amt = adata (abfd).exec_bytes_size;
00664 if (bfd_bwrite ((PTR) &exec_bytes, amt, abfd) != amt)
00665 return FALSE;
00666 }
00667
00668
00669 if (bfd_get_outsymbols (abfd) != (asymbol **) NULL
00670 && bfd_get_symcount (abfd) != 0)
00671 {
00672 if (bfd_seek (abfd, (file_ptr) (N_SYMOFF (*execp)), SEEK_SET) != 0)
00673 return FALSE;
00674
00675 if (!NAME (aout, write_syms) (abfd))
00676 return FALSE;
00677 }
00678
00679 if (bfd_seek (abfd, (file_ptr) (N_TRELOFF (*execp)), SEEK_SET) != 0)
00680 return FALSE;
00681 if (!NAME (aout, squirt_out_relocs) (abfd, obj_textsec (abfd)))
00682 return FALSE;
00683
00684 if (bfd_seek (abfd, (file_ptr) (N_DRELOFF (*execp)), SEEK_SET) != 0)
00685 return FALSE;
00686 if (!NAME (aout, squirt_out_relocs) (abfd, obj_datasec (abfd)))
00687 return FALSE;
00688 }
00689
00690 return TRUE;
00691 }
00692
00693 static bfd_boolean
00694 tic30_aout_set_sizes (abfd)
00695 bfd *abfd;
00696 {
00697 adata (abfd).page_size = TARGET_PAGE_SIZE;
00698
00699 #ifdef SEGMENT_SIZE
00700 adata (abfd).segment_size = SEGMENT_SIZE;
00701 #else
00702 adata (abfd).segment_size = TARGET_PAGE_SIZE;
00703 #endif
00704
00705 #ifdef ZMAGIC_DISK_BLOCK_SIZE
00706 adata (abfd).zmagic_disk_block_size = ZMAGIC_DISK_BLOCK_SIZE;
00707 #else
00708 adata (abfd).zmagic_disk_block_size = TARGET_PAGE_SIZE;
00709 #endif
00710
00711 adata (abfd).exec_bytes_size = EXEC_BYTES_SIZE;
00712
00713 return TRUE;
00714 }
00715
00716 #ifndef MY_final_link_callback
00717
00718
00719
00720 static void MY_final_link_callback
00721 PARAMS ((bfd *, file_ptr *, file_ptr *, file_ptr *));
00722
00723 static void
00724 MY_final_link_callback (abfd, ptreloff, pdreloff, psymoff)
00725 bfd *abfd;
00726 file_ptr *ptreloff;
00727 file_ptr *pdreloff;
00728 file_ptr *psymoff;
00729 {
00730 struct internal_exec *execp = exec_hdr (abfd);
00731
00732 *ptreloff = obj_datasec (abfd)->filepos + execp->a_data;
00733 *pdreloff = *ptreloff + execp->a_trsize;
00734 *psymoff = *pdreloff + execp->a_drsize;;
00735 }
00736
00737 #endif
00738
00739 #ifndef MY_bfd_final_link
00740
00741
00742
00743
00744 static bfd_boolean
00745 MY_bfd_final_link (abfd, info)
00746 bfd *abfd;
00747 struct bfd_link_info *info;
00748 {
00749 struct internal_exec *execp = exec_hdr (abfd);
00750 file_ptr pos;
00751 bfd_vma vma = 0;
00752 int pad;
00753
00754
00755
00756 adata (abfd).exec_bytes_size = 0;
00757 pos = adata (abfd).exec_bytes_size;
00758
00759 vma = info->create_object_symbols_section->vma;
00760 pos += vma;
00761 obj_textsec (abfd)->filepos = pos;
00762 obj_textsec (abfd)->vma = vma;
00763 obj_textsec (abfd)->user_set_vma = 1;
00764 pos += obj_textsec (abfd)->size;
00765 vma += obj_textsec (abfd)->size;
00766
00767
00768 if (abfd->flags & D_PAGED)
00769 {
00770 if (info->create_object_symbols_section->next->vma > 0)
00771 obj_datasec (abfd)->vma = info->create_object_symbols_section->next->vma;
00772 else
00773 obj_datasec (abfd)->vma = BFD_ALIGN (vma, adata (abfd).segment_size);
00774 }
00775 else
00776 {
00777 obj_datasec (abfd)->vma = BFD_ALIGN (vma, 4);
00778 }
00779
00780 if (obj_datasec (abfd)->vma < vma)
00781 obj_datasec (abfd)->vma = BFD_ALIGN (vma, 4);
00782
00783 obj_datasec (abfd)->user_set_vma = 1;
00784 vma = obj_datasec (abfd)->vma;
00785 obj_datasec (abfd)->filepos = vma + adata (abfd).exec_bytes_size;
00786 execp->a_text = vma - obj_textsec (abfd)->vma;
00787 obj_textsec (abfd)->size = execp->a_text;
00788
00789
00790 vma += obj_datasec (abfd)->size;
00791 pad = align_power (vma, obj_bsssec (abfd)->alignment_power) - vma;
00792 obj_datasec (abfd)->size += pad;
00793 pos += obj_datasec (abfd)->size;
00794 execp->a_data = obj_datasec (abfd)->size;
00795
00796
00797 obj_bsssec (abfd)->vma = vma;
00798 obj_bsssec (abfd)->user_set_vma = 1;
00799
00800
00801 adata (abfd).magic = z_magic;
00802
00803 return NAME (aout, final_link) (abfd, info, MY_final_link_callback);
00804 }
00805
00806 #endif
00807
00808 enum machine_type
00809 tic30_aout_machine_type (arch, machine, unknown)
00810 enum bfd_architecture arch;
00811 unsigned long machine ATTRIBUTE_UNUSED;
00812 bfd_boolean *unknown;
00813 {
00814 enum machine_type arch_flags;
00815
00816 arch_flags = M_UNKNOWN;
00817 *unknown = TRUE;
00818
00819 switch (arch)
00820 {
00821 case bfd_arch_tic30:
00822 *unknown = FALSE;
00823 break;
00824 default:
00825 arch_flags = M_UNKNOWN;
00826 }
00827 if (arch_flags != M_UNKNOWN)
00828 *unknown = FALSE;
00829 return arch_flags;
00830 }
00831
00832 bfd_boolean
00833 tic30_aout_set_arch_mach (abfd, arch, machine)
00834 bfd *abfd;
00835 enum bfd_architecture arch;
00836 unsigned long machine;
00837 {
00838 if (!bfd_default_set_arch_mach (abfd, arch, machine))
00839 return FALSE;
00840 if (arch != bfd_arch_unknown)
00841 {
00842 bfd_boolean unknown;
00843 tic30_aout_machine_type (arch, machine, &unknown);
00844 if (unknown)
00845 return FALSE;
00846 }
00847 obj_reloc_entry_size (abfd) = RELOC_STD_SIZE;
00848 return (*aout_backend_info (abfd)->set_sizes) (abfd);
00849 }
00850
00851
00852 #ifndef MY_openr_next_archived_file
00853 #define MY_openr_next_archived_file bfd_generic_openr_next_archived_file
00854 #endif
00855 #ifndef MY_get_elt_at_index
00856 #define MY_get_elt_at_index _bfd_generic_get_elt_at_index
00857 #endif
00858 #ifndef MY_generic_stat_arch_elt
00859 #define MY_generic_stat_arch_elt bfd_generic_stat_arch_elt
00860 #endif
00861 #ifndef MY_slurp_armap
00862 #define MY_slurp_armap bfd_slurp_bsd_armap
00863 #endif
00864 #ifndef MY_slurp_extended_name_table
00865 #define MY_slurp_extended_name_table _bfd_slurp_extended_name_table
00866 #endif
00867 #ifndef MY_construct_extended_name_table
00868 #define MY_construct_extended_name_table \
00869 _bfd_archive_bsd_construct_extended_name_table
00870 #endif
00871 #ifndef MY_write_armap
00872 #define MY_write_armap bsd_write_armap
00873 #endif
00874 #ifndef MY_read_ar_hdr
00875 #define MY_read_ar_hdr _bfd_generic_read_ar_hdr
00876 #endif
00877 #ifndef MY_truncate_arname
00878 #define MY_truncate_arname bfd_bsd_truncate_arname
00879 #endif
00880 #ifndef MY_update_armap_timestamp
00881 #define MY_update_armap_timestamp _bfd_archive_bsd_update_armap_timestamp
00882 #endif
00883
00884
00885 #ifndef MY_core_file_failing_command
00886 #define MY_core_file_failing_command _bfd_nocore_core_file_failing_command
00887 #endif
00888 #ifndef MY_core_file_failing_signal
00889 #define MY_core_file_failing_signal _bfd_nocore_core_file_failing_signal
00890 #endif
00891 #ifndef MY_core_file_matches_executable_p
00892 #define MY_core_file_matches_executable_p \
00893 _bfd_nocore_core_file_matches_executable_p
00894 #endif
00895 #ifndef MY_core_file_p
00896 #define MY_core_file_p _bfd_dummy_target
00897 #endif
00898
00899 #ifndef MY_bfd_debug_info_start
00900 #define MY_bfd_debug_info_start bfd_void
00901 #endif
00902 #ifndef MY_bfd_debug_info_end
00903 #define MY_bfd_debug_info_end bfd_void
00904 #endif
00905 #ifndef MY_bfd_debug_info_accumulate
00906 #define MY_bfd_debug_info_accumulate \
00907 (void (*) PARAMS ((bfd*, struct bfd_section *))) bfd_void
00908 #endif
00909
00910 #ifndef MY_core_file_failing_command
00911 #define MY_core_file_failing_command NAME(aout,core_file_failing_command)
00912 #endif
00913 #ifndef MY_core_file_failing_signal
00914 #define MY_core_file_failing_signal NAME(aout,core_file_failing_signal)
00915 #endif
00916 #ifndef MY_core_file_matches_executable_p
00917 #define MY_core_file_matches_executable_p NAME(aout,core_file_matches_executable_p)
00918 #endif
00919 #ifndef MY_set_section_contents
00920 #define MY_set_section_contents NAME(aout,set_section_contents)
00921 #endif
00922 #ifndef MY_get_section_contents
00923 #define MY_get_section_contents aout_32_get_section_contents
00924 #endif
00925 #ifndef MY_get_section_contents_in_window
00926 #define MY_get_section_contents_in_window _bfd_generic_get_section_contents_in_window
00927 #endif
00928 #ifndef MY_new_section_hook
00929 #define MY_new_section_hook NAME(aout,new_section_hook)
00930 #endif
00931 #ifndef MY_get_symtab_upper_bound
00932 #define MY_get_symtab_upper_bound NAME(aout,get_symtab_upper_bound)
00933 #endif
00934 #ifndef MY_canonicalize_symtab
00935 #define MY_canonicalize_symtab NAME(aout,canonicalize_symtab)
00936 #endif
00937 #ifndef MY_get_reloc_upper_bound
00938 #define MY_get_reloc_upper_bound NAME(aout,get_reloc_upper_bound)
00939 #endif
00940 #ifndef MY_canonicalize_reloc
00941 #define MY_canonicalize_reloc NAME(aout,canonicalize_reloc)
00942 #endif
00943 #ifndef MY_make_empty_symbol
00944 #define MY_make_empty_symbol NAME(aout,make_empty_symbol)
00945 #endif
00946 #ifndef MY_print_symbol
00947 #define MY_print_symbol NAME(aout,print_symbol)
00948 #endif
00949 #ifndef MY_get_symbol_info
00950 #define MY_get_symbol_info NAME(aout,get_symbol_info)
00951 #endif
00952 #ifndef MY_get_lineno
00953 #define MY_get_lineno NAME(aout,get_lineno)
00954 #endif
00955 #ifndef MY_set_arch_mach
00956 #define MY_set_arch_mach tic30_aout_set_arch_mach
00957 #endif
00958 #ifndef MY_find_nearest_line
00959 #define MY_find_nearest_line NAME(aout,find_nearest_line)
00960 #endif
00961 #ifndef MY_sizeof_headers
00962 #define MY_sizeof_headers NAME(aout,sizeof_headers)
00963 #endif
00964 #ifndef MY_bfd_get_relocated_section_contents
00965 #define MY_bfd_get_relocated_section_contents \
00966 bfd_generic_get_relocated_section_contents
00967 #endif
00968 #ifndef MY_bfd_relax_section
00969 #define MY_bfd_relax_section bfd_generic_relax_section
00970 #endif
00971 #ifndef MY_bfd_gc_sections
00972 #define MY_bfd_gc_sections bfd_generic_gc_sections
00973 #endif
00974 #ifndef MY_bfd_merge_sections
00975 #define MY_bfd_merge_sections bfd_generic_merge_sections
00976 #endif
00977 #ifndef MY_bfd_is_group_section
00978 #define MY_bfd_is_group_section bfd_generic_is_group_section
00979 #endif
00980 #ifndef MY_bfd_discard_group
00981 #define MY_bfd_discard_group bfd_generic_discard_group
00982 #endif
00983 #ifndef MY_section_already_linked
00984 #define MY_section_already_linked \
00985 _bfd_generic_section_already_linked
00986 #endif
00987 #ifndef MY_bfd_reloc_type_lookup
00988 #define MY_bfd_reloc_type_lookup tic30_aout_reloc_type_lookup
00989 #endif
00990 #ifndef MY_bfd_make_debug_symbol
00991 #define MY_bfd_make_debug_symbol 0
00992 #endif
00993 #ifndef MY_read_minisymbols
00994 #define MY_read_minisymbols NAME(aout,read_minisymbols)
00995 #endif
00996 #ifndef MY_minisymbol_to_symbol
00997 #define MY_minisymbol_to_symbol NAME(aout,minisymbol_to_symbol)
00998 #endif
00999 #ifndef MY_bfd_link_hash_table_create
01000 #define MY_bfd_link_hash_table_create NAME(aout,link_hash_table_create)
01001 #endif
01002 #ifndef MY_bfd_link_hash_table_free
01003 #define MY_bfd_link_hash_table_free _bfd_generic_link_hash_table_free
01004 #endif
01005 #ifndef MY_bfd_link_add_symbols
01006 #define MY_bfd_link_add_symbols NAME(aout,link_add_symbols)
01007 #endif
01008 #ifndef MY_bfd_link_just_syms
01009 #define MY_bfd_link_just_syms _bfd_generic_link_just_syms
01010 #endif
01011 #ifndef MY_bfd_link_split_section
01012 #define MY_bfd_link_split_section _bfd_generic_link_split_section
01013 #endif
01014
01015 #ifndef MY_bfd_copy_private_bfd_data
01016 #define MY_bfd_copy_private_bfd_data _bfd_generic_bfd_copy_private_bfd_data
01017 #endif
01018
01019 #ifndef MY_bfd_merge_private_bfd_data
01020 #define MY_bfd_merge_private_bfd_data _bfd_generic_bfd_merge_private_bfd_data
01021 #endif
01022
01023 #ifndef MY_bfd_copy_private_symbol_data
01024 #define MY_bfd_copy_private_symbol_data _bfd_generic_bfd_copy_private_symbol_data
01025 #endif
01026
01027 #ifndef MY_bfd_copy_private_header_data
01028 #define MY_bfd_copy_private_header_data _bfd_generic_bfd_copy_private_header_data
01029 #endif
01030
01031 #ifndef MY_bfd_print_private_bfd_data
01032 #define MY_bfd_print_private_bfd_data _bfd_generic_bfd_print_private_bfd_data
01033 #endif
01034
01035 #ifndef MY_bfd_set_private_flags
01036 #define MY_bfd_set_private_flags _bfd_generic_bfd_set_private_flags
01037 #endif
01038
01039 #ifndef MY_bfd_is_local_label_name
01040 #define MY_bfd_is_local_label_name bfd_generic_is_local_label_name
01041 #endif
01042
01043 #ifndef MY_bfd_is_target_special_symbol
01044 #define MY_bfd_is_target_special_symbol \
01045 ((bfd_boolean (*) (bfd *, asymbol *)) bfd_false)
01046 #endif
01047
01048 #ifndef MY_bfd_free_cached_info
01049 #define MY_bfd_free_cached_info NAME(aout,bfd_free_cached_info)
01050 #endif
01051
01052 #ifndef MY_close_and_cleanup
01053 #define MY_close_and_cleanup MY_bfd_free_cached_info
01054 #endif
01055
01056 #ifndef MY_get_dynamic_symtab_upper_bound
01057 #define MY_get_dynamic_symtab_upper_bound \
01058 _bfd_nodynamic_get_dynamic_symtab_upper_bound
01059 #endif
01060 #ifndef MY_canonicalize_dynamic_symtab
01061 #define MY_canonicalize_dynamic_symtab \
01062 _bfd_nodynamic_canonicalize_dynamic_symtab
01063 #endif
01064 #ifndef MY_get_synthetic_symtab
01065 #define MY_get_synthetic_symtab \
01066 _bfd_nodynamic_get_synthetic_symtab
01067 #endif
01068 #ifndef MY_get_dynamic_reloc_upper_bound
01069 #define MY_get_dynamic_reloc_upper_bound \
01070 _bfd_nodynamic_get_dynamic_reloc_upper_bound
01071 #endif
01072 #ifndef MY_canonicalize_dynamic_reloc
01073 #define MY_canonicalize_dynamic_reloc \
01074 _bfd_nodynamic_canonicalize_dynamic_reloc
01075 #endif
01076
01077
01078 #ifndef MY_symbol_leading_char
01079 #define MY_symbol_leading_char '_'
01080 #endif
01081
01082
01083 #ifndef AR_PAD_CHAR
01084 #define AR_PAD_CHAR ' '
01085 #endif
01086
01087 #ifndef MY_BFD_TARGET
01088 const bfd_target tic30_aout_vec =
01089 {
01090 TARGETNAME,
01091 bfd_target_aout_flavour,
01092 BFD_ENDIAN_BIG,
01093 BFD_ENDIAN_BIG,
01094 (HAS_RELOC |
01095 HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED),
01096 (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC),
01097 MY_symbol_leading_char,
01098 AR_PAD_CHAR,
01099 15,
01100 bfd_getb64, bfd_getb_signed_64, bfd_putb64,
01101 bfd_getb32, bfd_getb_signed_32, bfd_putb32,
01102 bfd_getb16, bfd_getb_signed_16, bfd_putb16,
01103 bfd_getb64, bfd_getb_signed_64, bfd_putb64,
01104 bfd_getb32, bfd_getb_signed_32, bfd_putb32,
01105 bfd_getb16, bfd_getb_signed_16, bfd_putb16,
01106 {_bfd_dummy_target, MY_object_p,
01107 bfd_generic_archive_p, MY_core_file_p},
01108 {bfd_false, MY_mkobject,
01109 _bfd_generic_mkarchive, bfd_false},
01110 {bfd_false, MY_write_object_contents,
01111 _bfd_write_archive_contents, bfd_false},
01112
01113 BFD_JUMP_TABLE_GENERIC (MY),
01114 BFD_JUMP_TABLE_COPY (MY),
01115 BFD_JUMP_TABLE_CORE (MY),
01116 BFD_JUMP_TABLE_ARCHIVE (MY),
01117 BFD_JUMP_TABLE_SYMBOLS (MY),
01118 BFD_JUMP_TABLE_RELOCS (MY),
01119 BFD_JUMP_TABLE_WRITE (MY),
01120 BFD_JUMP_TABLE_LINK (MY),
01121 BFD_JUMP_TABLE_DYNAMIC (MY),
01122
01123 NULL,
01124
01125 (PTR) MY_backend_data
01126 };
01127 #endif