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 license given in the file "LICENSE"
7 * distributed in the NASM archive.
24 #if defined OF_AOUT || defined OF_AOUTB
26 #define RELTYPE_ABSOLUTE 0x00
27 #define RELTYPE_RELATIVE 0x01
28 #define RELTYPE_GOTPC 0x01 /* no explicit GOTPC in a.out */
29 #define RELTYPE_GOTOFF 0x10
30 #define RELTYPE_GOT 0x10 /* distinct from GOTOFF bcos sym not sect */
31 #define RELTYPE_PLT 0x21
32 #define RELTYPE_SYMFLAG 0x08
36 int32_t address
; /* relative to _start_ of section */
37 int32_t symbol
; /* symbol number or -ve section id */
38 int bytes
; /* 2 or 4 */
39 int reltype
; /* see above */
43 int32_t strpos
; /* string table position of name */
44 int type
; /* symbol type - see flags below */
45 int32_t value
; /* address, or COMMON variable size */
46 int32_t size
; /* size for data or function exports */
47 int32_t segment
; /* back-reference used by gsym_reloc */
48 struct Symbol
*next
; /* list of globals in each section */
49 struct Symbol
*nextfwd
; /* list of unresolved-size symbols */
50 char *name
; /* for unresolved-size symbols */
51 int32_t symnum
; /* index into symbol table */
55 * Section IDs - used in Reloc.symbol when negative, and in
56 * Symbol.type when positive.
58 #define SECT_ABS 2 /* absolute value */
59 #define SECT_TEXT 4 /* text section */
60 #define SECT_DATA 6 /* data section */
61 #define SECT_BSS 8 /* bss section */
62 #define SECT_MASK 0xE /* mask out any of the above */
65 * More flags used in Symbol.type.
67 #define SYM_GLOBAL 1 /* it's a global symbol */
68 #define SYM_DATA 0x100 /* used for shared libs */
69 #define SYM_FUNCTION 0x200 /* used for shared libs */
70 #define SYM_WITH_SIZE 0x4000 /* not output; internal only */
73 * Bit more explanation of symbol types: SECT_xxx denotes a local
74 * symbol. SECT_xxx|SYM_GLOBAL denotes a global symbol, defined in
75 * this module. Just SYM_GLOBAL, with zero value, denotes an
76 * external symbol referenced in this module. And just SYM_GLOBAL,
77 * but with a non-zero value, declares a C `common' variable, of
83 uint32_t len
, size
, nrelocs
;
85 struct Reloc
*head
, **tail
;
86 struct Symbol
*gsyms
, *asym
;
89 static struct Section stext
, sdata
, sbss
;
91 static struct SAA
*syms
;
92 static uint32_t nsyms
;
94 static struct RAA
*bsym
;
96 static struct SAA
*strs
;
97 static uint32_t strslen
;
99 static struct Symbol
*fwds
;
103 static evalfunc evaluate
;
108 static void aout_write(void);
109 static void aout_write_relocs(struct Reloc
*);
110 static void aout_write_syms(void);
111 static void aout_sect_write(struct Section
*, const uint8_t *,
113 static void aout_pad_sections(void);
114 static void aout_fixup_relocs(struct Section
*);
117 * Special section numbers which are used to define special
118 * symbols, which can be used with WRT to provide PIC relocation
121 static int32_t aout_gotpc_sect
, aout_gotoff_sect
;
122 static int32_t aout_got_sect
, aout_plt_sect
;
123 static int32_t aout_sym_sect
;
125 static void aoutg_init(FILE * fp
, efunc errfunc
, ldfunc ldef
,
131 (void)ldef
; /* placate optimisers */
132 stext
.data
= saa_init(1L);
134 stext
.tail
= &stext
.head
;
135 sdata
.data
= saa_init(1L);
137 sdata
.tail
= &sdata
.head
;
138 stext
.len
= stext
.size
= sdata
.len
= sdata
.size
= sbss
.len
= 0;
139 stext
.nrelocs
= sdata
.nrelocs
= 0;
140 stext
.gsyms
= sdata
.gsyms
= sbss
.gsyms
= NULL
;
141 stext
.index
= seg_alloc();
142 sdata
.index
= seg_alloc();
143 sbss
.index
= seg_alloc();
144 stext
.asym
= sdata
.asym
= sbss
.asym
= NULL
;
145 syms
= saa_init((int32_t)sizeof(struct Symbol
));
155 static void aout_init(FILE * fp
, efunc errfunc
, ldfunc ldef
, evalfunc eval
)
158 aoutg_init(fp
, errfunc
, ldef
, eval
);
160 aout_gotpc_sect
= aout_gotoff_sect
= aout_got_sect
=
161 aout_plt_sect
= aout_sym_sect
= NO_SEG
;
168 extern struct ofmt of_aoutb
;
170 static void aoutb_init(FILE * fp
, efunc errfunc
, ldfunc ldef
,
174 aoutg_init(fp
, errfunc
, ldef
, eval
);
176 is_pic
= 0x00; /* may become 0x40 */
178 aout_gotpc_sect
= seg_alloc();
179 ldef("..gotpc", aout_gotpc_sect
+ 1, 0L, NULL
, false, false, &of_aoutb
,
181 aout_gotoff_sect
= seg_alloc();
182 ldef("..gotoff", aout_gotoff_sect
+ 1, 0L, NULL
, false, false,
184 aout_got_sect
= seg_alloc();
185 ldef("..got", aout_got_sect
+ 1, 0L, NULL
, false, false, &of_aoutb
,
187 aout_plt_sect
= seg_alloc();
188 ldef("..plt", aout_plt_sect
+ 1, 0L, NULL
, false, false, &of_aoutb
,
190 aout_sym_sect
= seg_alloc();
191 ldef("..sym", aout_sym_sect
+ 1, 0L, NULL
, false, false, &of_aoutb
,
197 static void aout_cleanup(int debuginfo
)
204 aout_fixup_relocs(&stext
);
205 aout_fixup_relocs(&sdata
);
208 saa_free(stext
.data
);
211 stext
.head
= stext
.head
->next
;
214 saa_free(sdata
.data
);
217 sdata
.head
= sdata
.head
->next
;
225 static int32_t aout_section_names(char *name
, int pass
, int *bits
)
231 * Default to 32 bits.
239 if (!strcmp(name
, ".text"))
241 else if (!strcmp(name
, ".data"))
243 else if (!strcmp(name
, ".bss"))
249 static void aout_deflabel(char *name
, int32_t segment
, int64_t offset
,
250 int is_global
, char *special
)
252 int pos
= strslen
+ 4;
254 int special_used
= false;
256 if (name
[0] == '.' && name
[1] == '.' && name
[2] != '@') {
258 * This is a NASM special symbol. We never allow it into
259 * the a.out symbol table, even if it's a valid one. If it
260 * _isn't_ a valid one, we should barf immediately.
262 if (strcmp(name
, "..gotpc") && strcmp(name
, "..gotoff") &&
263 strcmp(name
, "..got") && strcmp(name
, "..plt") &&
264 strcmp(name
, "..sym"))
265 error(ERR_NONFATAL
, "unrecognised special symbol `%s'", name
);
269 if (is_global
== 3) {
272 * Fix up a forward-reference symbol size from the first
275 for (s
= &fwds
; *s
; s
= &(*s
)->nextfwd
)
276 if (!strcmp((*s
)->name
, name
)) {
277 struct tokenval tokval
;
281 while (*p
&& !isspace(*p
))
283 while (*p
&& isspace(*p
))
287 tokval
.t_type
= TOKEN_INVALID
;
288 e
= evaluate(stdscan
, NULL
, &tokval
, NULL
, 1, error
, NULL
);
291 error(ERR_NONFATAL
, "cannot use relocatable"
292 " expression as symbol size");
294 (*s
)->size
= reloc_value(e
);
298 * Remove it from the list of unresolved sizes.
300 nasm_free((*s
)->name
);
304 return; /* it wasn't an important one */
307 saa_wbytes(strs
, name
, (int32_t)(1 + strlen(name
)));
308 strslen
+= 1 + strlen(name
);
310 sym
= saa_wstruct(syms
);
313 sym
->type
= is_global
? SYM_GLOBAL
: 0;
314 sym
->segment
= segment
;
315 if (segment
== NO_SEG
)
316 sym
->type
|= SECT_ABS
;
317 else if (segment
== stext
.index
) {
318 sym
->type
|= SECT_TEXT
;
320 sym
->next
= stext
.gsyms
;
322 } else if (!stext
.asym
)
324 } else if (segment
== sdata
.index
) {
325 sym
->type
|= SECT_DATA
;
327 sym
->next
= sdata
.gsyms
;
329 } else if (!sdata
.asym
)
331 } else if (segment
== sbss
.index
) {
332 sym
->type
|= SECT_BSS
;
334 sym
->next
= sbss
.gsyms
;
336 } else if (!sbss
.asym
)
339 sym
->type
= SYM_GLOBAL
;
343 sym
->value
= (sym
->type
== SYM_GLOBAL
? 0 : offset
);
345 if (is_global
&& sym
->type
!= SYM_GLOBAL
) {
347 * Global symbol exported _from_ this module. We must check
348 * the special text for type information.
352 int n
= strcspn(special
, " ");
354 if (!nasm_strnicmp(special
, "function", n
))
355 sym
->type
|= SYM_FUNCTION
;
356 else if (!nasm_strnicmp(special
, "data", n
) ||
357 !nasm_strnicmp(special
, "object", n
))
358 sym
->type
|= SYM_DATA
;
360 error(ERR_NONFATAL
, "unrecognised symbol type `%.*s'",
363 struct tokenval tokval
;
366 char *saveme
= stdscan_bufptr
; /* bugfix? fbk 8/10/00 */
369 error(ERR_NONFATAL
, "Linux a.out does not support"
370 " symbol size information");
372 while (special
[n
] && isspace(special
[n
]))
375 * We have a size expression; attempt to
378 sym
->type
|= SYM_WITH_SIZE
;
380 stdscan_bufptr
= special
+ n
;
381 tokval
.t_type
= TOKEN_INVALID
;
382 e
= evaluate(stdscan
, NULL
, &tokval
, &fwd
, 0, error
,
387 sym
->name
= nasm_strdup(name
);
390 error(ERR_NONFATAL
, "cannot use relocatable"
391 " expression as symbol size");
393 sym
->size
= reloc_value(e
);
396 stdscan_bufptr
= saveme
; /* bugfix? fbk 8/10/00 */
403 * define the references from external-symbol segment numbers
404 * to these symbol records.
406 if (segment
!= NO_SEG
&& segment
!= stext
.index
&&
407 segment
!= sdata
.index
&& segment
!= sbss
.index
)
408 bsym
= raa_write(bsym
, segment
, nsyms
);
412 if (sym
->type
& SYM_WITH_SIZE
)
413 nsyms
++; /* and another for the size */
415 if (special
&& !special_used
)
416 error(ERR_NONFATAL
, "no special symbol features supported here");
419 static void aout_add_reloc(struct Section
*sect
, int32_t segment
,
420 int reltype
, int bytes
)
424 r
= *sect
->tail
= nasm_malloc(sizeof(struct Reloc
));
425 sect
->tail
= &r
->next
;
428 r
->address
= sect
->len
;
429 r
->symbol
= (segment
== NO_SEG
? -SECT_ABS
:
430 segment
== stext
.index
? -SECT_TEXT
:
431 segment
== sdata
.index
? -SECT_DATA
:
432 segment
== sbss
.index
? -SECT_BSS
:
433 raa_read(bsym
, segment
));
434 r
->reltype
= reltype
;
436 r
->reltype
|= RELTYPE_SYMFLAG
;
443 * This routine deals with ..got and ..sym relocations: the more
444 * complicated kinds. In shared-library writing, some relocations
445 * with respect to global symbols must refer to the precise symbol
446 * rather than referring to an offset from the base of the section
447 * _containing_ the symbol. Such relocations call to this routine,
448 * which searches the symbol list for the symbol in question.
450 * RELTYPE_GOT references require the _exact_ symbol address to be
451 * used; RELTYPE_ABSOLUTE references can be at an offset from the
452 * symbol. The boolean argument `exact' tells us this.
454 * Return value is the adjusted value of `addr', having become an
455 * offset from the symbol rather than the section. Should always be
456 * zero when returning from an exact call.
458 * Limitation: if you define two symbols at the same place,
459 * confusion will occur.
461 * Inefficiency: we search, currently, using a linked list which
462 * isn't even necessarily sorted.
464 static int32_t aout_add_gsym_reloc(struct Section
*sect
,
465 int32_t segment
, int32_t offset
,
466 int type
, int bytes
, int exact
)
468 struct Symbol
*sym
, *sm
, *shead
;
472 * First look up the segment to find whether it's text, data,
473 * bss or an external symbol.
476 if (segment
== stext
.index
)
478 else if (segment
== sdata
.index
)
480 else if (segment
== sbss
.index
)
483 if (exact
&& offset
!= 0)
484 error(ERR_NONFATAL
, "unable to find a suitable global symbol"
485 " for this reference");
487 aout_add_reloc(sect
, segment
, type
, bytes
);
493 * Find a symbol pointing _exactly_ at this one.
495 for (sym
= shead
; sym
; sym
= sym
->next
)
496 if (sym
->value
== offset
)
500 * Find the nearest symbol below this one.
503 for (sm
= shead
; sm
; sm
= sm
->next
)
504 if (sm
->value
<= offset
&& (!sym
|| sm
->value
> sym
->value
))
508 error(ERR_NONFATAL
, "unable to find a suitable global symbol"
509 " for this reference");
513 r
= *sect
->tail
= nasm_malloc(sizeof(struct Reloc
));
514 sect
->tail
= &r
->next
;
517 r
->address
= sect
->len
;
518 r
->symbol
= sym
->symnum
;
519 r
->reltype
= type
| RELTYPE_SYMFLAG
;
524 return offset
- sym
->value
;
528 * This routine deals with ..gotoff relocations. These _must_ refer
529 * to a symbol, due to a perversity of *BSD's PIC implementation,
530 * and it must be a non-global one as well; so we store `asym', the
531 * first nonglobal symbol defined in each section, and always work
532 * from that. Relocation type is always RELTYPE_GOTOFF.
534 * Return value is the adjusted value of `addr', having become an
535 * offset from the `asym' symbol rather than the section.
537 static int32_t aout_add_gotoff_reloc(struct Section
*sect
, int32_t segment
,
538 int32_t offset
, int bytes
)
544 * First look up the segment to find whether it's text, data,
545 * bss or an external symbol.
548 if (segment
== stext
.index
)
550 else if (segment
== sdata
.index
)
552 else if (segment
== sbss
.index
)
555 error(ERR_NONFATAL
, "`..gotoff' relocations require a non-global"
556 " symbol in the section");
558 r
= *sect
->tail
= nasm_malloc(sizeof(struct Reloc
));
559 sect
->tail
= &r
->next
;
562 r
->address
= sect
->len
;
563 r
->symbol
= asym
->symnum
;
564 r
->reltype
= RELTYPE_GOTOFF
;
569 return offset
- asym
->value
;
572 static void aout_out(int32_t segto
, const void *data
,
573 enum out_type type
, uint64_t size
,
574 int32_t segment
, int32_t wrt
)
578 uint8_t mydata
[4], *p
;
581 * handle absolute-assembly (structure definitions)
583 if (segto
== NO_SEG
) {
584 if (type
!= OUT_RESERVE
)
585 error(ERR_NONFATAL
, "attempt to assemble code in [ABSOLUTE]"
590 if (segto
== stext
.index
)
592 else if (segto
== sdata
.index
)
594 else if (segto
== sbss
.index
)
597 error(ERR_WARNING
, "attempt to assemble code in"
598 " segment %d: defaulting to `.text'", segto
);
602 if (!s
&& type
!= OUT_RESERVE
) {
603 error(ERR_WARNING
, "attempt to initialize memory in the"
604 " BSS section: ignored");
605 if (type
== OUT_REL2ADR
)
607 else if (type
== OUT_REL4ADR
)
613 if (type
== OUT_RESERVE
) {
615 error(ERR_WARNING
, "uninitialized space declared in"
616 " %s section: zeroing",
617 (segto
== stext
.index
? "code" : "data"));
618 aout_sect_write(s
, NULL
, size
);
621 } else if (type
== OUT_RAWDATA
) {
622 if (segment
!= NO_SEG
)
623 error(ERR_PANIC
, "OUT_RAWDATA with other than NO_SEG");
624 aout_sect_write(s
, data
, size
);
625 } else if (type
== OUT_ADDRESS
) {
626 addr
= *(int64_t *)data
;
627 if (segment
!= NO_SEG
) {
629 error(ERR_NONFATAL
, "a.out format does not support"
630 " segment base references");
633 aout_add_reloc(s
, segment
, RELTYPE_ABSOLUTE
,
637 "Linux a.out format does not support"
639 wrt
= NO_SEG
; /* we can at least _try_ to continue */
640 } else if (wrt
== aout_gotpc_sect
+ 1) {
642 aout_add_reloc(s
, segment
, RELTYPE_GOTPC
, size
);
643 } else if (wrt
== aout_gotoff_sect
+ 1) {
645 addr
= aout_add_gotoff_reloc(s
, segment
,
647 } else if (wrt
== aout_got_sect
+ 1) {
650 aout_add_gsym_reloc(s
, segment
, addr
, RELTYPE_GOT
,
652 } else if (wrt
== aout_sym_sect
+ 1) {
653 addr
= aout_add_gsym_reloc(s
, segment
, addr
,
654 RELTYPE_ABSOLUTE
, size
,
656 } else if (wrt
== aout_plt_sect
+ 1) {
659 "a.out format cannot produce non-PC-"
660 "relative PLT references");
663 "a.out format does not support this"
665 wrt
= NO_SEG
; /* we can at least _try_ to continue */
674 aout_sect_write(s
, mydata
, size
);
675 } else if (type
== OUT_REL2ADR
) {
676 if (segment
== segto
)
677 error(ERR_PANIC
, "intra-segment OUT_REL2ADR");
678 if (segment
!= NO_SEG
&& segment
% 2) {
679 error(ERR_NONFATAL
, "a.out format does not support"
680 " segment base references");
683 aout_add_reloc(s
, segment
, RELTYPE_RELATIVE
, 2);
685 error(ERR_NONFATAL
, "Linux a.out format does not support"
687 wrt
= NO_SEG
; /* we can at least _try_ to continue */
688 } else if (wrt
== aout_plt_sect
+ 1) {
690 aout_add_reloc(s
, segment
, RELTYPE_PLT
, 2);
691 } else if (wrt
== aout_gotpc_sect
+ 1 ||
692 wrt
== aout_gotoff_sect
+ 1 ||
693 wrt
== aout_got_sect
+ 1) {
694 error(ERR_NONFATAL
, "a.out format cannot produce PC-"
695 "relative GOT references");
697 error(ERR_NONFATAL
, "a.out format does not support this"
699 wrt
= NO_SEG
; /* we can at least _try_ to continue */
703 WRITESHORT(p
, *(int64_t *)data
- (size
+ s
->len
));
704 aout_sect_write(s
, mydata
, 2L);
705 } else if (type
== OUT_REL4ADR
) {
706 if (segment
== segto
)
707 error(ERR_PANIC
, "intra-segment OUT_REL4ADR");
708 if (segment
!= NO_SEG
&& segment
% 2) {
709 error(ERR_NONFATAL
, "a.out format does not support"
710 " segment base references");
713 aout_add_reloc(s
, segment
, RELTYPE_RELATIVE
, 4);
715 error(ERR_NONFATAL
, "Linux a.out format does not support"
717 wrt
= NO_SEG
; /* we can at least _try_ to continue */
718 } else if (wrt
== aout_plt_sect
+ 1) {
720 aout_add_reloc(s
, segment
, RELTYPE_PLT
, 4);
721 } else if (wrt
== aout_gotpc_sect
+ 1 ||
722 wrt
== aout_gotoff_sect
+ 1 ||
723 wrt
== aout_got_sect
+ 1) {
724 error(ERR_NONFATAL
, "a.out format cannot produce PC-"
725 "relative GOT references");
727 error(ERR_NONFATAL
, "a.out format does not support this"
729 wrt
= NO_SEG
; /* we can at least _try_ to continue */
733 WRITELONG(p
, *(int64_t *)data
- (size
+ s
->len
));
734 aout_sect_write(s
, mydata
, 4L);
738 static void aout_pad_sections(void)
740 static uint8_t pad
[] = { 0x90, 0x90, 0x90, 0x90 };
742 * Pad each of the text and data sections with NOPs until their
743 * length is a multiple of four. (NOP == 0x90.) Also increase
744 * the length of the BSS section similarly.
746 aout_sect_write(&stext
, pad
, (-(int32_t)stext
.len
) & 3);
747 aout_sect_write(&sdata
, pad
, (-(int32_t)sdata
.len
) & 3);
748 sbss
.len
= (sbss
.len
+ 3) & ~3;
752 * a.out files have the curious property that all references to
753 * things in the data or bss sections are done by addresses which
754 * are actually relative to the start of the _text_ section, in the
755 * _file_. (No relation to what happens after linking. No idea why
756 * this should be so. It's very strange.) So we have to go through
757 * the relocation table, _after_ the final size of each section is
758 * known, and fix up the relocations pointed to.
760 static void aout_fixup_relocs(struct Section
*sect
)
764 saa_rewind(sect
->data
);
765 for (r
= sect
->head
; r
; r
= r
->next
) {
766 uint8_t *p
, *q
, blk
[4];
769 saa_fread(sect
->data
, r
->address
, blk
, (int32_t)r
->bytes
);
773 l
+= ((int32_t)*p
++) << 8;
775 l
+= ((int32_t)*p
++) << 16;
776 l
+= ((int32_t)*p
++) << 24;
779 if (r
->symbol
== -SECT_DATA
)
781 else if (r
->symbol
== -SECT_BSS
)
782 l
+= stext
.len
+ sdata
.len
;
785 else if (r
->bytes
== 2)
789 saa_fwrite(sect
->data
, r
->address
, blk
, (int32_t)r
->bytes
);
793 static void aout_write(void)
796 * Emit the a.out header.
798 /* OMAGIC, M_386 or MID_I386, no flags */
799 fwriteint32_t(bsd
? 0x07018600 | is_pic
: 0x640107L
, aoutfp
);
800 fwriteint32_t(stext
.len
, aoutfp
);
801 fwriteint32_t(sdata
.len
, aoutfp
);
802 fwriteint32_t(sbss
.len
, aoutfp
);
803 fwriteint32_t(nsyms
* 12, aoutfp
); /* length of symbol table */
804 fwriteint32_t(0L, aoutfp
); /* object files have no entry point */
805 fwriteint32_t(stext
.nrelocs
* 8, aoutfp
); /* size of text relocs */
806 fwriteint32_t(sdata
.nrelocs
* 8, aoutfp
); /* size of data relocs */
809 * Write out the code section and the data section.
811 saa_fpwrite(stext
.data
, aoutfp
);
812 saa_fpwrite(sdata
.data
, aoutfp
);
815 * Write out the relocations.
817 aout_write_relocs(stext
.head
);
818 aout_write_relocs(sdata
.head
);
821 * Write the symbol table.
826 * And the string table.
828 fwriteint32_t(strslen
+ 4, aoutfp
); /* length includes length count */
829 saa_fpwrite(strs
, aoutfp
);
832 static void aout_write_relocs(struct Reloc
*r
)
837 fwriteint32_t(r
->address
, aoutfp
);
843 word2
|= r
->reltype
<< 24;
844 word2
|= (r
->bytes
== 1 ? 0 :
845 r
->bytes
== 2 ? 0x2000000L
: 0x4000000L
);
846 fwriteint32_t(word2
, aoutfp
);
852 static void aout_write_syms(void)
857 for (i
= 0; i
< nsyms
; i
++) {
858 struct Symbol
*sym
= saa_rstruct(syms
);
859 fwriteint32_t(sym
->strpos
, aoutfp
);
860 fwriteint32_t((int32_t)sym
->type
& ~SYM_WITH_SIZE
, aoutfp
);
862 * Fix up the symbol value now we know the final section
865 if ((sym
->type
& SECT_MASK
) == SECT_DATA
)
866 sym
->value
+= stext
.len
;
867 if ((sym
->type
& SECT_MASK
) == SECT_BSS
)
868 sym
->value
+= stext
.len
+ sdata
.len
;
869 fwriteint32_t(sym
->value
, aoutfp
);
871 * Output a size record if necessary.
873 if (sym
->type
& SYM_WITH_SIZE
) {
874 fwriteint32_t(sym
->strpos
, aoutfp
);
875 fwriteint32_t(0x0DL
, aoutfp
); /* special value: means size */
876 fwriteint32_t(sym
->size
, aoutfp
);
877 i
++; /* use up another of `nsyms' */
882 static void aout_sect_write(struct Section
*sect
,
883 const uint8_t *data
, uint32_t len
)
885 saa_wbytes(sect
->data
, data
, len
);
889 static int32_t aout_segbase(int32_t segment
)
894 static int aout_directive(char *directive
, char *value
, int pass
)
902 static void aout_filename(char *inname
, char *outname
, efunc error
)
904 standard_extension(inname
, outname
, ".o", error
);
907 static const char *aout_stdmac
[] = {
908 "%define __SECT__ [section .text]",
909 "%macro __NASM_CDecl__ 1",
914 static int aout_set_info(enum geninfo type
, char **val
)
920 #endif /* OF_AOUT || OF_AOUTB */
924 struct ofmt of_aout
= {
925 "Linux a.out object files",
946 struct ofmt of_aoutb
= {
947 "NetBSD/FreeBSD a.out object files",