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