*** empty log message ***
[deliverable/binutils-gdb.git] / bfd / bout.c
CommitLineData
7ed4093a
SC
1/* BFD back-end for i960 b.out binaries */
2
3/* Copyright (C) 1990, 1991 Free Software Foundation, Inc.
4
5This file is part of BFD, the Binary File Diddler.
6
7BFD is free software; you can redistribute it and/or modify
8it under the terms of the GNU General Public License as published by
9the Free Software Foundation; either version 1, or (at your option)
10any later version.
11
12BFD is distributed in the hope that it will be useful,
13but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License
18along with BFD; see the file COPYING. If not, write to
19the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
20
21/* $Id$ */
22
23#include <sysdep.h>
24#include "bfd.h"
25#include "libbfd.h"
26
27
28#include "bout.h"
29
30
31#include "stab.gnu.h"
359f1dee 32#include "libaout.h" /* BFD a.out internal data structures */
7ed4093a
SC
33#include "archures.h"
34
35/* Align an address by rounding it up to a power of two. It leaves the
36 address unchanged if align == 0 (2^0 = alignment of 1 byte) */
37#define i960_align(addr, align) \
38 ( ((addr) + ((1<<(align))-1)) & (-1 << (align)))
39
7ed4093a
SC
40
41
42PROTO (static boolean, b_out_squirt_out_relocs,(bfd *abfd, asection *section));
43PROTO (static bfd_target *, b_out_callback, (bfd *));
44
f4d2c0bb
SC
45PROTO (boolean, aout_32_slurp_symbol_table, (bfd *abfd));
46PROTO (void , aout_32_write_syms, ());
7ed4093a 47
87059abb
SC
48PROTO (static void, swap_exec_header, (bfd *abfd, struct internal_exec *execp));
49
7ed4093a
SC
50
51static bfd_target *
52b_out_little_object_p (abfd)
53 bfd *abfd;
54{
55 unsigned char magicbytes[LONG_SIZE];
87059abb 56 struct internal_exec anexec;
7ed4093a
SC
57
58 if (bfd_read ((PTR)magicbytes, 1, LONG_SIZE, abfd) != LONG_SIZE) {
59 bfd_error = system_call_error;
60 return 0;
61 }
62 anexec.a_magic = _do_getl32 (magicbytes);
63
64 if (N_BADMAG (anexec)) {
65 bfd_error = wrong_format;
66 return 0;
67 }
87059abb 68 return aout_32_some_aout_object_p (abfd, b_out_callback);
7ed4093a
SC
69}
70
71static bfd_target *
72b_out_big_object_p (abfd)
73 bfd *abfd;
74{
75 unsigned char magicbytes[LONG_SIZE];
87059abb 76 struct internal_exec anexec;
7ed4093a
SC
77
78 if (bfd_read ((PTR)magicbytes, 1, LONG_SIZE, abfd) != LONG_SIZE) {
79 bfd_error = system_call_error;
80 return 0;
81 }
82
83 anexec.a_magic = _do_getb32 (magicbytes);
84
85 if (N_BADMAG (anexec)) {
86 bfd_error = wrong_format;
87 return 0;
88 }
87059abb 89 return aout_32_some_aout_object_p (abfd, b_out_callback);
7ed4093a
SC
90}
91
92/* Finish up the opening of a b.out file for reading. Fill in all the
93 fields that are not handled by common code. */
94
95static bfd_target *
96b_out_callback (abfd)
97 bfd *abfd;
98{
87059abb
SC
99 struct internal_exec anexec;
100 struct internal_exec *execp = &anexec;
7ed4093a
SC
101 unsigned long bss_start;
102
103 /* Reread the exec header, because the common code didn't get all of
104 our extended header. */
105
106 if (bfd_seek (abfd, 0L, SEEK_SET) < 0) {
107 bfd_error = system_call_error;
108 return 0;
109 }
110
111 /* FIXME, needs to be hacked for character array read-in ala sunos.c. */
87059abb
SC
112 if (bfd_read ((PTR) execp, 1, sizeof (struct internal_exec), abfd)
113 != sizeof (struct internal_exec)) {
7ed4093a
SC
114 bfd_error = wrong_format;
115 return 0;
116 }
117
118 swap_exec_header (abfd, execp);
119
120 /* Architecture and machine type */
121 abfd->obj_arch = bfd_arch_i960; /* B.out only used on i960 */
122 abfd->obj_machine = bfd_mach_i960_core; /* Default */
123/* FIXME: Set real machine type from file here */
124
125 /* The positions of the string table and symbol table. */
126 obj_str_filepos (abfd) = N_STROFF (anexec);
127 obj_sym_filepos (abfd) = N_SYMOFF (anexec);
128
129 /* The alignments of the sections */
130 obj_textsec (abfd)->alignment_power = execp->a_talign;
131 obj_datasec (abfd)->alignment_power = execp->a_dalign;
132 obj_bsssec (abfd)->alignment_power = execp->a_balign;
133
134 /* The starting addresses of the sections. */
135 obj_textsec (abfd)->vma = anexec.a_tload;
136 obj_datasec (abfd)->vma = anexec.a_dload;
137 bss_start = anexec.a_dload + anexec.a_data; /* BSS = end of data section */
138 obj_bsssec (abfd)->vma = i960_align (bss_start, anexec.a_balign);
139
140 /* The file positions of the sections */
141 obj_textsec (abfd)->filepos = N_TXTOFF(anexec);
142 obj_datasec (abfd)->filepos = N_DATOFF(anexec);
143
144 /* The file positions of the relocation info */
145 obj_textsec (abfd)->rel_filepos = N_TROFF(anexec);
146 obj_datasec (abfd)->rel_filepos = N_DROFF(anexec);
147
148 return abfd->xvec;
149}
150
151
152static boolean
153b_out_mkobject (abfd)
154 bfd *abfd;
155{
156 PTR rawptr;
157
158 bfd_error = system_call_error;
159
160 /* Use an intermediate variable for clarity */
87059abb 161 rawptr = (PTR) zalloc (sizeof (struct aoutdata) + sizeof (struct internal_exec));
7ed4093a
SC
162
163 if (rawptr == (PTR)NULL) {
164 bfd_error = no_memory;
165 return false;
166 }
167
168 set_tdata(abfd, (struct aoutdata *) rawptr);
87059abb 169 exec_hdr (abfd) = (struct internal_exec *) ( (char*)rawptr + sizeof (struct aoutdata));
7ed4093a
SC
170
171 /* For simplicity's sake we just make all the sections right here. */
172 obj_textsec (abfd) = (asection *)NULL;
173 obj_datasec (abfd) = (asection *)NULL;
174 obj_bsssec (abfd) = (asection *)NULL;
175
176 bfd_make_section (abfd, ".text");
177 bfd_make_section (abfd, ".data");
178 bfd_make_section (abfd, ".bss");
179
180 return true;
181}
182
183static boolean
184b_out_write_object_contents (abfd)
185 bfd *abfd;
186{
87059abb 187 struct internal_exec swapped_hdr;
7ed4093a
SC
188
189 exec_hdr (abfd)->a_magic = BMAGIC;
190
191 exec_hdr (abfd)->a_text = obj_textsec (abfd)->size;
192 exec_hdr (abfd)->a_data = obj_datasec (abfd)->size;
193 exec_hdr (abfd)->a_bss = obj_bsssec (abfd)->size;
194 exec_hdr (abfd)->a_syms = bfd_get_symcount (abfd) * sizeof (struct nlist);
195 exec_hdr (abfd)->a_entry = bfd_get_start_address (abfd);
196 exec_hdr (abfd)->a_trsize = ((obj_textsec (abfd)->reloc_count) *
197 sizeof (struct relocation_info));
198 exec_hdr (abfd)->a_drsize = ((obj_datasec (abfd)->reloc_count) *
199 sizeof (struct relocation_info));
200
201 exec_hdr (abfd)->a_talign = obj_textsec (abfd)->alignment_power;
202 exec_hdr (abfd)->a_dalign = obj_datasec (abfd)->alignment_power;
203 exec_hdr (abfd)->a_balign = obj_bsssec (abfd)->alignment_power;
204
205 exec_hdr (abfd)->a_tload = obj_textsec (abfd)->vma;
206 exec_hdr (abfd)->a_dload = obj_datasec (abfd)->vma;
207
208 /* FIXME, turn the header into bytes here, to avoid problems with
209 sizes and alignments of its fields. */
210 swapped_hdr = *exec_hdr(abfd);
211 swap_exec_header (abfd, &swapped_hdr);
212
213 bfd_seek (abfd, 0L, SEEK_SET);
87059abb 214 bfd_write ((PTR) &swapped_hdr, 1, sizeof (struct internal_exec), abfd);
7ed4093a
SC
215
216 /* Now write out reloc info, followed by syms and strings */
217 if (bfd_get_symcount (abfd) != 0)
218 {
219 bfd_seek (abfd,
220 (long)(N_SYMOFF(*exec_hdr(abfd))), SEEK_SET);
221
f4d2c0bb 222 aout_32_write_syms (abfd);
7ed4093a
SC
223
224 bfd_seek (abfd, (long)(N_TROFF(*exec_hdr(abfd))), SEEK_SET);
225
226 if (!b_out_squirt_out_relocs (abfd, obj_textsec (abfd))) return false;
227 bfd_seek (abfd, (long)(N_DROFF(*exec_hdr(abfd))), SEEK_SET);
228
229 if (!b_out_squirt_out_relocs (abfd, obj_datasec (abfd))) return false;
230 }
231 return true;
232}
233
234static void
235swap_exec_header (abfd, execp)
236 bfd *abfd;
87059abb 237 struct internal_exec *execp;
7ed4093a
SC
238{
239#define swapme(field) field = bfd_h_get_32 (abfd, (unsigned char *)&field);
240 swapme (execp->a_magic);
241 swapme (execp->a_text);
242 swapme (execp->a_data);
243 swapme (execp->a_bss);
244 swapme (execp->a_syms);
245 swapme (execp->a_entry);
246 swapme (execp->a_trsize);
247 swapme (execp->a_drsize);
248 swapme (execp->a_tload);
249 swapme (execp->a_dload);
250 /* talign, dalign, and balign are one-byte fields and don't swap. */
251#undef swapme
252}
253\f
254/** Some reloc hackery */
255
256#define CALLS 0x66003800 /* Template for 'calls' instruction */
257#define BAL 0x0b000000 /* Template for 'bal' instruction */
258#define BAL_MASK 0x00ffffff
259
260static bfd_reloc_status_enum_type
261callj_callback(abfd, reloc_entry, symbol_in, data, input_section)
262bfd *abfd;
263arelent *reloc_entry;
264asymbol *symbol_in;
265unsigned char *data;
266asection *input_section;
267{
268 int word = bfd_get_32(abfd, data+reloc_entry->address);
269 aout_symbol_type *symbol = aout_symbol(symbol_in);
270
271 if (IS_OTHER(symbol->other)) {
272 /* Call to a system procedure - replace code with system
273 procedure number
274 */
275
276 word = CALLS | (symbol->other - 1);
277 bfd_put_32(abfd, word, data+reloc_entry->address); /* replace */
278 return bfd_reloc_ok;
279 }
280
281 if (IS_CALLNAME(symbol->other)) {
282 aout_symbol_type *balsym = symbol+1;
283 /* The next symbol should be an N_BALNAME */
284 BFD_ASSERT(IS_BALNAME(balsym->other));
285
286 /* We are calling a leaf - so replace the call instruction
287 with a bal */
288
289 word = BAL |
290 (((word & BAL_MASK) +
291 balsym->symbol.section->output_offset +
292 balsym->symbol.section->output_section->vma+
293 balsym->symbol.value + reloc_entry->addend -
294 ( input_section->output_section->vma + input_section->output_offset))
295 & BAL_MASK);
296
297 bfd_put_32(abfd, word, data+reloc_entry->address); /* replace */
298 return bfd_reloc_ok;
299 }
300 return bfd_reloc_continue;
301
302}
303/* type rshift size bitsize pcrel bitpos absolute overflow check*/
304
305
306static reloc_howto_type howto_reloc_callj =
307HOWTO( 3, 0, 2, 24, true, 0, true, true, callj_callback,"callj", true, 0x00ffffff, 0x00ffffff,false);
308static reloc_howto_type howto_reloc_abs32 =
309HOWTO(1, 0, 2, 32, false, 0, true, true,0,"abs32", true, 0xffffffff,0xffffffff,false);
310static reloc_howto_type howto_reloc_pcrel24 =
311HOWTO(2, 0, 2, 24, true, 0, true, true,0,"pcrel24", true, 0x00ffffff,0x00ffffff,false);
312
313/* Allocate enough room for all the reloc entries, plus pointers to them all */
314
315static boolean
316b_out_slurp_reloc_table (abfd, asect, symbols)
317 bfd *abfd;
318 sec_ptr asect;
319 asymbol **symbols;
320{
321 unsigned int count;
322 size_t reloc_size;
323 struct relocation_info *relocs;
324 arelent *reloc_cache;
325
326 if (asect->relocation) return true;
f4d2c0bb 327 if (!aout_32_slurp_symbol_table (abfd)) return false;
7ed4093a
SC
328
329 if (asect == obj_datasec (abfd)) {
330 reloc_size = exec_hdr(abfd)->a_drsize;
331 goto doit;
332 }
333
334 if (asect == obj_textsec (abfd)) {
335 reloc_size = exec_hdr(abfd)->a_trsize;
336 goto doit;
337 }
338
339 bfd_error = invalid_operation;
340 return false;
341
342 doit:
343 bfd_seek (abfd, (long)(asect->rel_filepos), SEEK_SET);
344 count = reloc_size / sizeof (struct relocation_info);
345
346 relocs = (struct relocation_info *) malloc (reloc_size);
347 if (!relocs) {
348 bfd_error = no_memory;
349 return false;
350 }
351 reloc_cache = (arelent *) malloc ((count+1) * sizeof (arelent));
352 if (!reloc_cache) {
353 free ((char*)relocs);
354 bfd_error = no_memory;
355 return false;
356 }
357
358 if (bfd_read ((PTR) relocs, 1, reloc_size, abfd) != reloc_size) {
359 bfd_error = system_call_error;
360 free (reloc_cache);
361 free (relocs);
362 return false;
363 }
364
365 {
366 register struct relocation_info *rptr = relocs;
367 unsigned int counter = 0;
368 arelent *cache_ptr = reloc_cache;
369 int extern_mask, pcrel_mask, callj_mask;
370
371 if (abfd->xvec->header_byteorder_big_p) {
372 /* Big-endian bit field allocation order */
373 pcrel_mask = 0x80;
374 extern_mask = 0x10;
375 callj_mask = 0x02;
376 } else {
377 /* Little-endian bit field allocation order */
378 pcrel_mask = 0x01;
379 extern_mask = 0x08;
380 callj_mask = 0x40;
381 }
382
383 for (; counter < count; counter++, rptr++, cache_ptr++)
384 {
385 unsigned char *raw = (unsigned char *)rptr;
386 unsigned int symnum;
387 cache_ptr->address = bfd_h_get_32 (abfd, raw + 0);
388 if (abfd->xvec->header_byteorder_big_p) {
389 symnum = (raw[4] << 16) | (raw[5] << 8) | raw[6];
390 } else {
391 symnum = (raw[6] << 16) | (raw[5] << 8) | raw[4];
392 }
393
394 if (raw[7] & extern_mask) {
395 /* If this is set then the r_index is a index into the symbol table;
396 * if the bit is not set then r_index contains a section map.
397 * We either fill in the sym entry with a pointer to the symbol,
398 * or point to the correct section
399 */
400 cache_ptr->sym_ptr_ptr = symbols + symnum;
401 cache_ptr->addend = 0;
402 cache_ptr->section = (asection*)NULL;
403 } else {
404 /* In a.out symbols are relative to the beginning of the
405 * file rather than sections ?
406 * (look in translate_from_native_sym_flags)
407 * The reloc entry addend has added to it the offset into the
408 * file of the data, so subtract the base to make the reloc
409 * section relative */
410 cache_ptr->sym_ptr_ptr = (asymbol **)NULL;
411 switch (symnum) {
412 case N_TEXT:
413 case N_TEXT | N_EXT:
414 cache_ptr->section = obj_textsec(abfd);
415 cache_ptr->addend = -obj_textsec(abfd)->vma;
416 break;
417 case N_DATA:
418 case N_DATA | N_EXT:
419 cache_ptr->section = obj_datasec(abfd);
420 cache_ptr->addend = - obj_datasec(abfd)->vma;
421 break;
422 case N_BSS:
423 case N_BSS | N_EXT:
424 cache_ptr->section = obj_bsssec(abfd);
425 cache_ptr->addend = - obj_bsssec(abfd)->vma;
426 break;
427 case N_ABS:
428 case N_ABS | N_EXT:
429 BFD_ASSERT(0);
430 break;
431 default:
432 BFD_ASSERT(0);
433 break;
434 }
435
436 }
437
438 /* The i960 only has a few relocation types:
439 abs 32-bit and pcrel 24bit. Except for callj's! */
440 if (raw[7] & callj_mask)
441 cache_ptr->howto = &howto_reloc_callj;
442 else if ( raw[7] & pcrel_mask)
443 cache_ptr->howto = &howto_reloc_pcrel24;
444 else
445 cache_ptr->howto = &howto_reloc_abs32;
446 }
447 }
448
449 free (relocs);
450 asect->relocation = reloc_cache;
451 asect->reloc_count = count;
452 return true;
453}
454
455
456static boolean
457b_out_squirt_out_relocs (abfd, section)
458 bfd *abfd;
459 asection *section;
460{
461 arelent **generic;
462
463 unsigned int count = section->reloc_count;
464 struct relocation_info *native, *natptr;
465 size_t natsize = count * sizeof (struct relocation_info);
466 int extern_mask, pcrel_mask, len_2, callj_mask;
467 if (count == 0) return true;
468 generic = section->orelocation;
469 native = ((struct relocation_info *) malloc (natsize));
470 if (!native) {
471 bfd_error = no_memory;
472 return false;
473 }
474
475 if (abfd->xvec->header_byteorder_big_p) {
476 /* Big-endian bit field allocation order */
477 pcrel_mask = 0x80;
478 extern_mask = 0x10;
479 len_2 = 0x40;
480 callj_mask = 0x02;
481 } else {
482 /* Little-endian bit field allocation order */
483 pcrel_mask = 0x01;
484 extern_mask = 0x08;
485 len_2 = 0x04;
486 callj_mask = 0x40;
487 }
488
489 for (natptr = native; count > 0; --count, ++natptr, ++generic)
490 {
491 arelent *g = *generic;
492 unsigned char *raw = (unsigned char *)natptr;
493 unsigned int symnum;
494
495 bfd_h_put_32(abfd, g->address, raw);
496 /* Find a type in the output format which matches the input howto -
497 * at the moment we assume input format == output format FIXME!!
498 */
499 /* FIXME: Need callj stuff here, and to check the howto entries to
500 be sure they are real for this architecture. */
501 if (g->howto== &howto_reloc_callj) {
502 raw[7] = callj_mask + pcrel_mask + len_2;
503 }
504 else if (g->howto == &howto_reloc_pcrel24) {
505 raw[7] = pcrel_mask +len_2;
506 }
507 else {
508 raw[7] = len_2;
509 }
510 if (g->sym_ptr_ptr != (asymbol **)NULL)
511 {
512 /* name clobbered by aout_write_syms to be symbol index*/
513 if ((*(g->sym_ptr_ptr))->section) {
514 /* replace the section offset into the addent */
515 g->addend += (*(g->sym_ptr_ptr))->section->vma ;
516 }
517 symnum = stoi((*(g->sym_ptr_ptr))->name);
518 raw[7] |= extern_mask;
519 BFD_ASSERT(g->addend == 0);
520 }
521 else {
522 if (g->section == (asection *)NULL) {
523 symnum = N_ABS;
524 BFD_ASSERT(0);
525 }
526 else if(g->section->output_section == obj_textsec(abfd)) {
527 symnum = N_TEXT;
87059abb
SC
528 BFD_ASSERT(g->addend + obj_textsec(abfd)->vma == 0);
529
7ed4093a
SC
530 }
531 else if (g->section->output_section == obj_datasec(abfd)) {
532 symnum = N_DATA;
87059abb
SC
533 BFD_ASSERT(g->addend + obj_datasec(abfd)->vma == 0);
534
7ed4093a
SC
535 }
536 else if (g->section->output_section == obj_bsssec(abfd)) {
537 symnum = N_BSS;
87059abb
SC
538 BFD_ASSERT(g->addend + obj_bsssec(abfd)->vma == 0);
539
7ed4093a
SC
540
541 }
542 else {
543 BFD_ASSERT(0);
544 }
545 }
546 if (abfd->xvec->header_byteorder_big_p) {
547 raw[4] = (unsigned char) (symnum >> 16);
548 raw[5] = (unsigned char) (symnum >> 8);
549 raw[6] = (unsigned char) (symnum );
550 } else {
551 raw[6] = (unsigned char) (symnum >> 16);
552 raw[5] = (unsigned char) (symnum >> 8);
553 raw[4] = (unsigned char) (symnum );
554 }
555 }
556
557 if ( bfd_write ((PTR) native, 1, natsize, abfd) != natsize) {
558 free((PTR)native);
559 return false;
560 }
561 free ((PTR)native);
562
563 return true;
564}
565
566/* This is stupid. This function should be a boolean predicate */
567static unsigned int
568b_out_canonicalize_reloc (abfd, section, relptr, symbols)
569 bfd *abfd;
570 sec_ptr section;
571 arelent **relptr;
572 asymbol **symbols;
573{
574 arelent *tblptr = section->relocation;
575 unsigned int count = 0;
576
577 if (!(tblptr || b_out_slurp_reloc_table (abfd, section, symbols))) return 0;
578 tblptr = section->relocation;
579 if (!tblptr) return 0;
580
581 for (; count++ < section->reloc_count;)
582 *relptr++ = tblptr++;
583
584 *relptr = 0;
585
586 return section->reloc_count;
587}
588
589static unsigned int
590b_out_get_reloc_upper_bound (abfd, asect)
591 bfd *abfd;
592 sec_ptr asect;
593{
594 if (bfd_get_format (abfd) != bfd_object) {
595 bfd_error = invalid_operation;
596 return 0;
597 }
598
599 if (asect == obj_datasec (abfd))
600 return (sizeof (arelent *) *
601 ((exec_hdr(abfd)->a_drsize / sizeof (struct relocation_info))
602 +1));
603
604 if (asect == obj_textsec (abfd))
605 return (sizeof (arelent *) *
606 ((exec_hdr(abfd)->a_trsize / sizeof (struct relocation_info))
607 +1));
608
609 bfd_error = invalid_operation;
610 return 0;
611}
612\f
613static boolean
614b_out_set_section_contents (abfd, section, location, offset, count)
615 bfd *abfd;
616 sec_ptr section;
617 unsigned char *location;
618 file_ptr offset;
619 int count;
620{
621 if (abfd->output_has_begun == false) { /* set by bfd.c handler */
622 if ((obj_textsec (abfd) == NULL) || (obj_datasec (abfd) == NULL) /*||
623 (obj_textsec (abfd)->size == 0) || (obj_datasec (abfd)->size == 0)*/) {
624 bfd_error = invalid_operation;
625 return false;
626 }
627
87059abb 628 obj_textsec (abfd)->filepos = sizeof(struct internal_exec);
7ed4093a
SC
629 obj_datasec(abfd)->filepos = obj_textsec(abfd)->filepos
630 + obj_textsec (abfd)->size;
631
632 }
633 /* regardless, once we know what we're doing, we might as well get going */
634 bfd_seek (abfd, section->filepos + offset, SEEK_SET);
635
636 if (count != 0) {
637 return (bfd_write ((PTR)location, 1, count, abfd) == count) ?true:false;
638 }
639 return false;
640}
641
642static boolean
643b_out_set_arch_mach (abfd, arch, machine)
644 bfd *abfd;
645 enum bfd_architecture arch;
646 unsigned long machine;
647{
648 abfd->obj_arch = arch;
649 abfd->obj_machine = machine;
650 if (arch == bfd_arch_unknown) /* Unknown machine arch is OK */
651 return true;
652 if (arch == bfd_arch_i960) /* i960 default is OK */
653 switch (machine) {
654 case bfd_mach_i960_core:
655 case bfd_mach_i960_kb_sb:
656 case bfd_mach_i960_mc:
657 case bfd_mach_i960_xa:
658 case bfd_mach_i960_ca:
659 case bfd_mach_i960_ka_sa:
660 return true;
661 default:
662 return false;
663 }
664
665 return false;
666}
667
668static int
669DEFUN(b_out_sizeof_headers,(abfd, exec),
670 bfd *abfd AND
f4d2c0bb 671 boolean exec)
7ed4093a 672{
87059abb 673return sizeof(struct internal_exec);
7ed4093a 674}
87059abb
SC
675
676
7ed4093a 677\f
87059abb
SC
678
679
680
681
7ed4093a
SC
682/* Build the transfer vectors for Big and Little-Endian B.OUT files. */
683
684/* We don't have core files. */
87059abb
SC
685#define aout_32_core_file_failing_command _bfd_dummy_core_file_failing_command
686#define aout_32_core_file_failing_signal _bfd_dummy_core_file_failing_signal
687#define aout_32_core_file_matches_executable_p \
7ed4093a
SC
688 _bfd_dummy_core_file_matches_executable_p
689
690/* We use BSD-Unix generic archive files. */
87059abb
SC
691#define aout_32_openr_next_archived_file bfd_generic_openr_next_archived_file
692#define aout_32_generic_stat_arch_elt bfd_generic_stat_arch_elt
693#define aout_32_slurp_armap bfd_slurp_bsd_armap
694#define aout_32_slurp_extended_name_table bfd_true
695#define aout_32_write_armap bsd_write_armap
696#define aout_32_truncate_arname bfd_bsd_truncate_arname
7ed4093a
SC
697
698/* We override these routines from the usual a.out file routines. */
87059abb
SC
699#define aout_32_canonicalize_reloc b_out_canonicalize_reloc
700#define aout_32_get_reloc_upper_bound b_out_get_reloc_upper_bound
701#define aout_32_set_section_contents b_out_set_section_contents
702#define aout_32_set_arch_mach b_out_set_arch_mach
703#define aout_32_sizeof_headers b_out_sizeof_headers
704
705#define aout_32_bfd_debug_info_start bfd_void
706#define aout_32_bfd_debug_info_end bfd_void
707#define aout_32_bfd_debug_info_accumulate (PROTO(void,(*),(bfd*, struct sec *))) bfd_void
7ed4093a
SC
708
709
710bfd_target b_out_vec_big_host =
711{
712 "b.out.big", /* name */
713 bfd_target_aout_flavour_enum,
714 false, /* data byte order is little */
715 true, /* hdr byte order is big */
716 (HAS_RELOC | EXEC_P | /* object flags */
717 HAS_LINENO | HAS_DEBUG |
718 HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT ),
719 (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
720 ' ', /* ar_pad_char */
721 16, /* ar_max_namelen */
87059abb 722 2, /* minumum alignment power */
7ed4093a
SC
723
724_do_getl64, _do_putl64, _do_getl32, _do_putl32, _do_getl16, _do_putl16, /* data */
725_do_getb64, _do_putb64, _do_getb32, _do_putb32, _do_getb16, _do_putb16, /* hdrs */
726 {_bfd_dummy_target, b_out_big_object_p, /* bfd_check_format */
727 bfd_generic_archive_p, _bfd_dummy_target},
728 {bfd_false, b_out_mkobject, /* bfd_set_format */
729 _bfd_generic_mkarchive, bfd_false},
730 {bfd_false, b_out_write_object_contents, /* bfd_write_contents */
731 _bfd_write_archive_contents, bfd_false},
732
87059abb 733 JUMP_TABLE(aout_32)
7ed4093a
SC
734};
735
736
737bfd_target b_out_vec_little_host =
738{
739 "b.out.little", /* name */
740 bfd_target_aout_flavour_enum,
741 false, /* data byte order is little */
742 false, /* header byte order is little */
743 (HAS_RELOC | EXEC_P | /* object flags */
744 HAS_LINENO | HAS_DEBUG |
745 HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT ),
746 (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
747 ' ', /* ar_pad_char */
748 16, /* ar_max_namelen */
87059abb 749 2, /* minum align */
7ed4093a
SC
750_do_getl64, _do_putl64, _do_getl32, _do_putl32, _do_getl16, _do_putl16, /* data */
751_do_getl64, _do_putl64, _do_getl32, _do_putl32, _do_getl16, _do_putl16, /* hdrs */
752
753 {_bfd_dummy_target, b_out_little_object_p, /* bfd_check_format */
754 bfd_generic_archive_p, _bfd_dummy_target},
755 {bfd_false, b_out_mkobject, /* bfd_set_format */
756 _bfd_generic_mkarchive, bfd_false},
757 {bfd_false, b_out_write_object_contents, /* bfd_write_contents */
758 _bfd_write_archive_contents, bfd_false},
87059abb 759 JUMP_TABLE(aout_32)
7ed4093a
SC
760};
761
This page took 0.055818 seconds and 4 git commands to generate.