Add bfd_free_cached_info support to a.out backends.
[deliverable/binutils-gdb.git] / bfd / bout.c
1 /* BFD back-end for Intel 960 b.out binaries.
2 Copyright 1990, 1991, 1992, 1993 Free Software Foundation, Inc.
3 Written by Cygnus Support.
4
5 This file is part of BFD, the Binary File Descriptor library.
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
20
21
22 #include "bfd.h"
23 #include "sysdep.h"
24 #include "libbfd.h"
25 #include "bfdlink.h"
26 #include "genlink.h"
27 #include "bout.h"
28
29 #include "aout/stab_gnu.h"
30 #include "libaout.h" /* BFD a.out internal data structures */
31
32
33 static int aligncode PARAMS ((bfd *abfd, asection *input_section,
34 arelent *r, unsigned int shrink));
35 static void perform_slip PARAMS ((bfd *abfd, unsigned int slip,
36 asection *input_section, bfd_vma value));
37 static boolean b_out_squirt_out_relocs PARAMS ((bfd *abfd, asection *section));
38 static bfd_target *b_out_callback PARAMS ((bfd *));
39 static bfd_reloc_status_type calljx_callback
40 PARAMS ((bfd *, struct bfd_link_info *, arelent *, PTR src, PTR dst,
41 asection *));
42 static bfd_reloc_status_type callj_callback
43 PARAMS ((bfd *, struct bfd_link_info *, arelent *, PTR data,
44 unsigned int srcidx, unsigned int dstidx, asection *));
45 static bfd_vma get_value PARAMS ((arelent *, struct bfd_link_info *,
46 asection *));
47 static int abs32code PARAMS ((bfd *, asection *, arelent *,
48 unsigned int, struct bfd_link_info *));
49 static boolean b_out_relax_section PARAMS ((bfd *, asection *,
50 struct bfd_link_info *,
51 boolean *));
52 static bfd_byte *b_out_get_relocated_section_contents
53 PARAMS ((bfd *, struct bfd_link_info *, struct bfd_link_order *,
54 bfd_byte *, boolean, asymbol **));
55
56 /* Swaps the information in an executable header taken from a raw byte
57 stream memory image, into the internal exec_header structure. */
58
59 void
60 bout_swap_exec_header_in (abfd, raw_bytes, execp)
61 bfd *abfd;
62 struct external_exec *raw_bytes;
63 struct internal_exec *execp;
64 {
65 struct external_exec *bytes = (struct external_exec *)raw_bytes;
66
67 /* Now fill in fields in the execp, from the bytes in the raw data. */
68 execp->a_info = bfd_h_get_32 (abfd, bytes->e_info);
69 execp->a_text = GET_WORD (abfd, bytes->e_text);
70 execp->a_data = GET_WORD (abfd, bytes->e_data);
71 execp->a_bss = GET_WORD (abfd, bytes->e_bss);
72 execp->a_syms = GET_WORD (abfd, bytes->e_syms);
73 execp->a_entry = GET_WORD (abfd, bytes->e_entry);
74 execp->a_trsize = GET_WORD (abfd, bytes->e_trsize);
75 execp->a_drsize = GET_WORD (abfd, bytes->e_drsize);
76 execp->a_tload = GET_WORD (abfd, bytes->e_tload);
77 execp->a_dload = GET_WORD (abfd, bytes->e_dload);
78 execp->a_talign = bytes->e_talign[0];
79 execp->a_dalign = bytes->e_dalign[0];
80 execp->a_balign = bytes->e_balign[0];
81 execp->a_relaxable = bytes->e_relaxable[0];
82 }
83
84 /* Swaps the information in an internal exec header structure into the
85 supplied buffer ready for writing to disk. */
86
87 PROTO(void, bout_swap_exec_header_out,
88 (bfd *abfd,
89 struct internal_exec *execp,
90 struct external_exec *raw_bytes));
91 void
92 bout_swap_exec_header_out (abfd, execp, raw_bytes)
93 bfd *abfd;
94 struct internal_exec *execp;
95 struct external_exec *raw_bytes;
96 {
97 struct external_exec *bytes = (struct external_exec *)raw_bytes;
98
99 /* Now fill in fields in the raw data, from the fields in the exec struct. */
100 bfd_h_put_32 (abfd, execp->a_info , bytes->e_info);
101 PUT_WORD (abfd, execp->a_text , bytes->e_text);
102 PUT_WORD (abfd, execp->a_data , bytes->e_data);
103 PUT_WORD (abfd, execp->a_bss , bytes->e_bss);
104 PUT_WORD (abfd, execp->a_syms , bytes->e_syms);
105 PUT_WORD (abfd, execp->a_entry , bytes->e_entry);
106 PUT_WORD (abfd, execp->a_trsize, bytes->e_trsize);
107 PUT_WORD (abfd, execp->a_drsize, bytes->e_drsize);
108 PUT_WORD (abfd, execp->a_tload , bytes->e_tload);
109 PUT_WORD (abfd, execp->a_dload , bytes->e_dload);
110 bytes->e_talign[0] = execp->a_talign;
111 bytes->e_dalign[0] = execp->a_dalign;
112 bytes->e_balign[0] = execp->a_balign;
113 bytes->e_relaxable[0] = execp->a_relaxable;
114 }
115
116
117 static bfd_target *
118 b_out_object_p (abfd)
119 bfd *abfd;
120 {
121 struct internal_exec anexec;
122 struct external_exec exec_bytes;
123
124 if (bfd_read ((PTR) &exec_bytes, 1, EXEC_BYTES_SIZE, abfd)
125 != EXEC_BYTES_SIZE) {
126 bfd_set_error (bfd_error_wrong_format);
127 return 0;
128 }
129
130 anexec.a_info = bfd_h_get_32 (abfd, exec_bytes.e_info);
131
132 if (N_BADMAG (anexec)) {
133 bfd_set_error (bfd_error_wrong_format);
134 return 0;
135 }
136
137 bout_swap_exec_header_in (abfd, &exec_bytes, &anexec);
138 return aout_32_some_aout_object_p (abfd, &anexec, b_out_callback);
139 }
140
141
142 /* Finish up the opening of a b.out file for reading. Fill in all the
143 fields that are not handled by common code. */
144
145 static bfd_target *
146 b_out_callback (abfd)
147 bfd *abfd;
148 {
149 struct internal_exec *execp = exec_hdr (abfd);
150 unsigned long bss_start;
151
152 /* Architecture and machine type */
153 bfd_set_arch_mach(abfd,
154 bfd_arch_i960, /* B.out only used on i960 */
155 bfd_mach_i960_core /* Default */
156 );
157
158 /* The positions of the string table and symbol table. */
159 obj_str_filepos (abfd) = N_STROFF (*execp);
160 obj_sym_filepos (abfd) = N_SYMOFF (*execp);
161
162 /* The alignments of the sections */
163 obj_textsec (abfd)->alignment_power = execp->a_talign;
164 obj_datasec (abfd)->alignment_power = execp->a_dalign;
165 obj_bsssec (abfd)->alignment_power = execp->a_balign;
166
167 /* The starting addresses of the sections. */
168 obj_textsec (abfd)->vma = execp->a_tload;
169 obj_datasec (abfd)->vma = execp->a_dload;
170
171 /* And reload the sizes, since the aout module zaps them */
172 obj_textsec (abfd)->_raw_size = execp->a_text;
173
174 bss_start = execp->a_dload + execp->a_data; /* BSS = end of data section */
175 obj_bsssec (abfd)->vma = align_power (bss_start, execp->a_balign);
176
177 /* The file positions of the sections */
178 obj_textsec (abfd)->filepos = N_TXTOFF(*execp);
179 obj_datasec (abfd)->filepos = N_DATOFF(*execp);
180
181 /* The file positions of the relocation info */
182 obj_textsec (abfd)->rel_filepos = N_TROFF(*execp);
183 obj_datasec (abfd)->rel_filepos = N_DROFF(*execp);
184
185 adata(abfd).page_size = 1; /* Not applicable. */
186 adata(abfd).segment_size = 1; /* Not applicable. */
187 adata(abfd).exec_bytes_size = EXEC_BYTES_SIZE;
188
189 if (execp->a_relaxable)
190 abfd->flags |= BFD_IS_RELAXABLE;
191 return abfd->xvec;
192 }
193
194 struct bout_data_struct {
195 struct aoutdata a;
196 struct internal_exec e;
197 };
198
199 static boolean
200 b_out_mkobject (abfd)
201 bfd *abfd;
202 {
203 struct bout_data_struct *rawptr;
204
205 rawptr = (struct bout_data_struct *) bfd_zalloc (abfd, sizeof (struct bout_data_struct));
206 if (rawptr == NULL) {
207 bfd_set_error (bfd_error_no_memory);
208 return false;
209 }
210
211 abfd->tdata.bout_data = rawptr;
212 exec_hdr (abfd) = &rawptr->e;
213
214 /* For simplicity's sake we just make all the sections right here. */
215 obj_textsec (abfd) = (asection *)NULL;
216 obj_datasec (abfd) = (asection *)NULL;
217 obj_bsssec (abfd) = (asection *)NULL;
218
219 bfd_make_section (abfd, ".text");
220 bfd_make_section (abfd, ".data");
221 bfd_make_section (abfd, ".bss");
222
223 return true;
224 }
225
226 static boolean
227 b_out_write_object_contents (abfd)
228 bfd *abfd;
229 {
230 struct external_exec swapped_hdr;
231
232 exec_hdr (abfd)->a_info = BMAGIC;
233
234 exec_hdr (abfd)->a_text = obj_textsec (abfd)->_raw_size;
235 exec_hdr (abfd)->a_data = obj_datasec (abfd)->_raw_size;
236 exec_hdr (abfd)->a_bss = obj_bsssec (abfd)->_raw_size;
237 exec_hdr (abfd)->a_syms = bfd_get_symcount (abfd) * sizeof (struct nlist);
238 exec_hdr (abfd)->a_entry = bfd_get_start_address (abfd);
239 exec_hdr (abfd)->a_trsize = ((obj_textsec (abfd)->reloc_count) *
240 sizeof (struct relocation_info));
241 exec_hdr (abfd)->a_drsize = ((obj_datasec (abfd)->reloc_count) *
242 sizeof (struct relocation_info));
243
244 exec_hdr (abfd)->a_talign = obj_textsec (abfd)->alignment_power;
245 exec_hdr (abfd)->a_dalign = obj_datasec (abfd)->alignment_power;
246 exec_hdr (abfd)->a_balign = obj_bsssec (abfd)->alignment_power;
247
248 exec_hdr (abfd)->a_tload = obj_textsec (abfd)->vma;
249 exec_hdr (abfd)->a_dload = obj_datasec (abfd)->vma;
250
251 bout_swap_exec_header_out (abfd, exec_hdr (abfd), &swapped_hdr);
252
253 bfd_seek (abfd, (file_ptr) 0, SEEK_SET);
254 bfd_write ((PTR) &swapped_hdr, 1, EXEC_BYTES_SIZE, abfd);
255
256 /* Now write out reloc info, followed by syms and strings */
257 if (bfd_get_symcount (abfd) != 0)
258 {
259 bfd_seek (abfd, (file_ptr)(N_SYMOFF(*exec_hdr(abfd))), SEEK_SET);
260
261 if (! aout_32_write_syms (abfd))
262 return false;
263
264 bfd_seek (abfd, (file_ptr)(N_TROFF(*exec_hdr(abfd))), SEEK_SET);
265
266 if (!b_out_squirt_out_relocs (abfd, obj_textsec (abfd))) return false;
267 bfd_seek (abfd, (file_ptr)(N_DROFF(*exec_hdr(abfd))), SEEK_SET);
268
269 if (!b_out_squirt_out_relocs (abfd, obj_datasec (abfd))) return false;
270 }
271 return true;
272 }
273 \f
274 /** Some reloc hackery */
275
276 #define CALLS 0x66003800 /* Template for 'calls' instruction */
277 #define BAL 0x0b000000 /* Template for 'bal' instruction */
278 #define BALX 0x85000000 /* Template for 'balx' instruction */
279 #define BAL_MASK 0x00ffffff
280 #define CALL 0x09000000
281 #define PCREL13_MASK 0x1fff
282
283
284 #define output_addr(sec) ((sec)->output_offset+(sec)->output_section->vma)
285
286 /* Magic to turn callx into calljx */
287 static bfd_reloc_status_type
288 calljx_callback (abfd, link_info, reloc_entry, src, dst, input_section)
289 bfd *abfd;
290 struct bfd_link_info *link_info;
291 arelent *reloc_entry;
292 PTR src;
293 PTR dst;
294 asection *input_section;
295 {
296 int word = bfd_get_32 (abfd, src);
297 asymbol *symbol_in = *(reloc_entry->sym_ptr_ptr);
298 aout_symbol_type *symbol = aout_symbol (symbol_in);
299 bfd_vma value;
300
301 value = get_value (reloc_entry, link_info, input_section);
302
303 if (IS_CALLNAME (symbol->other))
304 {
305 aout_symbol_type *balsym = symbol+1;
306 int inst = bfd_get_32 (abfd, (bfd_byte *) src-4);
307 /* The next symbol should be an N_BALNAME */
308 BFD_ASSERT (IS_BALNAME (balsym->other));
309 inst &= BAL_MASK;
310 inst |= BALX;
311 bfd_put_32 (abfd, inst, (bfd_byte *) dst-4);
312 symbol = balsym;
313 value = (symbol->symbol.value
314 + output_addr (symbol->symbol.section));
315 }
316
317 word += value + reloc_entry->addend;
318
319 bfd_put_32(abfd, word, dst);
320 return bfd_reloc_ok;
321 }
322
323
324 /* Magic to turn call into callj */
325 static bfd_reloc_status_type
326 callj_callback (abfd, link_info, reloc_entry, data, srcidx, dstidx,
327 input_section)
328 bfd *abfd;
329 struct bfd_link_info *link_info;
330 arelent *reloc_entry;
331 PTR data;
332 unsigned int srcidx;
333 unsigned int dstidx;
334 asection *input_section;
335 {
336 int word = bfd_get_32 (abfd, (bfd_byte *) data + srcidx);
337 asymbol *symbol_in = *(reloc_entry->sym_ptr_ptr);
338 aout_symbol_type *symbol = aout_symbol (symbol_in);
339 bfd_vma value;
340
341 value = get_value (reloc_entry, link_info, input_section);
342
343 if (IS_OTHER(symbol->other))
344 {
345 /* Call to a system procedure - replace code with system
346 procedure number. */
347 word = CALLS | (symbol->other - 1);
348 }
349 else if (IS_CALLNAME(symbol->other))
350 {
351 aout_symbol_type *balsym = symbol+1;
352
353 /* The next symbol should be an N_BALNAME. */
354 BFD_ASSERT(IS_BALNAME(balsym->other));
355
356 /* We are calling a leaf, so replace the call instruction with a
357 bal. */
358 word = BAL | ((word
359 + output_addr (balsym->symbol.section)
360 + balsym->symbol.value + reloc_entry->addend
361 - dstidx
362 - output_addr (input_section))
363 & BAL_MASK);
364 }
365 else
366 {
367 word = CALL | (((word & BAL_MASK)
368 + value
369 + reloc_entry->addend
370 - dstidx
371 - output_addr (input_section))
372 & BAL_MASK);
373 }
374 bfd_put_32(abfd, word, (bfd_byte *) data + dstidx);
375 return bfd_reloc_ok;
376 }
377
378 /* type rshift size bitsize pcrel bitpos absolute overflow check*/
379
380 #define ABS32CODE 0
381 #define ABS32CODE_SHRUNK 1
382 #define PCREL24 2
383 #define CALLJ 3
384 #define ABS32 4
385 #define PCREL13 5
386 #define ABS32_MAYBE_RELAXABLE 1
387 #define ABS32_WAS_RELAXABLE 2
388
389 #define ALIGNER 10
390 #define ALIGNDONE 11
391 static reloc_howto_type howto_reloc_callj =
392 HOWTO(CALLJ, 0, 2, 24, true, 0, complain_overflow_signed, 0,"callj", true, 0x00ffffff, 0x00ffffff,false);
393 static reloc_howto_type howto_reloc_abs32 =
394 HOWTO(ABS32, 0, 2, 32, false, 0, complain_overflow_bitfield,0,"abs32", true, 0xffffffff,0xffffffff,false);
395 static reloc_howto_type howto_reloc_pcrel24 =
396 HOWTO(PCREL24, 0, 2, 24, true, 0, complain_overflow_signed,0,"pcrel24", true, 0x00ffffff,0x00ffffff,false);
397
398 static reloc_howto_type howto_reloc_pcrel13 =
399 HOWTO(PCREL13, 0, 2, 13, true, 0, complain_overflow_signed,0,"pcrel13", true, 0x00001fff,0x00001fff,false);
400
401
402 static reloc_howto_type howto_reloc_abs32codeshrunk =
403 HOWTO(ABS32CODE_SHRUNK, 0, 2, 24, true, 0, complain_overflow_signed, 0,"callx->callj", true, 0x00ffffff, 0x00ffffff,false);
404
405 static reloc_howto_type howto_reloc_abs32code =
406 HOWTO(ABS32CODE, 0, 2, 32, false, 0, complain_overflow_bitfield,0,"callx", true, 0xffffffff,0xffffffff,false);
407
408 static reloc_howto_type howto_align_table[] = {
409 HOWTO (ALIGNER, 0, 0x1, 0, false, 0, complain_overflow_dont, 0, "align16", false, 0, 0, false),
410 HOWTO (ALIGNER, 0, 0x3, 0, false, 0, complain_overflow_dont, 0, "align32", false, 0, 0, false),
411 HOWTO (ALIGNER, 0, 0x7, 0, false, 0, complain_overflow_dont, 0, "align64", false, 0, 0, false),
412 HOWTO (ALIGNER, 0, 0xf, 0, false, 0, complain_overflow_dont, 0, "align128", false, 0, 0, false),
413 };
414
415 static reloc_howto_type howto_done_align_table[] = {
416 HOWTO (ALIGNDONE, 0x1, 0x1, 0, false, 0, complain_overflow_dont, 0, "donealign16", false, 0, 0, false),
417 HOWTO (ALIGNDONE, 0x3, 0x3, 0, false, 0, complain_overflow_dont, 0, "donealign32", false, 0, 0, false),
418 HOWTO (ALIGNDONE, 0x7, 0x7, 0, false, 0, complain_overflow_dont, 0, "donealign64", false, 0, 0, false),
419 HOWTO (ALIGNDONE, 0xf, 0xf, 0, false, 0, complain_overflow_dont, 0, "donealign128", false, 0, 0, false),
420 };
421
422 static const reloc_howto_type *
423 b_out_reloc_type_lookup (abfd, code)
424 bfd *abfd;
425 bfd_reloc_code_real_type code;
426 {
427 switch (code)
428 {
429 default:
430 return 0;
431 case BFD_RELOC_I960_CALLJ:
432 return &howto_reloc_callj;
433 case BFD_RELOC_32:
434 return &howto_reloc_abs32;
435 case BFD_RELOC_24_PCREL:
436 return &howto_reloc_pcrel24;
437 }
438 }
439
440 /* Allocate enough room for all the reloc entries, plus pointers to them all */
441
442 static boolean
443 b_out_slurp_reloc_table (abfd, asect, symbols)
444 bfd *abfd;
445 sec_ptr asect;
446 asymbol **symbols;
447 {
448 register struct relocation_info *rptr;
449 unsigned int counter ;
450 arelent *cache_ptr ;
451 int extern_mask, pcrel_mask, callj_mask, length_shift;
452 int incode_mask;
453 int size_mask;
454 bfd_vma prev_addr = 0;
455 unsigned int count;
456 size_t reloc_size;
457 struct relocation_info *relocs;
458 arelent *reloc_cache;
459
460 if (asect->relocation)
461 return true;
462 if (!aout_32_slurp_symbol_table (abfd))
463 return false;
464
465 if (asect == obj_datasec (abfd)) {
466 reloc_size = exec_hdr(abfd)->a_drsize;
467 goto doit;
468 }
469
470 if (asect == obj_textsec (abfd)) {
471 reloc_size = exec_hdr(abfd)->a_trsize;
472 goto doit;
473 }
474
475 bfd_set_error (bfd_error_invalid_operation);
476 return false;
477
478 doit:
479 if (bfd_seek (abfd, (file_ptr)(asect->rel_filepos), SEEK_SET) != 0)
480 return false;
481 count = reloc_size / sizeof (struct relocation_info);
482
483 relocs = (struct relocation_info *) malloc (reloc_size);
484 if (!relocs && reloc_size != 0) {
485 bfd_set_error (bfd_error_no_memory);
486 return false;
487 }
488 reloc_cache = (arelent *) malloc ((count+1) * sizeof (arelent));
489 if (!reloc_cache) {
490 free ((char*)relocs);
491 bfd_set_error (bfd_error_no_memory);
492 return false;
493 }
494
495 if (bfd_read ((PTR) relocs, 1, reloc_size, abfd) != reloc_size) {
496 free (reloc_cache);
497 free (relocs);
498 return false;
499 }
500
501
502
503 if (abfd->xvec->header_byteorder_big_p) {
504 /* big-endian bit field allocation order */
505 pcrel_mask = 0x80;
506 extern_mask = 0x10;
507 incode_mask = 0x08;
508 callj_mask = 0x02;
509 size_mask = 0x20;
510 length_shift = 5;
511 } else {
512 /* little-endian bit field allocation order */
513 pcrel_mask = 0x01;
514 extern_mask = 0x08;
515 incode_mask = 0x10;
516 callj_mask = 0x40;
517 size_mask = 0x02;
518 length_shift = 1;
519 }
520
521 for (rptr = relocs, cache_ptr = reloc_cache, counter = 0;
522 counter < count;
523 counter++, rptr++, cache_ptr++)
524 {
525 unsigned char *raw = (unsigned char *)rptr;
526 unsigned int symnum;
527 cache_ptr->address = bfd_h_get_32 (abfd, raw + 0);
528 cache_ptr->howto = 0;
529 if (abfd->xvec->header_byteorder_big_p)
530 {
531 symnum = (raw[4] << 16) | (raw[5] << 8) | raw[6];
532 }
533 else
534 {
535 symnum = (raw[6] << 16) | (raw[5] << 8) | raw[4];
536 }
537
538 if (raw[7] & extern_mask)
539 {
540 /* if this is set then the r_index is a index into the symbol table;
541 * if the bit is not set then r_index contains a section map.
542 * we either fill in the sym entry with a pointer to the symbol,
543 * or point to the correct section
544 */
545 cache_ptr->sym_ptr_ptr = symbols + symnum;
546 cache_ptr->addend = 0;
547 } else
548 {
549 /* in a.out symbols are relative to the beginning of the
550 * file rather than sections ?
551 * (look in translate_from_native_sym_flags)
552 * the reloc entry addend has added to it the offset into the
553 * file of the data, so subtract the base to make the reloc
554 * section relative */
555 int s;
556 {
557 /* sign-extend symnum from 24 bits to whatever host uses */
558 s = symnum;
559 if (s & (1 << 23))
560 s |= (~0) << 24;
561 }
562 cache_ptr->sym_ptr_ptr = (asymbol **)NULL;
563 switch (s)
564 {
565 case N_TEXT:
566 case N_TEXT | N_EXT:
567 cache_ptr->sym_ptr_ptr = obj_textsec(abfd)->symbol_ptr_ptr;
568 cache_ptr->addend = - obj_textsec(abfd)->vma;
569 break;
570 case N_DATA:
571 case N_DATA | N_EXT:
572 cache_ptr->sym_ptr_ptr = obj_datasec(abfd)->symbol_ptr_ptr;
573 cache_ptr->addend = - obj_datasec(abfd)->vma;
574 break;
575 case N_BSS:
576 case N_BSS | N_EXT:
577 cache_ptr->sym_ptr_ptr = obj_bsssec(abfd)->symbol_ptr_ptr;
578 cache_ptr->addend = - obj_bsssec(abfd)->vma;
579 break;
580 case N_ABS:
581 case N_ABS | N_EXT:
582 cache_ptr->sym_ptr_ptr = obj_bsssec(abfd)->symbol_ptr_ptr;
583 cache_ptr->addend = 0;
584 break;
585 case -2: /* .align */
586 if (raw[7] & pcrel_mask)
587 {
588 cache_ptr->howto = &howto_align_table[(raw[7] >> length_shift) & 3];
589 cache_ptr->sym_ptr_ptr = &bfd_abs_symbol;
590 }
591 else
592 {
593 /* .org? */
594 abort ();
595 }
596 cache_ptr->addend = 0;
597 break;
598 default:
599 BFD_ASSERT(0);
600 break;
601 }
602
603 }
604
605 /* the i960 only has a few relocation types:
606 abs 32-bit and pcrel 24bit. except for callj's! */
607 if (cache_ptr->howto != 0)
608 ;
609 else if (raw[7] & callj_mask)
610 {
611 cache_ptr->howto = &howto_reloc_callj;
612 }
613 else if ( raw[7] & pcrel_mask)
614 {
615 if (raw[7] & size_mask)
616 cache_ptr->howto = &howto_reloc_pcrel13;
617 else
618 cache_ptr->howto = &howto_reloc_pcrel24;
619 }
620 else
621 {
622 if (raw[7] & incode_mask)
623 {
624 cache_ptr->howto = &howto_reloc_abs32code;
625 }
626 else
627 {
628 cache_ptr->howto = &howto_reloc_abs32;
629 }
630 }
631 if (cache_ptr->address < prev_addr)
632 {
633 /* Ouch! this reloc is out of order, insert into the right place
634 */
635 arelent tmp;
636 arelent *cursor = cache_ptr-1;
637 bfd_vma stop = cache_ptr->address;
638 tmp = *cache_ptr;
639 while (cursor->address > stop && cursor >= reloc_cache)
640 {
641 cursor[1] = cursor[0];
642 cursor--;
643 }
644 cursor[1] = tmp;
645 }
646 else
647 {
648 prev_addr = cache_ptr->address;
649 }
650 }
651
652
653 free (relocs);
654 asect->relocation = reloc_cache;
655 asect->reloc_count = count;
656
657
658 return true;
659 }
660
661
662 static boolean
663 b_out_squirt_out_relocs (abfd, section)
664 bfd *abfd;
665 asection *section;
666 {
667 arelent **generic;
668 int r_extern = 0;
669 int r_idx;
670 int incode_mask;
671 int len_1;
672 unsigned int count = section->reloc_count;
673 struct relocation_info *native, *natptr;
674 size_t natsize = count * sizeof (struct relocation_info);
675 int extern_mask, pcrel_mask, len_2, callj_mask;
676 if (count == 0) return true;
677 generic = section->orelocation;
678 native = ((struct relocation_info *) malloc (natsize));
679 if (!native && natsize != 0) {
680 bfd_set_error (bfd_error_no_memory);
681 return false;
682 }
683
684 if (abfd->xvec->header_byteorder_big_p)
685 {
686 /* Big-endian bit field allocation order */
687 pcrel_mask = 0x80;
688 extern_mask = 0x10;
689 len_2 = 0x40;
690 len_1 = 0x20;
691 callj_mask = 0x02;
692 incode_mask = 0x08;
693 }
694 else
695 {
696 /* Little-endian bit field allocation order */
697 pcrel_mask = 0x01;
698 extern_mask = 0x08;
699 len_2 = 0x04;
700 len_1 = 0x02;
701 callj_mask = 0x40;
702 incode_mask = 0x10;
703 }
704
705 for (natptr = native; count > 0; --count, ++natptr, ++generic)
706 {
707 arelent *g = *generic;
708 unsigned char *raw = (unsigned char *)natptr;
709 asymbol *sym = *(g->sym_ptr_ptr);
710
711 asection *output_section = sym->section->output_section;
712
713 bfd_h_put_32(abfd, g->address, raw);
714 /* Find a type in the output format which matches the input howto -
715 * at the moment we assume input format == output format FIXME!!
716 */
717 r_idx = 0;
718 /* FIXME: Need callj stuff here, and to check the howto entries to
719 be sure they are real for this architecture. */
720 if (g->howto== &howto_reloc_callj)
721 {
722 raw[7] = callj_mask + pcrel_mask + len_2;
723 }
724 else if (g->howto == &howto_reloc_pcrel24)
725 {
726 raw[7] = pcrel_mask + len_2;
727 }
728 else if (g->howto == &howto_reloc_pcrel13)
729 {
730 raw[7] = pcrel_mask + len_1;
731 }
732 else if (g->howto == &howto_reloc_abs32code)
733 {
734 raw[7] = len_2 + incode_mask;
735 }
736 else if (g->howto >= howto_align_table
737 && g->howto <= (howto_align_table
738 + sizeof (howto_align_table) / sizeof (howto_align_table[0])
739 - 1))
740 {
741 /* symnum == -2; extern_mask not set, pcrel_mask set */
742 r_idx = -2;
743 r_extern = 0;
744 raw[7] = (pcrel_mask
745 | ((g->howto - howto_align_table) << 1));
746 }
747 else {
748 raw[7] = len_2;
749 }
750
751 if (r_idx != 0)
752 /* already mucked with r_extern, r_idx */;
753 else if (bfd_is_com_section (output_section)
754 || output_section == &bfd_abs_section
755 || output_section == &bfd_und_section)
756 {
757
758 if (bfd_abs_section.symbol == sym)
759 {
760 /* Whoops, looked like an abs symbol, but is really an offset
761 from the abs section */
762 r_idx = 0;
763 r_extern = 0;
764 }
765 else
766 {
767 /* Fill in symbol */
768
769 r_extern = 1;
770 r_idx = stoi((*(g->sym_ptr_ptr))->flags);
771 }
772 }
773 else
774 {
775 /* Just an ordinary section */
776 r_extern = 0;
777 r_idx = output_section->target_index;
778 }
779
780 if (abfd->xvec->header_byteorder_big_p) {
781 raw[4] = (unsigned char) (r_idx >> 16);
782 raw[5] = (unsigned char) (r_idx >> 8);
783 raw[6] = (unsigned char) (r_idx );
784 } else {
785 raw[6] = (unsigned char) (r_idx >> 16);
786 raw[5] = (unsigned char) (r_idx>> 8);
787 raw[4] = (unsigned char) (r_idx );
788 }
789 if (r_extern)
790 raw[7] |= extern_mask;
791 }
792
793 if (bfd_write ((PTR) native, 1, natsize, abfd) != natsize) {
794 free((PTR)native);
795 return false;
796 }
797 free ((PTR)native);
798
799 return true;
800 }
801
802 /* This is stupid. This function should be a boolean predicate */
803 static long
804 b_out_canonicalize_reloc (abfd, section, relptr, symbols)
805 bfd *abfd;
806 sec_ptr section;
807 arelent **relptr;
808 asymbol **symbols;
809 {
810 arelent *tblptr = section->relocation;
811 unsigned int count = 0;
812
813 if (!(tblptr || b_out_slurp_reloc_table (abfd, section, symbols)))
814 return -1;
815 tblptr = section->relocation;
816 if (!tblptr)
817 return -1;
818
819 for (; count++ < section->reloc_count;)
820 *relptr++ = tblptr++;
821
822 *relptr = 0;
823
824 return section->reloc_count;
825 }
826
827 static long
828 b_out_get_reloc_upper_bound (abfd, asect)
829 bfd *abfd;
830 sec_ptr asect;
831 {
832 if (bfd_get_format (abfd) != bfd_object) {
833 bfd_set_error (bfd_error_invalid_operation);
834 return -1;
835 }
836
837 if (asect == obj_datasec (abfd))
838 return (sizeof (arelent *) *
839 ((exec_hdr(abfd)->a_drsize / sizeof (struct relocation_info))
840 +1));
841
842 if (asect == obj_textsec (abfd))
843 return (sizeof (arelent *) *
844 ((exec_hdr(abfd)->a_trsize / sizeof (struct relocation_info))
845 +1));
846
847 if (asect == obj_bsssec (abfd))
848 return 0;
849
850 bfd_set_error (bfd_error_invalid_operation);
851 return -1;
852 }
853 \f
854 static boolean
855 b_out_set_section_contents (abfd, section, location, offset, count)
856 bfd *abfd;
857 sec_ptr section;
858 unsigned char *location;
859 file_ptr offset;
860 int count;
861 {
862
863 if (abfd->output_has_begun == false) { /* set by bfd.c handler */
864 if ((obj_textsec (abfd) == NULL) || (obj_datasec (abfd) == NULL) /*||
865 (obj_textsec (abfd)->_cooked_size == 0) || (obj_datasec (abfd)->_cooked_size == 0)*/) {
866 bfd_set_error (bfd_error_invalid_operation);
867 return false;
868 }
869
870 obj_textsec (abfd)->filepos = sizeof(struct internal_exec);
871 obj_datasec(abfd)->filepos = obj_textsec(abfd)->filepos
872 + obj_textsec (abfd)->_raw_size;
873
874 }
875 /* regardless, once we know what we're doing, we might as well get going */
876 bfd_seek (abfd, section->filepos + offset, SEEK_SET);
877
878 if (count != 0) {
879 return (bfd_write ((PTR)location, 1, count, abfd) == count) ?true:false;
880 }
881 return true;
882 }
883
884 static boolean
885 b_out_set_arch_mach (abfd, arch, machine)
886 bfd *abfd;
887 enum bfd_architecture arch;
888 unsigned long machine;
889 {
890 bfd_default_set_arch_mach(abfd, arch, machine);
891
892 if (arch == bfd_arch_unknown) /* Unknown machine arch is OK */
893 return true;
894 if (arch == bfd_arch_i960) /* i960 default is OK */
895 switch (machine) {
896 case bfd_mach_i960_core:
897 case bfd_mach_i960_kb_sb:
898 case bfd_mach_i960_mc:
899 case bfd_mach_i960_xa:
900 case bfd_mach_i960_ca:
901 case bfd_mach_i960_ka_sa:
902 case 0:
903 return true;
904 default:
905 return false;
906 }
907
908 return false;
909 }
910
911 static int
912 b_out_sizeof_headers (ignore_abfd, ignore)
913 bfd *ignore_abfd;
914 boolean ignore;
915 {
916 return sizeof(struct internal_exec);
917 }
918
919
920
921 /************************************************************************/
922 static bfd_vma
923 get_value (reloc, link_info, input_section)
924 arelent *reloc;
925 struct bfd_link_info *link_info;
926 asection *input_section;
927 {
928 bfd_vma value;
929 asymbol *symbol = *(reloc->sym_ptr_ptr);
930
931 /* A symbol holds a pointer to a section, and an offset from the
932 base of the section. To relocate, we find where the section will
933 live in the output and add that in */
934
935 if (symbol->section == &bfd_und_section)
936 {
937 struct bfd_link_hash_entry *h;
938
939 /* The symbol is undefined in this BFD. Look it up in the
940 global linker hash table. FIXME: This should be changed when
941 we convert b.out to use a specific final_link function and
942 change the interface to bfd_relax_section to not require the
943 generic symbols. */
944 h = bfd_link_hash_lookup (link_info->hash, bfd_asymbol_name (symbol),
945 false, false, true);
946 if (h != (struct bfd_link_hash_entry *) NULL
947 && h->type == bfd_link_hash_defined)
948 value = h->u.def.value + output_addr (h->u.def.section);
949 else if (h != (struct bfd_link_hash_entry *) NULL
950 && h->type == bfd_link_hash_common)
951 value = h->u.c.size;
952 else
953 {
954 if (! ((*link_info->callbacks->undefined_symbol)
955 (link_info, bfd_asymbol_name (symbol),
956 input_section->owner, input_section, reloc->address)))
957 abort ();
958 value = 0;
959 }
960 }
961 else
962 {
963 value = symbol->value + output_addr (symbol->section);
964 }
965
966 /* Add the value contained in the relocation */
967 value += reloc->addend;
968
969 return value;
970 }
971
972 static void
973 perform_slip (abfd, slip, input_section, value)
974 bfd *abfd;
975 unsigned int slip;
976 asection *input_section;
977 bfd_vma value;
978 {
979 asymbol **s;
980
981 s = _bfd_generic_link_get_symbols (abfd);
982 BFD_ASSERT (s != (asymbol **) NULL);
983
984 /* Find all symbols past this point, and make them know
985 what's happened */
986 while (*s)
987 {
988 asymbol *p = *s;
989 if (p->section == input_section)
990 {
991 /* This was pointing into this section, so mangle it */
992 if (p->value > value)
993 {
994 p->value -=slip;
995 if (p->udata != NULL)
996 {
997 struct generic_link_hash_entry *h;
998
999 h = (struct generic_link_hash_entry *) p->udata;
1000 BFD_ASSERT (h->root.type == bfd_link_hash_defined);
1001 h->root.u.def.value -= slip;
1002 BFD_ASSERT (h->root.u.def.value == p->value);
1003 }
1004 }
1005 }
1006 s++;
1007
1008 }
1009 }
1010
1011 /* This routine works out if the thing we want to get to can be
1012 reached with a 24bit offset instead of a 32 bit one.
1013 If it can, then it changes the amode */
1014
1015 static int
1016 abs32code (abfd, input_section, r, shrink, link_info)
1017 bfd *abfd;
1018 asection *input_section;
1019 arelent *r;
1020 unsigned int shrink;
1021 struct bfd_link_info *link_info;
1022 {
1023 bfd_vma value = get_value (r, link_info, input_section);
1024 bfd_vma dot = output_addr (input_section) + r->address;
1025 bfd_vma gap;
1026
1027 /* See if the address we're looking at within 2^23 bytes of where
1028 we are, if so then we can use a small branch rather than the
1029 jump we were going to */
1030
1031 gap = value - (dot - shrink);
1032
1033
1034 if (-1<<23 < (long)gap && (long)gap < 1<<23 )
1035 {
1036 /* Change the reloc type from 32bitcode possible 24, to 24bit
1037 possible 32 */
1038
1039 r->howto = &howto_reloc_abs32codeshrunk;
1040 /* The place to relc moves back by four bytes */
1041 r->address -=4;
1042
1043 /* This will be four bytes smaller in the long run */
1044 shrink += 4 ;
1045 perform_slip (abfd, 4, input_section, r->address-shrink + 4);
1046 }
1047 return shrink;
1048 }
1049
1050 static int
1051 aligncode (abfd, input_section, r, shrink)
1052 bfd *abfd;
1053 asection *input_section;
1054 arelent *r;
1055 unsigned int shrink;
1056 {
1057 bfd_vma dot = output_addr (input_section) + r->address;
1058 bfd_vma gap;
1059 bfd_vma old_end;
1060 bfd_vma new_end;
1061 int shrink_delta;
1062 int size = r->howto->size;
1063
1064 /* Reduce the size of the alignment so that it's still aligned but
1065 smaller - the current size is already the same size as or bigger
1066 than the alignment required. */
1067
1068 /* calculate the first byte following the padding before we optimize */
1069 old_end = ((dot + size ) & ~size) + size+1;
1070 /* work out where the new end will be - remember that we're smaller
1071 than we used to be */
1072 new_end = ((dot - shrink + size) & ~size);
1073
1074 /* This is the new end */
1075 gap = old_end - ((dot + size) & ~size);
1076
1077 shrink_delta = (old_end - new_end) - shrink;
1078
1079 if (shrink_delta)
1080 {
1081 /* Change the reloc so that it knows how far to align to */
1082 r->howto = howto_done_align_table + (r->howto - howto_align_table);
1083
1084 /* Encode the stuff into the addend - for future use we need to
1085 know how big the reloc used to be */
1086 r->addend = old_end - dot + r->address;
1087
1088 /* This will be N bytes smaller in the long run, adjust all the symbols */
1089 perform_slip (abfd, shrink_delta, input_section, r->address - shrink);
1090 shrink += shrink_delta;
1091 }
1092 return shrink;
1093 }
1094
1095 static boolean
1096 b_out_relax_section (abfd, i, link_info, again)
1097 bfd *abfd;
1098 asection *i;
1099 struct bfd_link_info *link_info;
1100 boolean *again;
1101 {
1102 /* Get enough memory to hold the stuff */
1103 bfd *input_bfd = i->owner;
1104 asection *input_section = i;
1105 int shrink = 0 ;
1106 arelent **reloc_vector = NULL;
1107 long reloc_size = bfd_get_reloc_upper_bound(input_bfd,
1108 input_section);
1109
1110 if (reloc_size < 0)
1111 return false;
1112
1113 /* We only run this relaxation once. It might work to run it
1114 multiple times, but it hasn't been tested. */
1115 *again = false;
1116
1117 if (reloc_size)
1118 {
1119 long reloc_count;
1120
1121 reloc_vector = (arelent **) malloc (reloc_size);
1122 if (reloc_vector == NULL && reloc_size != 0)
1123 {
1124 bfd_set_error (bfd_error_no_memory);
1125 goto error_return;
1126 }
1127
1128 /* Get the relocs and think about them */
1129 reloc_count =
1130 bfd_canonicalize_reloc (input_bfd, input_section, reloc_vector,
1131 _bfd_generic_link_get_symbols (input_bfd));
1132 if (reloc_count < 0)
1133 goto error_return;
1134 if (reloc_count > 0)
1135 {
1136 arelent **parent;
1137 for (parent = reloc_vector; *parent; parent++)
1138 {
1139 arelent *r = *parent;
1140 switch (r->howto->type)
1141 {
1142 case ALIGNER:
1143 /* An alignment reloc */
1144 shrink = aligncode (abfd, input_section, r, shrink);
1145 break;
1146 case ABS32CODE:
1147 /* A 32bit reloc in an addressing mode */
1148 shrink = abs32code (input_bfd, input_section, r, shrink,
1149 link_info);
1150 break;
1151 case ABS32CODE_SHRUNK:
1152 shrink+=4;
1153 break;
1154 }
1155 }
1156 }
1157 }
1158 input_section->_cooked_size = input_section->_raw_size - shrink;
1159
1160 if (reloc_vector != NULL)
1161 free (reloc_vector);
1162 return true;
1163 error_return:
1164 if (reloc_vector != NULL)
1165 free (reloc_vector);
1166 return false;
1167 }
1168
1169 static bfd_byte *
1170 b_out_get_relocated_section_contents (in_abfd, link_info, link_order, data,
1171 relocateable, symbols)
1172 bfd *in_abfd;
1173 struct bfd_link_info *link_info;
1174 struct bfd_link_order *link_order;
1175 bfd_byte *data;
1176 boolean relocateable;
1177 asymbol **symbols;
1178 {
1179 /* Get enough memory to hold the stuff */
1180 bfd *input_bfd = link_order->u.indirect.section->owner;
1181 asection *input_section = link_order->u.indirect.section;
1182 long reloc_size = bfd_get_reloc_upper_bound(input_bfd,
1183 input_section);
1184 arelent **reloc_vector = NULL;
1185 long reloc_count;
1186
1187 if (reloc_size < 0)
1188 goto error_return;
1189
1190 /* If producing relocateable output, don't bother to relax. */
1191 if (relocateable)
1192 return bfd_generic_get_relocated_section_contents (in_abfd, link_info,
1193 link_order,
1194 data, relocateable,
1195 symbols);
1196
1197 reloc_vector = (arelent **) malloc (reloc_size);
1198 if (reloc_vector == NULL && reloc_size != 0)
1199 {
1200 bfd_set_error (bfd_error_no_memory);
1201 goto error_return;
1202 }
1203
1204 input_section->reloc_done = 1;
1205
1206 /* read in the section */
1207 BFD_ASSERT (true == bfd_get_section_contents(input_bfd,
1208 input_section,
1209 data,
1210 0,
1211 input_section->_raw_size));
1212
1213 reloc_count = bfd_canonicalize_reloc (input_bfd,
1214 input_section,
1215 reloc_vector,
1216 symbols);
1217 if (reloc_count < 0)
1218 goto error_return;
1219 if (reloc_count > 0)
1220 {
1221 arelent **parent = reloc_vector;
1222 arelent *reloc ;
1223
1224 unsigned int dst_address = 0;
1225 unsigned int src_address = 0;
1226 unsigned int run;
1227 unsigned int idx;
1228
1229 /* Find how long a run we can do */
1230 while (dst_address < link_order->size)
1231 {
1232 reloc = *parent;
1233 if (reloc)
1234 {
1235 /* Note that the relaxing didn't tie up the addresses in the
1236 relocation, so we use the original address to work out the
1237 run of non-relocated data */
1238 BFD_ASSERT (reloc->address >= src_address);
1239 run = reloc->address - src_address;
1240 parent++;
1241 }
1242 else
1243 {
1244 run = link_order->size - dst_address;
1245 }
1246 /* Copy the bytes */
1247 for (idx = 0; idx < run; idx++)
1248 {
1249 data[dst_address++] = data[src_address++];
1250 }
1251
1252 /* Now do the relocation */
1253
1254 if (reloc)
1255 {
1256 switch (reloc->howto->type)
1257 {
1258 case ABS32CODE:
1259 calljx_callback (in_abfd, link_info, reloc,
1260 src_address + data, dst_address + data,
1261 input_section);
1262 src_address+=4;
1263 dst_address+=4;
1264 break;
1265 case ABS32:
1266 bfd_put_32(in_abfd,
1267 (bfd_get_32 (in_abfd, data+src_address)
1268 + get_value (reloc, link_info, input_section)),
1269 data+dst_address);
1270 src_address+=4;
1271 dst_address+=4;
1272 break;
1273 case CALLJ:
1274 callj_callback (in_abfd, link_info, reloc, data, src_address,
1275 dst_address, input_section);
1276 src_address+=4;
1277 dst_address+=4;
1278 break;
1279 case ALIGNDONE:
1280 BFD_ASSERT (reloc->addend >= src_address);
1281 BFD_ASSERT (reloc->addend <= input_section->_raw_size);
1282 src_address = reloc->addend;
1283 dst_address = ((dst_address + reloc->howto->size)
1284 & ~reloc->howto->size);
1285 break;
1286 case ABS32CODE_SHRUNK:
1287 /* This used to be a callx, but we've found out that a
1288 callj will reach, so do the right thing. */
1289 callj_callback (in_abfd, link_info, reloc, data,
1290 src_address + 4, dst_address, input_section);
1291 dst_address+=4;
1292 src_address+=8;
1293 break;
1294 case PCREL24:
1295 {
1296 long int word = bfd_get_32(in_abfd, data+src_address);
1297 bfd_vma value;
1298
1299 value = get_value (reloc, link_info, input_section);
1300 word = ((word & ~BAL_MASK)
1301 | (((word & BAL_MASK)
1302 + value
1303 - output_addr (input_section)
1304 + reloc->addend)
1305 & BAL_MASK));
1306
1307 bfd_put_32(in_abfd,word, data+dst_address);
1308 dst_address+=4;
1309 src_address+=4;
1310
1311 }
1312 break;
1313
1314 case PCREL13:
1315 {
1316 long int word = bfd_get_32(in_abfd, data+src_address);
1317 bfd_vma value;
1318
1319 value = get_value (reloc, link_info, input_section);
1320 word = ((word & ~PCREL13_MASK)
1321 | (((word & PCREL13_MASK)
1322 + value
1323 + reloc->addend
1324 - output_addr (input_section))
1325 & PCREL13_MASK));
1326
1327 bfd_put_32(in_abfd,word, data+dst_address);
1328 dst_address+=4;
1329 src_address+=4;
1330
1331 }
1332 break;
1333
1334 default:
1335 abort();
1336 }
1337 }
1338 }
1339 }
1340 if (reloc_vector != NULL)
1341 free (reloc_vector);
1342 return data;
1343 error_return:
1344 if (reloc_vector != NULL)
1345 free (reloc_vector);
1346 return NULL;
1347 }
1348 /***********************************************************************/
1349
1350 /* Build the transfer vectors for Big and Little-Endian B.OUT files. */
1351
1352 /* We don't have core files. */
1353 #define aout_32_core_file_failing_command _bfd_dummy_core_file_failing_command
1354 #define aout_32_core_file_failing_signal _bfd_dummy_core_file_failing_signal
1355 #define aout_32_core_file_matches_executable_p \
1356 _bfd_dummy_core_file_matches_executable_p
1357
1358 /* We use BSD-Unix generic archive files. */
1359 #define aout_32_openr_next_archived_file bfd_generic_openr_next_archived_file
1360 #define aout_32_generic_stat_arch_elt bfd_generic_stat_arch_elt
1361 #define aout_32_slurp_armap bfd_slurp_bsd_armap
1362 #define aout_32_slurp_extended_name_table _bfd_slurp_extended_name_table
1363 #define aout_32_write_armap bsd_write_armap
1364 #define aout_32_truncate_arname bfd_bsd_truncate_arname
1365
1366 /* We override these routines from the usual a.out file routines. */
1367 #define aout_32_canonicalize_reloc b_out_canonicalize_reloc
1368 #define aout_32_get_reloc_upper_bound b_out_get_reloc_upper_bound
1369 #define aout_32_set_section_contents b_out_set_section_contents
1370 #define aout_32_set_arch_mach b_out_set_arch_mach
1371 #define aout_32_sizeof_headers b_out_sizeof_headers
1372
1373 #define aout_32_bfd_debug_info_start bfd_void
1374 #define aout_32_bfd_debug_info_end bfd_void
1375 #define aout_32_bfd_debug_info_accumulate (PROTO(void,(*),(bfd*, struct sec *))) bfd_void
1376
1377 #define aout_32_bfd_get_relocated_section_contents b_out_get_relocated_section_contents
1378 #define aout_32_bfd_relax_section b_out_relax_section
1379 #define aout_32_bfd_reloc_type_lookup b_out_reloc_type_lookup
1380 #define aout_32_bfd_make_debug_symbol \
1381 ((asymbol *(*) PARAMS ((bfd *, void *, unsigned long))) bfd_nullvoidptr)
1382 #define aout_32_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
1383 #define aout_32_bfd_link_add_symbols _bfd_generic_link_add_symbols
1384 #define aout_32_bfd_final_link _bfd_generic_final_link
1385 #define aout_32_close_and_cleanup aout_32_bfd_free_cached_info
1386
1387 bfd_target b_out_vec_big_host =
1388 {
1389 "b.out.big", /* name */
1390 bfd_target_aout_flavour,
1391 false, /* data byte order is little */
1392 true, /* hdr byte order is big */
1393 (HAS_RELOC | EXEC_P | /* object flags */
1394 HAS_LINENO | HAS_DEBUG |
1395 HAS_SYMS | HAS_LOCALS | WP_TEXT | BFD_IS_RELAXABLE ),
1396 (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
1397 '_', /* symbol leading char */
1398 ' ', /* ar_pad_char */
1399 16, /* ar_max_namelen */
1400 2, /* minumum alignment power */
1401
1402 bfd_getl64, bfd_getl_signed_64, bfd_putl64,
1403 bfd_getl32, bfd_getl_signed_32, bfd_putl32,
1404 bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* data */
1405 bfd_getb64, bfd_getb_signed_64, bfd_putb64,
1406 bfd_getb32, bfd_getb_signed_32, bfd_putb32,
1407 bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */
1408 {_bfd_dummy_target, b_out_object_p, /* bfd_check_format */
1409 bfd_generic_archive_p, _bfd_dummy_target},
1410 {bfd_false, b_out_mkobject, /* bfd_set_format */
1411 _bfd_generic_mkarchive, bfd_false},
1412 {bfd_false, b_out_write_object_contents, /* bfd_write_contents */
1413 _bfd_write_archive_contents, bfd_false},
1414
1415 JUMP_TABLE(aout_32),
1416 (PTR) 0,
1417 };
1418
1419
1420 bfd_target b_out_vec_little_host =
1421 {
1422 "b.out.little", /* name */
1423 bfd_target_aout_flavour,
1424 false, /* data byte order is little */
1425 false, /* header byte order is little */
1426 (HAS_RELOC | EXEC_P | /* object flags */
1427 HAS_LINENO | HAS_DEBUG |
1428 HAS_SYMS | HAS_LOCALS | WP_TEXT | BFD_IS_RELAXABLE ),
1429 (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
1430 '_', /* symbol leading char */
1431 ' ', /* ar_pad_char */
1432 16, /* ar_max_namelen */
1433 2, /* minum align */
1434 bfd_getl64, bfd_getl_signed_64, bfd_putl64,
1435 bfd_getl32, bfd_getl_signed_32, bfd_putl32,
1436 bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* data */
1437 bfd_getl64, bfd_getl_signed_64, bfd_putl64,
1438 bfd_getl32, bfd_getl_signed_32, bfd_putl32,
1439 bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* hdrs */
1440
1441 {_bfd_dummy_target, b_out_object_p, /* bfd_check_format */
1442 bfd_generic_archive_p, _bfd_dummy_target},
1443 {bfd_false, b_out_mkobject, /* bfd_set_format */
1444 _bfd_generic_mkarchive, bfd_false},
1445 {bfd_false, b_out_write_object_contents, /* bfd_write_contents */
1446 _bfd_write_archive_contents, bfd_false},
1447 JUMP_TABLE(aout_32),
1448 (PTR) 0
1449 };
This page took 0.063786 seconds and 5 git commands to generate.