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