1 /* outaout.c output routines for the Netwide Assembler to produce
2 * Linux a.out object files
4 * The Netwide Assembler is copyright (C) 1996 Simon Tatham and
5 * Julian Hall. All rights reserved. The software is
6 * redistributable under the licence given in the file "Licence"
7 * distributed in the NASM archive.
19 #if defined OF_AOUT || defined OF_AOUTB
21 #define RELTYPE_ABSOLUTE 0x00
22 #define RELTYPE_RELATIVE 0x01
23 #define RELTYPE_GOTPC 0x01 /* no explicit GOTPC in a.out */
24 #define RELTYPE_GOTOFF 0x10
25 #define RELTYPE_GOT 0x10 /* distinct from GOTOFF bcos sym not sect */
26 #define RELTYPE_PLT 0x21
27 #define RELTYPE_SYMFLAG 0x08
31 long address
; /* relative to _start_ of section */
32 long symbol
; /* symbol number or -ve section id */
33 int bytes
; /* 2 or 4 */
34 int reltype
; /* see above */
38 long strpos
; /* string table position of name */
39 int type
; /* symbol type - see flags below */
40 long value
; /* address, or COMMON variable size */
41 long size
; /* size for data or function exports */
42 long segment
; /* back-reference used by gsym_reloc */
43 struct Symbol
*next
; /* list of globals in each section */
44 struct Symbol
*nextfwd
; /* list of unresolved-size symbols */
45 char *name
; /* for unresolved-size symbols */
46 long symnum
; /* index into symbol table */
50 * Section IDs - used in Reloc.symbol when negative, and in
51 * Symbol.type when positive.
53 #define SECT_ABS 2 /* absolute value */
54 #define SECT_TEXT 4 /* text section */
55 #define SECT_DATA 6 /* data section */
56 #define SECT_BSS 8 /* bss section */
57 #define SECT_MASK 0xE /* mask out any of the above */
60 * More flags used in Symbol.type.
62 #define SYM_GLOBAL 1 /* it's a global symbol */
63 #define SYM_DATA 0x100 /* used for shared libs */
64 #define SYM_FUNCTION 0x200 /* used for shared libs */
65 #define SYM_WITH_SIZE 0x4000 /* not output; internal only */
68 * Bit more explanation of symbol types: SECT_xxx denotes a local
69 * symbol. SECT_xxx|SYM_GLOBAL denotes a global symbol, defined in
70 * this module. Just SYM_GLOBAL, with zero value, denotes an
71 * external symbol referenced in this module. And just SYM_GLOBAL,
72 * but with a non-zero value, declares a C `common' variable, of
78 unsigned long len
, size
, nrelocs
;
80 struct Reloc
*head
, **tail
;
81 struct Symbol
*gsyms
, *asym
;
84 static struct Section stext
, sdata
, sbss
;
86 static struct SAA
*syms
;
87 static unsigned long nsyms
;
89 static struct RAA
*bsym
;
91 static struct SAA
*strs
;
92 static unsigned long strslen
;
94 static struct Symbol
*fwds
;
98 static evalfunc evaluate
;
103 static void aout_write(void);
104 static void aout_write_relocs(struct Reloc
*);
105 static void aout_write_syms(void);
106 static void aout_sect_write(struct Section
*, unsigned char *, unsigned long);
107 static void aout_pad_sections(void);
108 static void aout_fixup_relocs(struct Section
*);
111 * Special section numbers which are used to define special
112 * symbols, which can be used with WRT to provide PIC relocation
115 static long aout_gotpc_sect
, aout_gotoff_sect
;
116 static long aout_got_sect
, aout_plt_sect
;
117 static long aout_sym_sect
;
119 static void aoutg_init(FILE *fp
, efunc errfunc
, ldfunc ldef
, evalfunc eval
)
124 (void) ldef
; /* placate optimisers */
125 stext
.data
= saa_init(1L); stext
.head
= NULL
; stext
.tail
= &stext
.head
;
126 sdata
.data
= saa_init(1L); sdata
.head
= NULL
; sdata
.tail
= &sdata
.head
;
127 stext
.len
= stext
.size
= sdata
.len
= sdata
.size
= sbss
.len
= 0;
128 stext
.nrelocs
= sdata
.nrelocs
= 0;
129 stext
.gsyms
= sdata
.gsyms
= sbss
.gsyms
= NULL
;
130 stext
.index
= seg_alloc();
131 sdata
.index
= seg_alloc();
132 sbss
.index
= seg_alloc();
133 stext
.asym
= sdata
.asym
= sbss
.asym
= NULL
;
134 syms
= saa_init((long)sizeof(struct Symbol
));
144 static void aout_init(FILE *fp
, efunc errfunc
, ldfunc ldef
, evalfunc eval
)
147 aoutg_init (fp
, errfunc
, ldef
, eval
);
149 aout_gotpc_sect
= aout_gotoff_sect
= aout_got_sect
=
150 aout_plt_sect
= aout_sym_sect
= NO_SEG
;
157 extern struct ofmt of_aoutb
;
159 static void aoutb_init(FILE *fp
, efunc errfunc
, ldfunc ldef
, evalfunc eval
)
162 aoutg_init (fp
, errfunc
, ldef
, eval
);
164 is_pic
= 0x00; /* may become 0x40 */
166 aout_gotpc_sect
= seg_alloc();
167 ldef("..gotpc", aout_gotpc_sect
+1, 0L, NULL
, FALSE
,FALSE
,&of_aoutb
,error
);
168 aout_gotoff_sect
= seg_alloc();
169 ldef("..gotoff", aout_gotoff_sect
+1, 0L,NULL
,FALSE
,FALSE
,&of_aoutb
,error
);
170 aout_got_sect
= seg_alloc();
171 ldef("..got", aout_got_sect
+1, 0L, NULL
, FALSE
,FALSE
,&of_aoutb
,error
);
172 aout_plt_sect
= seg_alloc();
173 ldef("..plt", aout_plt_sect
+1, 0L, NULL
, FALSE
,FALSE
,&of_aoutb
,error
);
174 aout_sym_sect
= seg_alloc();
175 ldef("..sym", aout_sym_sect
+1, 0L, NULL
, FALSE
,FALSE
,&of_aoutb
,error
);
180 static void aout_cleanup(int debuginfo
)
187 aout_fixup_relocs(&stext
);
188 aout_fixup_relocs(&sdata
);
191 saa_free (stext
.data
);
194 stext
.head
= stext
.head
->next
;
197 saa_free (sdata
.data
);
200 sdata
.head
= sdata
.head
->next
;
208 static long aout_section_names (char *name
, int pass
, int *bits
)
211 * Default to 32 bits.
219 if (!strcmp(name
, ".text"))
221 else if (!strcmp(name
, ".data"))
223 else if (!strcmp(name
, ".bss"))
229 static void aout_deflabel (char *name
, long segment
, long offset
,
230 int is_global
, char *special
)
234 int special_used
= FALSE
;
236 if (name
[0] == '.' && name
[1] == '.' && name
[2] != '@') {
238 * This is a NASM special symbol. We never allow it into
239 * the a.out symbol table, even if it's a valid one. If it
240 * _isn't_ a valid one, we should barf immediately.
242 if (strcmp(name
, "..gotpc") && strcmp(name
, "..gotoff") &&
243 strcmp(name
, "..got") && strcmp(name
, "..plt") &&
244 strcmp(name
, "..sym"))
245 error (ERR_NONFATAL
, "unrecognised special symbol `%s'", name
);
249 if (is_global
== 3) {
252 * Fix up a forward-reference symbol size from the first
255 for (s
= &fwds
; *s
; s
= &(*s
)->nextfwd
)
256 if (!strcmp((*s
)->name
, name
)) {
257 struct tokenval tokval
;
261 while (*p
&& !isspace(*p
)) p
++;
262 while (*p
&& isspace(*p
)) p
++;
265 tokval
.t_type
= TOKEN_INVALID
;
266 e
= evaluate(stdscan
, NULL
, &tokval
, NULL
, 1, error
, NULL
);
269 error (ERR_NONFATAL
, "cannot use relocatable"
270 " expression as symbol size");
272 (*s
)->size
= reloc_value(e
);
276 * Remove it from the list of unresolved sizes.
278 nasm_free ((*s
)->name
);
282 return; /* it wasn't an important one */
285 saa_wbytes (strs
, name
, (long)(1+strlen(name
)));
286 strslen
+= 1+strlen(name
);
288 sym
= saa_wstruct (syms
);
291 sym
->type
= is_global
? SYM_GLOBAL
: 0;
292 sym
->segment
= segment
;
293 if (segment
== NO_SEG
)
294 sym
->type
|= SECT_ABS
;
295 else if (segment
== stext
.index
) {
296 sym
->type
|= SECT_TEXT
;
298 sym
->next
= stext
.gsyms
;
300 } else if (!stext
.asym
)
302 } else if (segment
== sdata
.index
) {
303 sym
->type
|= SECT_DATA
;
305 sym
->next
= sdata
.gsyms
;
307 } else if (!sdata
.asym
)
309 } else if (segment
== sbss
.index
) {
310 sym
->type
|= SECT_BSS
;
312 sym
->next
= sbss
.gsyms
;
314 } else if (!sbss
.asym
)
317 sym
->type
= SYM_GLOBAL
;
321 sym
->value
= (sym
->type
== SYM_GLOBAL
? 0 : offset
);
323 if (is_global
&& sym
->type
!= SYM_GLOBAL
) {
325 * Global symbol exported _from_ this module. We must check
326 * the special text for type information.
330 int n
= strcspn(special
, " ");
332 if (!nasm_strnicmp(special
, "function", n
))
333 sym
->type
|= SYM_FUNCTION
;
334 else if (!nasm_strnicmp(special
, "data", n
) ||
335 !nasm_strnicmp(special
, "object", n
))
336 sym
->type
|= SYM_DATA
;
338 error(ERR_NONFATAL
, "unrecognised symbol type `%.*s'",
341 struct tokenval tokval
;
346 error(ERR_NONFATAL
, "Linux a.out does not support"
347 " symbol size information");
349 while (special
[n
] && isspace(special
[n
]))
352 * We have a size expression; attempt to
355 sym
->type
|= SYM_WITH_SIZE
;
357 stdscan_bufptr
= special
+n
;
358 tokval
.t_type
= TOKEN_INVALID
;
359 e
= evaluate(stdscan
, NULL
, &tokval
, &fwd
, 0, error
, NULL
);
363 sym
->name
= nasm_strdup(name
);
366 error (ERR_NONFATAL
, "cannot use relocatable"
367 " expression as symbol size");
369 sym
->size
= reloc_value(e
);
378 * define the references from external-symbol segment numbers
379 * to these symbol records.
381 if (segment
!= NO_SEG
&& segment
!= stext
.index
&&
382 segment
!= sdata
.index
&& segment
!= sbss
.index
)
383 bsym
= raa_write (bsym
, segment
, nsyms
);
387 if (sym
->type
& SYM_WITH_SIZE
)
388 nsyms
++; /* and another for the size */
390 if (special
&& !special_used
)
391 error(ERR_NONFATAL
, "no special symbol features supported here");
394 static void aout_add_reloc (struct Section
*sect
, long segment
,
395 int reltype
, int bytes
)
399 r
= *sect
->tail
= nasm_malloc(sizeof(struct Reloc
));
400 sect
->tail
= &r
->next
;
403 r
->address
= sect
->len
;
404 r
->symbol
= (segment
== NO_SEG
? -SECT_ABS
:
405 segment
== stext
.index
? -SECT_TEXT
:
406 segment
== sdata
.index
? -SECT_DATA
:
407 segment
== sbss
.index
? -SECT_BSS
:
408 raa_read(bsym
, segment
));
409 r
->reltype
= reltype
;
411 r
->reltype
|= RELTYPE_SYMFLAG
;
418 * This routine deals with ..got and ..sym relocations: the more
419 * complicated kinds. In shared-library writing, some relocations
420 * with respect to global symbols must refer to the precise symbol
421 * rather than referring to an offset from the base of the section
422 * _containing_ the symbol. Such relocations call to this routine,
423 * which searches the symbol list for the symbol in question.
425 * RELTYPE_GOT references require the _exact_ symbol address to be
426 * used; RELTYPE_ABSOLUTE references can be at an offset from the
427 * symbol. The boolean argument `exact' tells us this.
429 * Return value is the adjusted value of `addr', having become an
430 * offset from the symbol rather than the section. Should always be
431 * zero when returning from an exact call.
433 * Limitation: if you define two symbols at the same place,
434 * confusion will occur.
436 * Inefficiency: we search, currently, using a linked list which
437 * isn't even necessarily sorted.
439 static long aout_add_gsym_reloc (struct Section
*sect
,
440 long segment
, long offset
,
441 int type
, int bytes
, int exact
)
443 struct Symbol
*sym
, *sm
, *shead
;
447 * First look up the segment to find whether it's text, data,
448 * bss or an external symbol.
451 if (segment
== stext
.index
)
453 else if (segment
== sdata
.index
)
455 else if (segment
== sbss
.index
)
458 if (exact
&& offset
!= 0)
459 error (ERR_NONFATAL
, "unable to find a suitable global symbol"
460 " for this reference");
462 aout_add_reloc (sect
, segment
, type
, bytes
);
468 * Find a symbol pointing _exactly_ at this one.
470 for (sym
= shead
; sym
; sym
= sym
->next
)
471 if (sym
->value
== offset
)
475 * Find the nearest symbol below this one.
478 for (sm
= shead
; sm
; sm
= sm
->next
)
479 if (sm
->value
<= offset
&& (!sym
|| sm
->value
> sym
->value
))
483 error (ERR_NONFATAL
, "unable to find a suitable global symbol"
484 " for this reference");
488 r
= *sect
->tail
= nasm_malloc(sizeof(struct Reloc
));
489 sect
->tail
= &r
->next
;
492 r
->address
= sect
->len
;
493 r
->symbol
= sym
->symnum
;
494 r
->reltype
= type
| RELTYPE_SYMFLAG
;
499 return offset
- sym
->value
;
503 * This routine deals with ..gotoff relocations. These _must_ refer
504 * to a symbol, due to a perversity of *BSD's PIC implementation,
505 * and it must be a non-global one as well; so we store `asym', the
506 * first nonglobal symbol defined in each section, and always work
507 * from that. Relocation type is always RELTYPE_GOTOFF.
509 * Return value is the adjusted value of `addr', having become an
510 * offset from the `asym' symbol rather than the section.
512 static long aout_add_gotoff_reloc (struct Section
*sect
, long segment
,
513 long offset
, int bytes
)
519 * First look up the segment to find whether it's text, data,
520 * bss or an external symbol.
523 if (segment
== stext
.index
)
525 else if (segment
== sdata
.index
)
527 else if (segment
== sbss
.index
)
530 error (ERR_NONFATAL
, "`..gotoff' relocations require a non-global"
531 " symbol in the section");
533 r
= *sect
->tail
= nasm_malloc(sizeof(struct Reloc
));
534 sect
->tail
= &r
->next
;
537 r
->address
= sect
->len
;
538 r
->symbol
= asym
->symnum
;
539 r
->reltype
= RELTYPE_GOTOFF
;
544 return offset
- asym
->value
;
547 static void aout_out (long segto
, void *data
, unsigned long type
,
548 long segment
, long wrt
)
551 long realbytes
= type
& OUT_SIZMASK
;
553 unsigned char mydata
[4], *p
;
558 * handle absolute-assembly (structure definitions)
560 if (segto
== NO_SEG
) {
561 if (type
!= OUT_RESERVE
)
562 error (ERR_NONFATAL
, "attempt to assemble code in [ABSOLUTE]"
567 if (segto
== stext
.index
)
569 else if (segto
== sdata
.index
)
571 else if (segto
== sbss
.index
)
574 error(ERR_WARNING
, "attempt to assemble code in"
575 " segment %d: defaulting to `.text'", segto
);
579 if (!s
&& type
!= OUT_RESERVE
) {
580 error(ERR_WARNING
, "attempt to initialise memory in the"
581 " BSS section: ignored");
582 if (type
== OUT_REL2ADR
)
584 else if (type
== OUT_REL4ADR
)
586 sbss
.len
+= realbytes
;
590 if (type
== OUT_RESERVE
) {
592 error(ERR_WARNING
, "uninitialised space declared in"
593 " %s section: zeroing",
594 (segto
== stext
.index
? "code" : "data"));
595 aout_sect_write (s
, NULL
, realbytes
);
597 sbss
.len
+= realbytes
;
598 } else if (type
== OUT_RAWDATA
) {
599 if (segment
!= NO_SEG
)
600 error(ERR_PANIC
, "OUT_RAWDATA with other than NO_SEG");
601 aout_sect_write (s
, data
, realbytes
);
602 } else if (type
== OUT_ADDRESS
) {
603 addr
= *(long *)data
;
604 if (segment
!= NO_SEG
) {
606 error(ERR_NONFATAL
, "a.out format does not support"
607 " segment base references");
610 aout_add_reloc (s
, segment
, RELTYPE_ABSOLUTE
, realbytes
);
612 error (ERR_NONFATAL
, "Linux a.out format does not support"
614 wrt
= NO_SEG
; /* we can at least _try_ to continue */
615 } else if (wrt
== aout_gotpc_sect
+1) {
617 aout_add_reloc (s
, segment
, RELTYPE_GOTPC
, realbytes
);
618 } else if (wrt
== aout_gotoff_sect
+1) {
620 addr
= aout_add_gotoff_reloc (s
, segment
,
622 } else if (wrt
== aout_got_sect
+1) {
624 addr
= aout_add_gsym_reloc (s
, segment
, addr
, RELTYPE_GOT
,
626 } else if (wrt
== aout_sym_sect
+1) {
627 addr
= aout_add_gsym_reloc (s
, segment
, addr
,
628 RELTYPE_ABSOLUTE
, realbytes
,
630 } else if (wrt
== aout_plt_sect
+1) {
632 error(ERR_NONFATAL
, "a.out format cannot produce non-PC-"
633 "relative PLT references");
635 error (ERR_NONFATAL
, "a.out format does not support this"
637 wrt
= NO_SEG
; /* we can at least _try_ to continue */
643 WRITESHORT (p
, addr
);
646 aout_sect_write (s
, mydata
, realbytes
);
647 } else if (type
== OUT_REL2ADR
) {
648 if (segment
== segto
)
649 error(ERR_PANIC
, "intra-segment OUT_REL2ADR");
650 if (segment
!= NO_SEG
&& segment
% 2) {
651 error(ERR_NONFATAL
, "a.out format does not support"
652 " segment base references");
655 aout_add_reloc (s
, segment
, RELTYPE_RELATIVE
, 2);
657 error (ERR_NONFATAL
, "Linux a.out format does not support"
659 wrt
= NO_SEG
; /* we can at least _try_ to continue */
660 } else if (wrt
== aout_plt_sect
+1) {
662 aout_add_reloc (s
, segment
, RELTYPE_PLT
, 2);
663 } else if (wrt
== aout_gotpc_sect
+1 ||
664 wrt
== aout_gotoff_sect
+1 ||
665 wrt
== aout_got_sect
+1) {
666 error(ERR_NONFATAL
, "a.out format cannot produce PC-"
667 "relative GOT references");
669 error (ERR_NONFATAL
, "a.out format does not support this"
671 wrt
= NO_SEG
; /* we can at least _try_ to continue */
675 WRITESHORT (p
, *(long*)data
-(realbytes
+ s
->len
));
676 aout_sect_write (s
, mydata
, 2L);
677 } else if (type
== OUT_REL4ADR
) {
678 if (segment
== segto
)
679 error(ERR_PANIC
, "intra-segment OUT_REL4ADR");
680 if (segment
!= NO_SEG
&& segment
% 2) {
681 error(ERR_NONFATAL
, "a.out format does not support"
682 " segment base references");
685 aout_add_reloc (s
, segment
, RELTYPE_RELATIVE
, 4);
687 error (ERR_NONFATAL
, "Linux a.out format does not support"
689 wrt
= NO_SEG
; /* we can at least _try_ to continue */
690 } else if (wrt
== aout_plt_sect
+1) {
692 aout_add_reloc (s
, segment
, RELTYPE_PLT
, 4);
693 } else if (wrt
== aout_gotpc_sect
+1 ||
694 wrt
== aout_gotoff_sect
+1 ||
695 wrt
== aout_got_sect
+1) {
696 error(ERR_NONFATAL
, "a.out format cannot produce PC-"
697 "relative GOT references");
699 error (ERR_NONFATAL
, "a.out format does not support this"
701 wrt
= NO_SEG
; /* we can at least _try_ to continue */
705 WRITELONG (p
, *(long*)data
-(realbytes
+ s
->len
));
706 aout_sect_write (s
, mydata
, 4L);
710 static void aout_pad_sections(void)
712 static unsigned char pad
[] = { 0x90, 0x90, 0x90, 0x90 };
714 * Pad each of the text and data sections with NOPs until their
715 * length is a multiple of four. (NOP == 0x90.) Also increase
716 * the length of the BSS section similarly.
718 aout_sect_write (&stext
, pad
, (-(long)stext
.len
) & 3);
719 aout_sect_write (&sdata
, pad
, (-(long)sdata
.len
) & 3);
720 sbss
.len
= (sbss
.len
+ 3) & ~3;
724 * a.out files have the curious property that all references to
725 * things in the data or bss sections are done by addresses which
726 * are actually relative to the start of the _text_ section, in the
727 * _file_. (No relation to what happens after linking. No idea why
728 * this should be so. It's very strange.) So we have to go through
729 * the relocation table, _after_ the final size of each section is
730 * known, and fix up the relocations pointed to.
732 static void aout_fixup_relocs(struct Section
*sect
)
736 saa_rewind (sect
->data
);
737 for (r
= sect
->head
; r
; r
= r
->next
) {
738 unsigned char *p
, *q
, blk
[4];
741 saa_fread (sect
->data
, r
->address
, blk
, (long)r
->bytes
);
745 l
+= ((long)*p
++) << 8;
747 l
+= ((long)*p
++) << 16;
748 l
+= ((long)*p
++) << 24;
751 if (r
->symbol
== -SECT_DATA
)
753 else if (r
->symbol
== -SECT_BSS
)
754 l
+= stext
.len
+ sdata
.len
;
757 else if (r
->bytes
== 2)
761 saa_fwrite (sect
->data
, r
->address
, blk
, (long)r
->bytes
);
765 static void aout_write(void)
768 * Emit the a.out header.
770 /* OMAGIC, M_386 or MID_I386, no flags */
771 fwritelong (bsd
? 0x07018600 | is_pic
: 0x640107L
, aoutfp
);
772 fwritelong (stext
.len
, aoutfp
);
773 fwritelong (sdata
.len
, aoutfp
);
774 fwritelong (sbss
.len
, aoutfp
);
775 fwritelong (nsyms
* 12, aoutfp
); /* length of symbol table */
776 fwritelong (0L, aoutfp
); /* object files have no entry point */
777 fwritelong (stext
.nrelocs
* 8, aoutfp
); /* size of text relocs */
778 fwritelong (sdata
.nrelocs
* 8, aoutfp
); /* size of data relocs */
781 * Write out the code section and the data section.
783 saa_fpwrite (stext
.data
, aoutfp
);
784 saa_fpwrite (sdata
.data
, aoutfp
);
787 * Write out the relocations.
789 aout_write_relocs (stext
.head
);
790 aout_write_relocs (sdata
.head
);
793 * Write the symbol table.
798 * And the string table.
800 fwritelong (strslen
+4, aoutfp
); /* length includes length count */
801 saa_fpwrite (strs
, aoutfp
);
804 static void aout_write_relocs (struct Reloc
*r
)
809 fwritelong (r
->address
, aoutfp
);
815 word2
|= r
->reltype
<< 24;
816 word2
|= (r
->bytes
== 1 ? 0 :
817 r
->bytes
== 2 ? 0x2000000L
: 0x4000000L
);
818 fwritelong (word2
, aoutfp
);
824 static void aout_write_syms (void)
829 for (i
=0; i
<nsyms
; i
++) {
830 struct Symbol
*sym
= saa_rstruct(syms
);
831 fwritelong (sym
->strpos
, aoutfp
);
832 fwritelong ((long)sym
->type
& ~SYM_WITH_SIZE
, aoutfp
);
834 * Fix up the symbol value now we know the final section
837 if ((sym
->type
& SECT_MASK
) == SECT_DATA
)
838 sym
->value
+= stext
.len
;
839 if ((sym
->type
& SECT_MASK
) == SECT_BSS
)
840 sym
->value
+= stext
.len
+ sdata
.len
;
841 fwritelong (sym
->value
, aoutfp
);
843 * Output a size record if necessary.
845 if (sym
->type
& SYM_WITH_SIZE
) {
846 fwritelong(sym
->strpos
, aoutfp
);
847 fwritelong(0x0DL
, aoutfp
); /* special value: means size */
848 fwritelong(sym
->size
, aoutfp
);
849 i
++; /* use up another of `nsyms' */
854 static void aout_sect_write (struct Section
*sect
,
855 unsigned char *data
, unsigned long len
)
857 saa_wbytes (sect
->data
, data
, len
);
861 static long aout_segbase (long segment
)
866 static int aout_directive (char *directive
, char *value
, int pass
)
871 static void aout_filename (char *inname
, char *outname
, efunc error
)
873 standard_extension (inname
, outname
, ".o", error
);
876 static char *aout_stdmac
[] = {
877 "%define __SECT__ [section .text]",
878 "%macro __NASM_CDecl__ 1",
883 static int aout_set_info(enum geninfo type
, char **val
)
887 #endif /* OF_AOUT || OF_AOUTB */
891 struct ofmt of_aout
= {
892 "Linux a.out object files",
913 struct ofmt of_aoutb
= {
914 "NetBSD/FreeBSD a.out object files",