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 #include "bfd.h"
00028 #include "sysdep.h"
00029 #include "libbfd.h"
00030 #include "bfdlink.h"
00031 #include "genlink.h"
00032 #include "bout.h"
00033
00034 #include "aout/stab_gnu.h"
00035 #include "libaout.h"
00036
00037 static int aligncode
00038 PARAMS ((bfd *abfd, asection *input_section, arelent *r,
00039 unsigned int shrink));
00040 static void perform_slip
00041 PARAMS ((bfd *abfd, unsigned int slip, asection *input_section,
00042 bfd_vma value));
00043 static bfd_boolean b_out_squirt_out_relocs
00044 PARAMS ((bfd *abfd, asection *section));
00045 static const bfd_target *b_out_callback
00046 PARAMS ((bfd *));
00047 static bfd_reloc_status_type calljx_callback
00048 PARAMS ((bfd *, struct bfd_link_info *, arelent *, PTR src, PTR dst,
00049 asection *));
00050 static bfd_reloc_status_type callj_callback
00051 PARAMS ((bfd *, struct bfd_link_info *, arelent *, PTR data,
00052 unsigned int srcidx, unsigned int dstidx, asection *, bfd_boolean));
00053 static bfd_vma get_value
00054 PARAMS ((arelent *, struct bfd_link_info *, asection *));
00055 static int abs32code
00056 PARAMS ((bfd *, asection *, arelent *, unsigned int,
00057 struct bfd_link_info *));
00058 static bfd_boolean b_out_bfd_relax_section
00059 PARAMS ((bfd *, asection *, struct bfd_link_info *, bfd_boolean *));
00060 static bfd_byte *b_out_bfd_get_relocated_section_contents
00061 PARAMS ((bfd *, struct bfd_link_info *, struct bfd_link_order *, bfd_byte *,
00062 bfd_boolean, asymbol **));
00063 static int b_out_sizeof_headers
00064 PARAMS ((bfd *, bfd_boolean));
00065 static bfd_boolean b_out_set_arch_mach
00066 PARAMS ((bfd *, enum bfd_architecture, unsigned long));
00067 static bfd_boolean b_out_set_section_contents
00068 PARAMS ((bfd *, asection *, const PTR, file_ptr, bfd_size_type));
00069 static long b_out_get_reloc_upper_bound
00070 PARAMS ((bfd *, sec_ptr));
00071 static long b_out_canonicalize_reloc
00072 PARAMS ((bfd *, sec_ptr, arelent **, asymbol **));
00073 static bfd_boolean b_out_slurp_reloc_table
00074 PARAMS ((bfd *, sec_ptr, asymbol **));
00075 static reloc_howto_type *b_out_bfd_reloc_type_lookup
00076 PARAMS ((bfd *, bfd_reloc_code_real_type));
00077 static bfd_boolean b_out_write_object_contents
00078 PARAMS ((bfd *));
00079 static int b_out_symbol_cmp
00080 PARAMS ((const void *, const void *));
00081 static bfd_boolean b_out_mkobject
00082 PARAMS ((bfd *));
00083 static const bfd_target *b_out_object_p
00084 PARAMS ((bfd *));
00085
00086 void bout_swap_exec_header_in
00087 PARAMS ((bfd *, struct external_exec *, struct internal_exec *));
00088 void bout_swap_exec_header_out
00089 PARAMS ((bfd *, struct internal_exec *, struct external_exec *));
00090
00091
00092
00093
00094 void
00095 bout_swap_exec_header_in (abfd, raw_bytes, execp)
00096 bfd *abfd;
00097 struct external_exec *raw_bytes;
00098 struct internal_exec *execp;
00099 {
00100 struct external_exec *bytes = (struct external_exec *)raw_bytes;
00101
00102
00103 execp->a_info = H_GET_32 (abfd, bytes->e_info);
00104 execp->a_text = GET_WORD (abfd, bytes->e_text);
00105 execp->a_data = GET_WORD (abfd, bytes->e_data);
00106 execp->a_bss = GET_WORD (abfd, bytes->e_bss);
00107 execp->a_syms = GET_WORD (abfd, bytes->e_syms);
00108 execp->a_entry = GET_WORD (abfd, bytes->e_entry);
00109 execp->a_trsize = GET_WORD (abfd, bytes->e_trsize);
00110 execp->a_drsize = GET_WORD (abfd, bytes->e_drsize);
00111 execp->a_tload = GET_WORD (abfd, bytes->e_tload);
00112 execp->a_dload = GET_WORD (abfd, bytes->e_dload);
00113 execp->a_talign = bytes->e_talign[0];
00114 execp->a_dalign = bytes->e_dalign[0];
00115 execp->a_balign = bytes->e_balign[0];
00116 execp->a_relaxable = bytes->e_relaxable[0];
00117 }
00118
00119
00120
00121
00122 void
00123 bout_swap_exec_header_out (abfd, execp, raw_bytes)
00124 bfd *abfd;
00125 struct internal_exec *execp;
00126 struct external_exec *raw_bytes;
00127 {
00128 struct external_exec *bytes = (struct external_exec *)raw_bytes;
00129
00130
00131 H_PUT_32 (abfd, execp->a_info , bytes->e_info);
00132 PUT_WORD (abfd, execp->a_text , bytes->e_text);
00133 PUT_WORD (abfd, execp->a_data , bytes->e_data);
00134 PUT_WORD (abfd, execp->a_bss , bytes->e_bss);
00135 PUT_WORD (abfd, execp->a_syms , bytes->e_syms);
00136 PUT_WORD (abfd, execp->a_entry , bytes->e_entry);
00137 PUT_WORD (abfd, execp->a_trsize, bytes->e_trsize);
00138 PUT_WORD (abfd, execp->a_drsize, bytes->e_drsize);
00139 PUT_WORD (abfd, execp->a_tload , bytes->e_tload);
00140 PUT_WORD (abfd, execp->a_dload , bytes->e_dload);
00141 bytes->e_talign[0] = execp->a_talign;
00142 bytes->e_dalign[0] = execp->a_dalign;
00143 bytes->e_balign[0] = execp->a_balign;
00144 bytes->e_relaxable[0] = execp->a_relaxable;
00145 }
00146
00147 static const bfd_target *
00148 b_out_object_p (abfd)
00149 bfd *abfd;
00150 {
00151 struct internal_exec anexec;
00152 struct external_exec exec_bytes;
00153 bfd_size_type amt = EXEC_BYTES_SIZE;
00154
00155 if (bfd_bread ((PTR) &exec_bytes, amt, abfd) != amt)
00156 {
00157 if (bfd_get_error () != bfd_error_system_call)
00158 bfd_set_error (bfd_error_wrong_format);
00159 return 0;
00160 }
00161
00162 anexec.a_info = H_GET_32 (abfd, exec_bytes.e_info);
00163
00164 if (N_BADMAG (anexec))
00165 {
00166 bfd_set_error (bfd_error_wrong_format);
00167 return 0;
00168 }
00169
00170 bout_swap_exec_header_in (abfd, &exec_bytes, &anexec);
00171 return aout_32_some_aout_object_p (abfd, &anexec, b_out_callback);
00172 }
00173
00174
00175
00176
00177 static const bfd_target *
00178 b_out_callback (abfd)
00179 bfd *abfd;
00180 {
00181 struct internal_exec *execp = exec_hdr (abfd);
00182 unsigned long bss_start;
00183
00184
00185 bfd_set_arch_mach(abfd,
00186 bfd_arch_i960,
00187 bfd_mach_i960_core
00188 );
00189
00190
00191 obj_str_filepos (abfd) = N_STROFF (*execp);
00192 obj_sym_filepos (abfd) = N_SYMOFF (*execp);
00193
00194
00195 obj_textsec (abfd)->alignment_power = execp->a_talign;
00196 obj_datasec (abfd)->alignment_power = execp->a_dalign;
00197 obj_bsssec (abfd)->alignment_power = execp->a_balign;
00198
00199
00200 obj_textsec (abfd)->vma = execp->a_tload;
00201 obj_datasec (abfd)->vma = execp->a_dload;
00202
00203 obj_textsec (abfd)->lma = obj_textsec (abfd)->vma;
00204 obj_datasec (abfd)->lma = obj_datasec (abfd)->vma;
00205
00206
00207 obj_textsec (abfd)->size = execp->a_text;
00208
00209 bss_start = execp->a_dload + execp->a_data;
00210 obj_bsssec (abfd)->vma = align_power (bss_start, execp->a_balign);
00211
00212 obj_bsssec (abfd)->lma = obj_bsssec (abfd)->vma;
00213
00214
00215 obj_textsec (abfd)->filepos = N_TXTOFF(*execp);
00216 obj_datasec (abfd)->filepos = N_DATOFF(*execp);
00217
00218
00219 obj_textsec (abfd)->rel_filepos = N_TROFF(*execp);
00220 obj_datasec (abfd)->rel_filepos = N_DROFF(*execp);
00221
00222 adata(abfd).page_size = 1;
00223 adata(abfd).segment_size = 1;
00224 adata(abfd).exec_bytes_size = EXEC_BYTES_SIZE;
00225
00226 if (execp->a_relaxable)
00227 abfd->flags |= BFD_IS_RELAXABLE;
00228 return abfd->xvec;
00229 }
00230
00231 struct bout_data_struct
00232 {
00233 struct aoutdata a;
00234 struct internal_exec e;
00235 };
00236
00237 static bfd_boolean
00238 b_out_mkobject (abfd)
00239 bfd *abfd;
00240 {
00241 struct bout_data_struct *rawptr;
00242 bfd_size_type amt = sizeof (struct bout_data_struct);
00243
00244 rawptr = (struct bout_data_struct *) bfd_zalloc (abfd, amt);
00245 if (rawptr == NULL)
00246 return FALSE;
00247
00248 abfd->tdata.bout_data = rawptr;
00249 exec_hdr (abfd) = &rawptr->e;
00250
00251 obj_textsec (abfd) = (asection *) NULL;
00252 obj_datasec (abfd) = (asection *) NULL;
00253 obj_bsssec (abfd) = (asection *) NULL;
00254
00255 return TRUE;
00256 }
00257
00258 static int
00259 b_out_symbol_cmp (a_ptr, b_ptr)
00260 const void * a_ptr;
00261 const void * b_ptr;
00262 {
00263 struct aout_symbol ** a = (struct aout_symbol **) a_ptr;
00264 struct aout_symbol ** b = (struct aout_symbol **) b_ptr;
00265 asection *sec;
00266 bfd_vma av, bv;
00267
00268
00269 sec = bfd_get_section (&(*a)->symbol);
00270 av = sec->output_section->vma + sec->output_offset + (*a)->symbol.value;
00271 sec = bfd_get_section (&(*b)->symbol);
00272 bv = sec->output_section->vma + sec->output_offset + (*b)->symbol.value;
00273
00274 if (av < bv)
00275 return -1;
00276 if (av > bv)
00277 return 1;
00278
00279
00280
00281 if (IS_BALNAME ((*a)->other) || IS_CALLNAME ((*b)->other))
00282 return -1;
00283 if (IS_CALLNAME ((*a)->other) || IS_BALNAME ((*b)->other))
00284 return 1;
00285
00286 return 0;
00287 }
00288
00289 static bfd_boolean
00290 b_out_write_object_contents (abfd)
00291 bfd *abfd;
00292 {
00293 struct external_exec swapped_hdr;
00294 bfd_size_type amt;
00295
00296 if (! aout_32_make_sections (abfd))
00297 return FALSE;
00298
00299 exec_hdr (abfd)->a_info = BMAGIC;
00300
00301 exec_hdr (abfd)->a_text = obj_textsec (abfd)->size;
00302 exec_hdr (abfd)->a_data = obj_datasec (abfd)->size;
00303 exec_hdr (abfd)->a_bss = obj_bsssec (abfd)->size;
00304 exec_hdr (abfd)->a_syms = bfd_get_symcount (abfd) * 12;
00305 exec_hdr (abfd)->a_entry = bfd_get_start_address (abfd);
00306 exec_hdr (abfd)->a_trsize = (obj_textsec (abfd)->reloc_count) * 8;
00307 exec_hdr (abfd)->a_drsize = (obj_datasec (abfd)->reloc_count) * 8;
00308
00309 exec_hdr (abfd)->a_talign = obj_textsec (abfd)->alignment_power;
00310 exec_hdr (abfd)->a_dalign = obj_datasec (abfd)->alignment_power;
00311 exec_hdr (abfd)->a_balign = obj_bsssec (abfd)->alignment_power;
00312
00313 exec_hdr (abfd)->a_tload = obj_textsec (abfd)->vma;
00314 exec_hdr (abfd)->a_dload = obj_datasec (abfd)->vma;
00315
00316 bout_swap_exec_header_out (abfd, exec_hdr (abfd), &swapped_hdr);
00317
00318 amt = EXEC_BYTES_SIZE;
00319 if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0
00320 || bfd_bwrite ((PTR) &swapped_hdr, amt, abfd) != amt)
00321 return FALSE;
00322
00323
00324 if (bfd_get_symcount (abfd) != 0)
00325 {
00326
00327
00328
00329
00330
00331 asymbol **outsyms, **p, **q;
00332
00333 outsyms = bfd_get_outsymbols (abfd);
00334 p = outsyms + bfd_get_symcount (abfd);
00335
00336 for (q = p--; p >= outsyms; p--)
00337 {
00338 if ((*p)->flags & BSF_DEBUGGING)
00339 {
00340 asymbol *t = *--q;
00341 *q = *p;
00342 *p = t;
00343 }
00344 }
00345
00346 if (q > outsyms)
00347 qsort (outsyms, (size_t) (q - outsyms), sizeof (asymbol*),
00348 b_out_symbol_cmp);
00349
00350
00351 if (bfd_seek (abfd, (file_ptr) (N_SYMOFF(*exec_hdr(abfd))), SEEK_SET)
00352 != 0)
00353 return FALSE;
00354
00355 if (! aout_32_write_syms (abfd))
00356 return FALSE;
00357
00358 if (bfd_seek (abfd, (file_ptr) (N_TROFF(*exec_hdr(abfd))), SEEK_SET)
00359 != 0)
00360 return FALSE;
00361
00362 if (!b_out_squirt_out_relocs (abfd, obj_textsec (abfd)))
00363 return FALSE;
00364 if (bfd_seek (abfd, (file_ptr) (N_DROFF(*exec_hdr(abfd))), SEEK_SET)
00365 != 0)
00366 return FALSE;
00367
00368 if (!b_out_squirt_out_relocs (abfd, obj_datasec (abfd)))
00369 return FALSE;
00370 }
00371 return TRUE;
00372 }
00373
00374
00375
00376 #define CALLS 0x66003800
00377 #define BAL 0x0b000000
00378 #define BAL_MASK 0x00ffffff
00379 #define BALX 0x85f00000
00380 #define BALX_MASK 0x0007ffff
00381 #define CALL 0x09000000
00382 #define PCREL13_MASK 0x1fff
00383
00384 #define output_addr(sec) ((sec)->output_offset+(sec)->output_section->vma)
00385
00386
00387
00388 static bfd_reloc_status_type
00389 calljx_callback (abfd, link_info, reloc_entry, src, dst, input_section)
00390 bfd *abfd;
00391 struct bfd_link_info *link_info;
00392 arelent *reloc_entry;
00393 PTR src;
00394 PTR dst;
00395 asection *input_section;
00396 {
00397 int word = bfd_get_32 (abfd, src);
00398 asymbol *symbol_in = *(reloc_entry->sym_ptr_ptr);
00399 aout_symbol_type *symbol = aout_symbol (symbol_in);
00400 bfd_vma value;
00401
00402 value = get_value (reloc_entry, link_info, input_section);
00403
00404 if (IS_CALLNAME (symbol->other))
00405 {
00406 aout_symbol_type *balsym = symbol+1;
00407 int inst = bfd_get_32 (abfd, (bfd_byte *) src-4);
00408
00409 BFD_ASSERT (IS_BALNAME (balsym->other));
00410 inst &= BALX_MASK;
00411 inst |= BALX;
00412 bfd_put_32 (abfd, (bfd_vma) inst, (bfd_byte *) dst-4);
00413 symbol = balsym;
00414 value = (symbol->symbol.value
00415 + output_addr (symbol->symbol.section));
00416 }
00417
00418 word += value + reloc_entry->addend;
00419
00420 bfd_put_32 (abfd, (bfd_vma) word, dst);
00421 return bfd_reloc_ok;
00422 }
00423
00424
00425
00426 static bfd_reloc_status_type
00427 callj_callback (abfd, link_info, reloc_entry, data, srcidx, dstidx,
00428 input_section, shrinking)
00429 bfd *abfd;
00430 struct bfd_link_info *link_info;
00431 arelent *reloc_entry;
00432 PTR data;
00433 unsigned int srcidx;
00434 unsigned int dstidx;
00435 asection *input_section;
00436 bfd_boolean shrinking;
00437 {
00438 int word = bfd_get_32 (abfd, (bfd_byte *) data + srcidx);
00439 asymbol *symbol_in = *(reloc_entry->sym_ptr_ptr);
00440 aout_symbol_type *symbol = aout_symbol (symbol_in);
00441 bfd_vma value;
00442
00443 value = get_value (reloc_entry, link_info, input_section);
00444
00445 if (IS_OTHER(symbol->other))
00446 {
00447
00448
00449 word = CALLS | (symbol->other - 1);
00450 }
00451 else if (IS_CALLNAME(symbol->other))
00452 {
00453 aout_symbol_type *balsym = symbol+1;
00454
00455
00456 BFD_ASSERT(IS_BALNAME(balsym->other));
00457
00458
00459
00460 word = BAL | ((word
00461 + output_addr (balsym->symbol.section)
00462 + balsym->symbol.value + reloc_entry->addend
00463 - dstidx
00464 - output_addr (input_section))
00465 & BAL_MASK);
00466 }
00467 else if ((symbol->symbol.flags & BSF_SECTION_SYM) != 0)
00468 {
00469
00470
00471
00472
00473 BFD_ASSERT (! shrinking);
00474 BFD_ASSERT (symbol->symbol.section == input_section);
00475 }
00476 else
00477 {
00478 word = CALL | (((word & BAL_MASK)
00479 + value
00480 + reloc_entry->addend
00481 - (shrinking ? dstidx : 0)
00482 - output_addr (input_section))
00483 & BAL_MASK);
00484 }
00485 bfd_put_32 (abfd, (bfd_vma) word, (bfd_byte *) data + dstidx);
00486 return bfd_reloc_ok;
00487 }
00488
00489
00490
00491 #define ABS32CODE 0
00492 #define ABS32CODE_SHRUNK 1
00493 #define PCREL24 2
00494 #define CALLJ 3
00495 #define ABS32 4
00496 #define PCREL13 5
00497 #define ABS32_MAYBE_RELAXABLE 1
00498 #define ABS32_WAS_RELAXABLE 2
00499
00500 #define ALIGNER 10
00501 #define ALIGNDONE 11
00502 static reloc_howto_type howto_reloc_callj =
00503 HOWTO(CALLJ, 0, 2, 24, TRUE, 0, complain_overflow_signed, 0,"callj", TRUE, 0x00ffffff, 0x00ffffff,FALSE);
00504 static reloc_howto_type howto_reloc_abs32 =
00505 HOWTO(ABS32, 0, 2, 32, FALSE, 0, complain_overflow_bitfield,0,"abs32", TRUE, 0xffffffff,0xffffffff,FALSE);
00506 static reloc_howto_type howto_reloc_pcrel24 =
00507 HOWTO(PCREL24, 0, 2, 24, TRUE, 0, complain_overflow_signed,0,"pcrel24", TRUE, 0x00ffffff,0x00ffffff,FALSE);
00508
00509 static reloc_howto_type howto_reloc_pcrel13 =
00510 HOWTO(PCREL13, 0, 2, 13, TRUE, 0, complain_overflow_signed,0,"pcrel13", TRUE, 0x00001fff,0x00001fff,FALSE);
00511
00512 static reloc_howto_type howto_reloc_abs32codeshrunk =
00513 HOWTO(ABS32CODE_SHRUNK, 0, 2, 24, TRUE, 0, complain_overflow_signed, 0,"callx->callj", TRUE, 0x00ffffff, 0x00ffffff,FALSE);
00514
00515 static reloc_howto_type howto_reloc_abs32code =
00516 HOWTO(ABS32CODE, 0, 2, 32, FALSE, 0, complain_overflow_bitfield,0,"callx", TRUE, 0xffffffff,0xffffffff,FALSE);
00517
00518 static reloc_howto_type howto_align_table[] = {
00519 HOWTO (ALIGNER, 0, 0x1, 0, FALSE, 0, complain_overflow_dont, 0, "align16", FALSE, 0, 0, FALSE),
00520 HOWTO (ALIGNER, 0, 0x3, 0, FALSE, 0, complain_overflow_dont, 0, "align32", FALSE, 0, 0, FALSE),
00521 HOWTO (ALIGNER, 0, 0x7, 0, FALSE, 0, complain_overflow_dont, 0, "align64", FALSE, 0, 0, FALSE),
00522 HOWTO (ALIGNER, 0, 0xf, 0, FALSE, 0, complain_overflow_dont, 0, "align128", FALSE, 0, 0, FALSE),
00523 };
00524
00525 static reloc_howto_type howto_done_align_table[] = {
00526 HOWTO (ALIGNDONE, 0x1, 0x1, 0, FALSE, 0, complain_overflow_dont, 0, "donealign16", FALSE, 0, 0, FALSE),
00527 HOWTO (ALIGNDONE, 0x3, 0x3, 0, FALSE, 0, complain_overflow_dont, 0, "donealign32", FALSE, 0, 0, FALSE),
00528 HOWTO (ALIGNDONE, 0x7, 0x7, 0, FALSE, 0, complain_overflow_dont, 0, "donealign64", FALSE, 0, 0, FALSE),
00529 HOWTO (ALIGNDONE, 0xf, 0xf, 0, FALSE, 0, complain_overflow_dont, 0, "donealign128", FALSE, 0, 0, FALSE),
00530 };
00531
00532 static reloc_howto_type *
00533 b_out_bfd_reloc_type_lookup (abfd, code)
00534 bfd *abfd ATTRIBUTE_UNUSED;
00535 bfd_reloc_code_real_type code;
00536 {
00537 switch (code)
00538 {
00539 default:
00540 return 0;
00541 case BFD_RELOC_I960_CALLJ:
00542 return &howto_reloc_callj;
00543 case BFD_RELOC_32:
00544 case BFD_RELOC_CTOR:
00545 return &howto_reloc_abs32;
00546 case BFD_RELOC_24_PCREL:
00547 return &howto_reloc_pcrel24;
00548 }
00549 }
00550
00551
00552
00553 static bfd_boolean
00554 b_out_slurp_reloc_table (abfd, asect, symbols)
00555 bfd *abfd;
00556 sec_ptr asect;
00557 asymbol **symbols;
00558 {
00559 register struct relocation_info *rptr;
00560 unsigned int counter;
00561 arelent *cache_ptr;
00562 int extern_mask, pcrel_mask, callj_mask, length_shift;
00563 int incode_mask;
00564 int size_mask;
00565 bfd_vma prev_addr = 0;
00566 unsigned int count;
00567 bfd_size_type reloc_size, amt;
00568 struct relocation_info *relocs;
00569 arelent *reloc_cache;
00570
00571 if (asect->relocation)
00572 return TRUE;
00573
00574 if (!aout_32_slurp_symbol_table (abfd))
00575 return FALSE;
00576
00577 if (asect == obj_datasec (abfd))
00578 {
00579 reloc_size = exec_hdr(abfd)->a_drsize;
00580 goto doit;
00581 }
00582
00583 if (asect == obj_textsec (abfd))
00584 {
00585 reloc_size = exec_hdr(abfd)->a_trsize;
00586 goto doit;
00587 }
00588
00589 if (asect == obj_bsssec (abfd))
00590 {
00591 reloc_size = 0;
00592 goto doit;
00593 }
00594
00595 bfd_set_error (bfd_error_invalid_operation);
00596 return FALSE;
00597
00598 doit:
00599 if (bfd_seek (abfd, asect->rel_filepos, SEEK_SET) != 0)
00600 return FALSE;
00601 count = reloc_size / sizeof (struct relocation_info);
00602
00603 relocs = (struct relocation_info *) bfd_malloc (reloc_size);
00604 if (!relocs && reloc_size != 0)
00605 return FALSE;
00606
00607 amt = ((bfd_size_type) count + 1) * sizeof (arelent);
00608 reloc_cache = (arelent *) bfd_malloc (amt);
00609 if (!reloc_cache)
00610 {
00611 if (relocs != NULL)
00612 free (relocs);
00613 return FALSE;
00614 }
00615
00616 if (bfd_bread ((PTR) relocs, reloc_size, abfd) != reloc_size)
00617 {
00618 free (reloc_cache);
00619 if (relocs != NULL)
00620 free (relocs);
00621 return FALSE;
00622 }
00623
00624 if (bfd_header_big_endian (abfd))
00625 {
00626
00627 pcrel_mask = 0x80;
00628 extern_mask = 0x10;
00629 incode_mask = 0x08;
00630 callj_mask = 0x02;
00631 size_mask = 0x20;
00632 length_shift = 5;
00633 }
00634 else
00635 {
00636
00637 pcrel_mask = 0x01;
00638 extern_mask = 0x08;
00639 incode_mask = 0x10;
00640 callj_mask = 0x40;
00641 size_mask = 0x02;
00642 length_shift = 1;
00643 }
00644
00645 for (rptr = relocs, cache_ptr = reloc_cache, counter = 0;
00646 counter < count;
00647 counter++, rptr++, cache_ptr++)
00648 {
00649 unsigned char *raw = (unsigned char *)rptr;
00650 unsigned int symnum;
00651
00652 cache_ptr->address = H_GET_32 (abfd, raw + 0);
00653 cache_ptr->howto = 0;
00654
00655 if (bfd_header_big_endian (abfd))
00656 symnum = (raw[4] << 16) | (raw[5] << 8) | raw[6];
00657 else
00658 symnum = (raw[6] << 16) | (raw[5] << 8) | raw[4];
00659
00660 if (raw[7] & extern_mask)
00661 {
00662
00663
00664
00665
00666 cache_ptr->sym_ptr_ptr = symbols + symnum;
00667 cache_ptr->addend = 0;
00668 }
00669 else
00670 {
00671
00672
00673
00674
00675
00676
00677 int s;
00678
00679
00680 s = symnum;
00681 if (s & (1 << 23))
00682 s |= (~0) << 24;
00683
00684 cache_ptr->sym_ptr_ptr = (asymbol **)NULL;
00685 switch (s)
00686 {
00687 case N_TEXT:
00688 case N_TEXT | N_EXT:
00689 cache_ptr->sym_ptr_ptr = obj_textsec (abfd)->symbol_ptr_ptr;
00690 cache_ptr->addend = - obj_textsec (abfd)->vma;
00691 break;
00692 case N_DATA:
00693 case N_DATA | N_EXT:
00694 cache_ptr->sym_ptr_ptr = obj_datasec (abfd)->symbol_ptr_ptr;
00695 cache_ptr->addend = - obj_datasec (abfd)->vma;
00696 break;
00697 case N_BSS:
00698 case N_BSS | N_EXT:
00699 cache_ptr->sym_ptr_ptr = obj_bsssec (abfd)->symbol_ptr_ptr;
00700 cache_ptr->addend = - obj_bsssec (abfd)->vma;
00701 break;
00702 case N_ABS:
00703 case N_ABS | N_EXT:
00704 cache_ptr->sym_ptr_ptr = obj_bsssec (abfd)->symbol_ptr_ptr;
00705 cache_ptr->addend = 0;
00706 break;
00707 case -2:
00708 if (raw[7] & pcrel_mask)
00709 {
00710 cache_ptr->howto = &howto_align_table[(raw[7] >> length_shift) & 3];
00711 cache_ptr->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
00712 }
00713 else
00714 {
00715
00716 abort ();
00717 }
00718 cache_ptr->addend = 0;
00719 break;
00720 default:
00721 BFD_ASSERT(0);
00722 break;
00723 }
00724 }
00725
00726
00727
00728 if (cache_ptr->howto != 0)
00729 ;
00730 else if (raw[7] & callj_mask)
00731 {
00732 cache_ptr->howto = &howto_reloc_callj;
00733 }
00734 else if ( raw[7] & pcrel_mask)
00735 {
00736 if (raw[7] & size_mask)
00737 cache_ptr->howto = &howto_reloc_pcrel13;
00738 else
00739 cache_ptr->howto = &howto_reloc_pcrel24;
00740 }
00741 else
00742 {
00743 if (raw[7] & incode_mask)
00744 cache_ptr->howto = &howto_reloc_abs32code;
00745 else
00746 cache_ptr->howto = &howto_reloc_abs32;
00747 }
00748
00749 if (cache_ptr->address < prev_addr)
00750 {
00751
00752 arelent tmp;
00753 arelent *cursor = cache_ptr-1;
00754 bfd_vma stop = cache_ptr->address;
00755
00756 tmp = *cache_ptr;
00757 while (cursor->address > stop && cursor >= reloc_cache)
00758 {
00759 cursor[1] = cursor[0];
00760 cursor--;
00761 }
00762
00763 cursor[1] = tmp;
00764 }
00765 else
00766 {
00767 prev_addr = cache_ptr->address;
00768 }
00769 }
00770
00771 if (relocs != NULL)
00772 free (relocs);
00773 asect->relocation = reloc_cache;
00774 asect->reloc_count = count;
00775
00776 return TRUE;
00777 }
00778
00779 static bfd_boolean
00780 b_out_squirt_out_relocs (abfd, section)
00781 bfd *abfd;
00782 asection *section;
00783 {
00784 arelent **generic;
00785 int r_extern = 0;
00786 int r_idx;
00787 int incode_mask;
00788 int len_1;
00789 unsigned int count = section->reloc_count;
00790 struct relocation_info *native, *natptr;
00791 bfd_size_type natsize;
00792 int extern_mask, pcrel_mask, len_2, callj_mask;
00793
00794 if (count == 0)
00795 return TRUE;
00796
00797 generic = section->orelocation;
00798 natsize = (bfd_size_type) count * sizeof (struct relocation_info);
00799 native = ((struct relocation_info *) bfd_malloc (natsize));
00800 if (!native && natsize != 0)
00801 return FALSE;
00802
00803 if (bfd_header_big_endian (abfd))
00804 {
00805
00806 pcrel_mask = 0x80;
00807 extern_mask = 0x10;
00808 len_2 = 0x40;
00809 len_1 = 0x20;
00810 callj_mask = 0x02;
00811 incode_mask = 0x08;
00812 }
00813 else
00814 {
00815
00816 pcrel_mask = 0x01;
00817 extern_mask = 0x08;
00818 len_2 = 0x04;
00819 len_1 = 0x02;
00820 callj_mask = 0x40;
00821 incode_mask = 0x10;
00822 }
00823
00824 for (natptr = native; count > 0; --count, ++natptr, ++generic)
00825 {
00826 arelent *g = *generic;
00827 unsigned char *raw = (unsigned char *)natptr;
00828 asymbol *sym = *(g->sym_ptr_ptr);
00829 asection *output_section = sym->section->output_section;
00830
00831 H_PUT_32 (abfd, g->address, raw);
00832
00833
00834 r_idx = 0;
00835
00836
00837 if (g->howto== &howto_reloc_callj)
00838 raw[7] = callj_mask + pcrel_mask + len_2;
00839 else if (g->howto == &howto_reloc_pcrel24)
00840 raw[7] = pcrel_mask + len_2;
00841 else if (g->howto == &howto_reloc_pcrel13)
00842 raw[7] = pcrel_mask + len_1;
00843 else if (g->howto == &howto_reloc_abs32code)
00844 raw[7] = len_2 + incode_mask;
00845 else if (g->howto >= howto_align_table
00846 && g->howto <= (howto_align_table
00847 + sizeof (howto_align_table) / sizeof (howto_align_table[0])
00848 - 1))
00849 {
00850
00851 r_idx = -2;
00852 r_extern = 0;
00853 raw[7] = (pcrel_mask
00854 | ((g->howto - howto_align_table) << 1));
00855 }
00856 else
00857 raw[7] = len_2;
00858
00859 if (r_idx != 0)
00860 ;
00861 else if (bfd_is_com_section (output_section)
00862 || bfd_is_abs_section (output_section)
00863 || bfd_is_und_section (output_section))
00864 {
00865 if (bfd_abs_section_ptr->symbol == sym)
00866 {
00867
00868
00869 r_idx = 0;
00870 r_extern = 0;
00871 }
00872 else
00873 {
00874
00875 r_extern = 1;
00876 r_idx = (*g->sym_ptr_ptr)->udata.i;
00877 }
00878 }
00879 else
00880 {
00881
00882 r_extern = 0;
00883 r_idx = output_section->target_index;
00884 }
00885
00886 if (bfd_header_big_endian (abfd))
00887 {
00888 raw[4] = (unsigned char) (r_idx >> 16);
00889 raw[5] = (unsigned char) (r_idx >> 8);
00890 raw[6] = (unsigned char) (r_idx );
00891 }
00892 else
00893 {
00894 raw[6] = (unsigned char) (r_idx >> 16);
00895 raw[5] = (unsigned char) (r_idx>> 8);
00896 raw[4] = (unsigned char) (r_idx );
00897 }
00898
00899 if (r_extern)
00900 raw[7] |= extern_mask;
00901 }
00902
00903 if (bfd_bwrite ((PTR) native, natsize, abfd) != natsize)
00904 {
00905 free ((PTR)native);
00906 return FALSE;
00907 }
00908
00909 free ((PTR)native);
00910
00911 return TRUE;
00912 }
00913
00914
00915
00916 static long
00917 b_out_canonicalize_reloc (abfd, section, relptr, symbols)
00918 bfd *abfd;
00919 sec_ptr section;
00920 arelent **relptr;
00921 asymbol **symbols;
00922 {
00923 arelent *tblptr;
00924 unsigned int count;
00925
00926 if ((section->flags & SEC_CONSTRUCTOR) != 0)
00927 {
00928 arelent_chain *chain = section->constructor_chain;
00929
00930 for (count = 0; count < section->reloc_count; count++)
00931 {
00932 *relptr++ = &chain->relent;
00933 chain = chain->next;
00934 }
00935 }
00936 else
00937 {
00938 if (section->relocation == NULL
00939 && ! b_out_slurp_reloc_table (abfd, section, symbols))
00940 return -1;
00941
00942 tblptr = section->relocation;
00943 for (count = 0; count++ < section->reloc_count;)
00944 *relptr++ = tblptr++;
00945 }
00946
00947 *relptr = NULL;
00948
00949 return section->reloc_count;
00950 }
00951
00952 static long
00953 b_out_get_reloc_upper_bound (abfd, asect)
00954 bfd *abfd;
00955 sec_ptr asect;
00956 {
00957 if (bfd_get_format (abfd) != bfd_object)
00958 {
00959 bfd_set_error (bfd_error_invalid_operation);
00960 return -1;
00961 }
00962
00963 if (asect->flags & SEC_CONSTRUCTOR)
00964 return sizeof (arelent *) * (asect->reloc_count + 1);
00965
00966 if (asect == obj_datasec (abfd))
00967 return (sizeof (arelent *) *
00968 ((exec_hdr(abfd)->a_drsize / sizeof (struct relocation_info))
00969 +1));
00970
00971 if (asect == obj_textsec (abfd))
00972 return (sizeof (arelent *) *
00973 ((exec_hdr(abfd)->a_trsize / sizeof (struct relocation_info))
00974 +1));
00975
00976 if (asect == obj_bsssec (abfd))
00977 return 0;
00978
00979 bfd_set_error (bfd_error_invalid_operation);
00980 return -1;
00981 }
00982
00983
00984 static bfd_boolean
00985 b_out_set_section_contents (abfd, section, location, offset, count)
00986 bfd *abfd;
00987 asection *section;
00988 const PTR location;
00989 file_ptr offset;
00990 bfd_size_type count;
00991 {
00992 if (! abfd->output_has_begun)
00993 {
00994
00995 if (! aout_32_make_sections (abfd))
00996 return FALSE;
00997
00998 obj_textsec (abfd)->filepos = sizeof (struct external_exec);
00999 obj_datasec(abfd)->filepos = obj_textsec(abfd)->filepos
01000 + obj_textsec (abfd)->size;
01001 }
01002
01003
01004 if (bfd_seek (abfd, section->filepos + offset, SEEK_SET) != 0)
01005 return FALSE;
01006
01007 if (count == 0)
01008 return TRUE;
01009
01010 return bfd_bwrite ((PTR) location, count, abfd) == count;
01011 }
01012
01013 static bfd_boolean
01014 b_out_set_arch_mach (abfd, arch, machine)
01015 bfd *abfd;
01016 enum bfd_architecture arch;
01017 unsigned long machine;
01018 {
01019 bfd_default_set_arch_mach(abfd, arch, machine);
01020
01021 if (arch == bfd_arch_unknown)
01022 return TRUE;
01023
01024 if (arch == bfd_arch_i960)
01025 switch (machine)
01026 {
01027 case bfd_mach_i960_core:
01028 case bfd_mach_i960_kb_sb:
01029 case bfd_mach_i960_mc:
01030 case bfd_mach_i960_xa:
01031 case bfd_mach_i960_ca:
01032 case bfd_mach_i960_ka_sa:
01033 case bfd_mach_i960_jx:
01034 case bfd_mach_i960_hx:
01035 case 0:
01036 return TRUE;
01037 default:
01038 return FALSE;
01039 }
01040
01041 return FALSE;
01042 }
01043
01044 static int
01045 b_out_sizeof_headers (ignore_abfd, ignore)
01046 bfd *ignore_abfd ATTRIBUTE_UNUSED;
01047 bfd_boolean ignore ATTRIBUTE_UNUSED;
01048 {
01049 return sizeof (struct external_exec);
01050 }
01051
01052
01053 static bfd_vma
01054 get_value (reloc, link_info, input_section)
01055 arelent *reloc;
01056 struct bfd_link_info *link_info;
01057 asection *input_section;
01058 {
01059 bfd_vma value;
01060 asymbol *symbol = *(reloc->sym_ptr_ptr);
01061
01062
01063
01064
01065 if (bfd_is_und_section (symbol->section))
01066 {
01067 struct bfd_link_hash_entry *h;
01068
01069
01070
01071
01072
01073
01074 h = bfd_wrapped_link_hash_lookup (input_section->owner, link_info,
01075 bfd_asymbol_name (symbol),
01076 FALSE, FALSE, TRUE);
01077 if (h != (struct bfd_link_hash_entry *) NULL
01078 && (h->type == bfd_link_hash_defined
01079 || h->type == bfd_link_hash_defweak))
01080 value = h->u.def.value + output_addr (h->u.def.section);
01081 else if (h != (struct bfd_link_hash_entry *) NULL
01082 && h->type == bfd_link_hash_common)
01083 value = h->u.c.size;
01084 else
01085 {
01086 if (! ((*link_info->callbacks->undefined_symbol)
01087 (link_info, bfd_asymbol_name (symbol),
01088 input_section->owner, input_section, reloc->address,
01089 TRUE)))
01090 abort ();
01091 value = 0;
01092 }
01093 }
01094 else
01095 {
01096 value = symbol->value + output_addr (symbol->section);
01097 }
01098
01099
01100 value += reloc->addend;
01101
01102 return value;
01103 }
01104
01105 static void
01106 perform_slip (abfd, slip, input_section, value)
01107 bfd *abfd;
01108 unsigned int slip;
01109 asection *input_section;
01110 bfd_vma value;
01111 {
01112 asymbol **s;
01113
01114 s = _bfd_generic_link_get_symbols (abfd);
01115 BFD_ASSERT (s != (asymbol **) NULL);
01116
01117
01118
01119 while (*s)
01120 {
01121 asymbol *p = *s;
01122
01123 if (p->section == input_section)
01124 {
01125
01126 if (p->value > value)
01127 {
01128 p->value -=slip;
01129
01130 if (p->udata.p != NULL)
01131 {
01132 struct generic_link_hash_entry *h;
01133
01134 h = (struct generic_link_hash_entry *) p->udata.p;
01135 BFD_ASSERT (h->root.type == bfd_link_hash_defined);
01136 h->root.u.def.value -= slip;
01137 BFD_ASSERT (h->root.u.def.value == p->value);
01138 }
01139 }
01140 }
01141 s++;
01142 }
01143 }
01144
01145
01146
01147
01148
01149 static int
01150 abs32code (abfd, input_section, r, shrink, link_info)
01151 bfd *abfd;
01152 asection *input_section;
01153 arelent *r;
01154 unsigned int shrink;
01155 struct bfd_link_info *link_info;
01156 {
01157 bfd_vma value = get_value (r, link_info, input_section);
01158 bfd_vma dot = output_addr (input_section) + r->address;
01159 bfd_vma gap;
01160
01161
01162
01163
01164 gap = value - (dot - shrink);
01165
01166 if (-1 << 23 < (long)gap && (long)gap < 1 << 23)
01167 {
01168
01169
01170 r->howto = &howto_reloc_abs32codeshrunk;
01171
01172 r->address -=4;
01173
01174
01175 shrink += 4 ;
01176 perform_slip (abfd, 4, input_section, r->address-shrink + 4);
01177 }
01178
01179 return shrink;
01180 }
01181
01182 static int
01183 aligncode (abfd, input_section, r, shrink)
01184 bfd *abfd;
01185 asection *input_section;
01186 arelent *r;
01187 unsigned int shrink;
01188 {
01189 bfd_vma dot = output_addr (input_section) + r->address;
01190 bfd_vma gap;
01191 bfd_vma old_end;
01192 bfd_vma new_end;
01193 unsigned int shrink_delta;
01194 int size = r->howto->size;
01195
01196
01197
01198
01199
01200
01201 old_end = ((dot + size ) & ~size) + size+1;
01202
01203
01204 new_end = ((dot - shrink + size) & ~size);
01205
01206
01207 gap = old_end - ((dot + size) & ~size);
01208
01209 shrink_delta = (old_end - new_end) - shrink;
01210
01211 if (shrink_delta)
01212 {
01213
01214 r->howto = howto_done_align_table + (r->howto - howto_align_table);
01215
01216
01217
01218 r->addend = old_end - dot + r->address;
01219
01220
01221 perform_slip (abfd, shrink_delta, input_section, r->address - shrink);
01222 shrink += shrink_delta;
01223 }
01224
01225 return shrink;
01226 }
01227
01228 static bfd_boolean
01229 b_out_bfd_relax_section (abfd, i, link_info, again)
01230 bfd *abfd;
01231 asection *i;
01232 struct bfd_link_info *link_info;
01233 bfd_boolean *again;
01234 {
01235
01236 bfd *input_bfd = i->owner;
01237 asection *input_section = i;
01238 unsigned int shrink = 0 ;
01239 arelent **reloc_vector = NULL;
01240 long reloc_size = bfd_get_reloc_upper_bound (input_bfd,
01241 input_section);
01242
01243 if (reloc_size < 0)
01244 return FALSE;
01245
01246
01247
01248 *again = FALSE;
01249
01250 if (reloc_size)
01251 {
01252 long reloc_count;
01253
01254 reloc_vector = (arelent **) bfd_malloc ((bfd_size_type) reloc_size);
01255 if (reloc_vector == NULL && reloc_size != 0)
01256 goto error_return;
01257
01258
01259 reloc_count =
01260 bfd_canonicalize_reloc (input_bfd, input_section, reloc_vector,
01261 _bfd_generic_link_get_symbols (input_bfd));
01262 if (reloc_count < 0)
01263 goto error_return;
01264 if (reloc_count > 0)
01265 {
01266 arelent **parent;
01267
01268 for (parent = reloc_vector; *parent; parent++)
01269 {
01270 arelent *r = *parent;
01271
01272 switch (r->howto->type)
01273 {
01274 case ALIGNER:
01275
01276 shrink = aligncode (abfd, input_section, r, shrink);
01277 break;
01278 case ABS32CODE:
01279
01280 shrink = abs32code (input_bfd, input_section, r, shrink,
01281 link_info);
01282 break;
01283 case ABS32CODE_SHRUNK:
01284 shrink += 4;
01285 break;
01286 }
01287 }
01288 }
01289 }
01290 input_section->size -= shrink;
01291
01292 if (reloc_vector != NULL)
01293 free (reloc_vector);
01294 return TRUE;
01295 error_return:
01296 if (reloc_vector != NULL)
01297 free (reloc_vector);
01298 return FALSE;
01299 }
01300
01301 static bfd_byte *
01302 b_out_bfd_get_relocated_section_contents (output_bfd, link_info, link_order,
01303 data, relocatable, symbols)
01304 bfd *output_bfd;
01305 struct bfd_link_info *link_info;
01306 struct bfd_link_order *link_order;
01307 bfd_byte *data;
01308 bfd_boolean relocatable;
01309 asymbol **symbols;
01310 {
01311
01312 bfd *input_bfd = link_order->u.indirect.section->owner;
01313 asection *input_section = link_order->u.indirect.section;
01314 long reloc_size = bfd_get_reloc_upper_bound (input_bfd,
01315 input_section);
01316 arelent **reloc_vector = NULL;
01317 long reloc_count;
01318
01319 if (reloc_size < 0)
01320 goto error_return;
01321
01322
01323 if (relocatable)
01324 return bfd_generic_get_relocated_section_contents (output_bfd, link_info,
01325 link_order,
01326 data, relocatable,
01327 symbols);
01328
01329 reloc_vector = (arelent **) bfd_malloc ((bfd_size_type) reloc_size);
01330 if (reloc_vector == NULL && reloc_size != 0)
01331 goto error_return;
01332
01333
01334 BFD_ASSERT (bfd_get_section_contents (input_bfd,
01335 input_section,
01336 data,
01337 (bfd_vma) 0,
01338 input_section->size));
01339
01340 reloc_count = bfd_canonicalize_reloc (input_bfd,
01341 input_section,
01342 reloc_vector,
01343 symbols);
01344 if (reloc_count < 0)
01345 goto error_return;
01346 if (reloc_count > 0)
01347 {
01348 arelent **parent = reloc_vector;
01349 arelent *reloc ;
01350 unsigned int dst_address = 0;
01351 unsigned int src_address = 0;
01352 unsigned int run;
01353 unsigned int idx;
01354
01355
01356 while (dst_address < link_order->size)
01357 {
01358 reloc = *parent;
01359 if (reloc)
01360 {
01361
01362
01363
01364 BFD_ASSERT (reloc->address >= src_address);
01365 run = reloc->address - src_address;
01366 parent++;
01367 }
01368 else
01369 {
01370 run = link_order->size - dst_address;
01371 }
01372
01373
01374 for (idx = 0; idx < run; idx++)
01375 data[dst_address++] = data[src_address++];
01376
01377
01378 if (reloc)
01379 {
01380 switch (reloc->howto->type)
01381 {
01382 case ABS32CODE:
01383 calljx_callback (input_bfd, link_info, reloc,
01384 src_address + data, dst_address + data,
01385 input_section);
01386 src_address += 4;
01387 dst_address += 4;
01388 break;
01389 case ABS32:
01390 bfd_put_32 (input_bfd,
01391 (bfd_get_32 (input_bfd, data + src_address)
01392 + get_value (reloc, link_info, input_section)),
01393 data + dst_address);
01394 src_address += 4;
01395 dst_address += 4;
01396 break;
01397 case CALLJ:
01398 callj_callback (input_bfd, link_info, reloc, data,
01399 src_address, dst_address, input_section,
01400 FALSE);
01401 src_address += 4;
01402 dst_address += 4;
01403 break;
01404 case ALIGNDONE:
01405 BFD_ASSERT (reloc->addend >= src_address);
01406 BFD_ASSERT ((bfd_vma) reloc->addend
01407 <= input_section->size);
01408 src_address = reloc->addend;
01409 dst_address = ((dst_address + reloc->howto->size)
01410 & ~reloc->howto->size);
01411 break;
01412 case ABS32CODE_SHRUNK:
01413
01414
01415 callj_callback (input_bfd, link_info, reloc, data,
01416 src_address + 4, dst_address, input_section,
01417 TRUE);
01418 dst_address += 4;
01419 src_address += 8;
01420 break;
01421 case PCREL24:
01422 {
01423 long int word = bfd_get_32 (input_bfd,
01424 data + src_address);
01425 bfd_vma value;
01426
01427 value = get_value (reloc, link_info, input_section);
01428 word = ((word & ~BAL_MASK)
01429 | (((word & BAL_MASK)
01430 + value
01431 - output_addr (input_section)
01432 + reloc->addend)
01433 & BAL_MASK));
01434
01435 bfd_put_32 (input_bfd, (bfd_vma) word, data + dst_address);
01436 dst_address += 4;
01437 src_address += 4;
01438
01439 }
01440 break;
01441 case PCREL13:
01442 {
01443 long int word = bfd_get_32 (input_bfd,
01444 data + src_address);
01445 bfd_vma value;
01446
01447 value = get_value (reloc, link_info, input_section);
01448 word = ((word & ~PCREL13_MASK)
01449 | (((word & PCREL13_MASK)
01450 + value
01451 + reloc->addend
01452 - output_addr (input_section))
01453 & PCREL13_MASK));
01454
01455 bfd_put_32 (input_bfd, (bfd_vma) word, data + dst_address);
01456 dst_address += 4;
01457 src_address += 4;
01458 }
01459 break;
01460
01461 default:
01462 abort ();
01463 }
01464 }
01465 }
01466 }
01467 if (reloc_vector != NULL)
01468 free (reloc_vector);
01469 return data;
01470 error_return:
01471 if (reloc_vector != NULL)
01472 free (reloc_vector);
01473 return NULL;
01474 }
01475
01476
01477
01478
01479 #define aout_32_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol
01480 #define aout_32_close_and_cleanup aout_32_bfd_free_cached_info
01481
01482 #define b_out_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
01483 #define b_out_bfd_link_hash_table_free _bfd_generic_link_hash_table_free
01484 #define b_out_bfd_link_add_symbols _bfd_generic_link_add_symbols
01485 #define b_out_bfd_link_just_syms _bfd_generic_link_just_syms
01486 #define b_out_bfd_final_link _bfd_generic_final_link
01487 #define b_out_bfd_link_split_section _bfd_generic_link_split_section
01488 #define b_out_bfd_gc_sections bfd_generic_gc_sections
01489 #define b_out_bfd_merge_sections bfd_generic_merge_sections
01490 #define b_out_bfd_is_group_section bfd_generic_is_group_section
01491 #define b_out_bfd_discard_group bfd_generic_discard_group
01492 #define b_out_section_already_linked \
01493 _bfd_generic_section_already_linked
01494
01495 #define aout_32_get_section_contents_in_window \
01496 _bfd_generic_get_section_contents_in_window
01497
01498 extern const bfd_target b_out_vec_little_host;
01499
01500 const bfd_target b_out_vec_big_host =
01501 {
01502 "b.out.big",
01503 bfd_target_aout_flavour,
01504 BFD_ENDIAN_LITTLE,
01505 BFD_ENDIAN_BIG,
01506 (HAS_RELOC | EXEC_P |
01507 HAS_LINENO | HAS_DEBUG |
01508 HAS_SYMS | HAS_LOCALS | WP_TEXT | BFD_IS_RELAXABLE ),
01509 (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC | SEC_CODE | SEC_DATA),
01510 '_',
01511 ' ',
01512 16,
01513
01514 bfd_getl64, bfd_getl_signed_64, bfd_putl64,
01515 bfd_getl32, bfd_getl_signed_32, bfd_putl32,
01516 bfd_getl16, bfd_getl_signed_16, bfd_putl16,
01517 bfd_getb64, bfd_getb_signed_64, bfd_putb64,
01518 bfd_getb32, bfd_getb_signed_32, bfd_putb32,
01519 bfd_getb16, bfd_getb_signed_16, bfd_putb16,
01520 {_bfd_dummy_target, b_out_object_p,
01521 bfd_generic_archive_p, _bfd_dummy_target},
01522 {bfd_false, b_out_mkobject,
01523 _bfd_generic_mkarchive, bfd_false},
01524 {bfd_false, b_out_write_object_contents,
01525 _bfd_write_archive_contents, bfd_false},
01526
01527 BFD_JUMP_TABLE_GENERIC (aout_32),
01528 BFD_JUMP_TABLE_COPY (_bfd_generic),
01529 BFD_JUMP_TABLE_CORE (_bfd_nocore),
01530 BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_bsd),
01531 BFD_JUMP_TABLE_SYMBOLS (aout_32),
01532 BFD_JUMP_TABLE_RELOCS (b_out),
01533 BFD_JUMP_TABLE_WRITE (b_out),
01534 BFD_JUMP_TABLE_LINK (b_out),
01535 BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
01536
01537 & b_out_vec_little_host,
01538
01539 (PTR) 0,
01540 };
01541
01542 const bfd_target b_out_vec_little_host =
01543 {
01544 "b.out.little",
01545 bfd_target_aout_flavour,
01546 BFD_ENDIAN_LITTLE,
01547 BFD_ENDIAN_LITTLE,
01548 (HAS_RELOC | EXEC_P |
01549 HAS_LINENO | HAS_DEBUG |
01550 HAS_SYMS | HAS_LOCALS | WP_TEXT | BFD_IS_RELAXABLE ),
01551 (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC | SEC_CODE | SEC_DATA),
01552 '_',
01553 ' ',
01554 16,
01555 bfd_getl64, bfd_getl_signed_64, bfd_putl64,
01556 bfd_getl32, bfd_getl_signed_32, bfd_putl32,
01557 bfd_getl16, bfd_getl_signed_16, bfd_putl16,
01558 bfd_getl64, bfd_getl_signed_64, bfd_putl64,
01559 bfd_getl32, bfd_getl_signed_32, bfd_putl32,
01560 bfd_getl16, bfd_getl_signed_16, bfd_putl16,
01561
01562 {_bfd_dummy_target, b_out_object_p,
01563 bfd_generic_archive_p, _bfd_dummy_target},
01564 {bfd_false, b_out_mkobject,
01565 _bfd_generic_mkarchive, bfd_false},
01566 {bfd_false, b_out_write_object_contents,
01567 _bfd_write_archive_contents, bfd_false},
01568
01569 BFD_JUMP_TABLE_GENERIC (aout_32),
01570 BFD_JUMP_TABLE_COPY (_bfd_generic),
01571 BFD_JUMP_TABLE_CORE (_bfd_nocore),
01572 BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_bsd),
01573 BFD_JUMP_TABLE_SYMBOLS (aout_32),
01574 BFD_JUMP_TABLE_RELOCS (b_out),
01575 BFD_JUMP_TABLE_WRITE (b_out),
01576 BFD_JUMP_TABLE_LINK (b_out),
01577 BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
01578
01579 & b_out_vec_big_host,
01580
01581 (PTR) 0
01582 };