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
*, const unsigned char *,
108 static void aout_pad_sections(void);
109 static void aout_fixup_relocs(struct Section
*);
112 * Special section numbers which are used to define special
113 * symbols, which can be used with WRT to provide PIC relocation
116 static long aout_gotpc_sect
, aout_gotoff_sect
;
117 static long aout_got_sect
, aout_plt_sect
;
118 static long aout_sym_sect
;
120 static void aoutg_init(FILE * fp
, efunc errfunc
, ldfunc ldef
,
126 (void)ldef
; /* placate optimisers */
127 stext
.data
= saa_init(1L);
129 stext
.tail
= &stext
.head
;
130 sdata
.data
= saa_init(1L);
132 sdata
.tail
= &sdata
.head
;
133 stext
.len
= stext
.size
= sdata
.len
= sdata
.size
= sbss
.len
= 0;
134 stext
.nrelocs
= sdata
.nrelocs
= 0;
135 stext
.gsyms
= sdata
.gsyms
= sbss
.gsyms
= NULL
;
136 stext
.index
= seg_alloc();
137 sdata
.index
= seg_alloc();
138 sbss
.index
= seg_alloc();
139 stext
.asym
= sdata
.asym
= sbss
.asym
= NULL
;
140 syms
= saa_init((long)sizeof(struct Symbol
));
150 static void aout_init(FILE * fp
, efunc errfunc
, ldfunc ldef
, evalfunc eval
)
153 aoutg_init(fp
, errfunc
, ldef
, eval
);
155 aout_gotpc_sect
= aout_gotoff_sect
= aout_got_sect
=
156 aout_plt_sect
= aout_sym_sect
= NO_SEG
;
163 extern struct ofmt of_aoutb
;
165 static void aoutb_init(FILE * fp
, efunc errfunc
, ldfunc ldef
,
169 aoutg_init(fp
, errfunc
, ldef
, eval
);
171 is_pic
= 0x00; /* may become 0x40 */
173 aout_gotpc_sect
= seg_alloc();
174 ldef("..gotpc", aout_gotpc_sect
+ 1, 0L, NULL
, FALSE
, FALSE
, &of_aoutb
,
176 aout_gotoff_sect
= seg_alloc();
177 ldef("..gotoff", aout_gotoff_sect
+ 1, 0L, NULL
, FALSE
, FALSE
,
179 aout_got_sect
= seg_alloc();
180 ldef("..got", aout_got_sect
+ 1, 0L, NULL
, FALSE
, FALSE
, &of_aoutb
,
182 aout_plt_sect
= seg_alloc();
183 ldef("..plt", aout_plt_sect
+ 1, 0L, NULL
, FALSE
, FALSE
, &of_aoutb
,
185 aout_sym_sect
= seg_alloc();
186 ldef("..sym", aout_sym_sect
+ 1, 0L, NULL
, FALSE
, FALSE
, &of_aoutb
,
192 static void aout_cleanup(int debuginfo
)
199 aout_fixup_relocs(&stext
);
200 aout_fixup_relocs(&sdata
);
203 saa_free(stext
.data
);
206 stext
.head
= stext
.head
->next
;
209 saa_free(sdata
.data
);
212 sdata
.head
= sdata
.head
->next
;
220 static long aout_section_names(char *name
, int pass
, int *bits
)
223 * Default to 32 bits.
231 if (!strcmp(name
, ".text"))
233 else if (!strcmp(name
, ".data"))
235 else if (!strcmp(name
, ".bss"))
241 static void aout_deflabel(char *name
, long segment
, long offset
,
242 int is_global
, char *special
)
244 int pos
= strslen
+ 4;
246 int special_used
= FALSE
;
248 if (name
[0] == '.' && name
[1] == '.' && name
[2] != '@') {
250 * This is a NASM special symbol. We never allow it into
251 * the a.out symbol table, even if it's a valid one. If it
252 * _isn't_ a valid one, we should barf immediately.
254 if (strcmp(name
, "..gotpc") && strcmp(name
, "..gotoff") &&
255 strcmp(name
, "..got") && strcmp(name
, "..plt") &&
256 strcmp(name
, "..sym"))
257 error(ERR_NONFATAL
, "unrecognised special symbol `%s'", name
);
261 if (is_global
== 3) {
264 * Fix up a forward-reference symbol size from the first
267 for (s
= &fwds
; *s
; s
= &(*s
)->nextfwd
)
268 if (!strcmp((*s
)->name
, name
)) {
269 struct tokenval tokval
;
273 while (*p
&& !isspace(*p
))
275 while (*p
&& isspace(*p
))
279 tokval
.t_type
= TOKEN_INVALID
;
280 e
= evaluate(stdscan
, NULL
, &tokval
, NULL
, 1, error
, NULL
);
283 error(ERR_NONFATAL
, "cannot use relocatable"
284 " expression as symbol size");
286 (*s
)->size
= reloc_value(e
);
290 * Remove it from the list of unresolved sizes.
292 nasm_free((*s
)->name
);
296 return; /* it wasn't an important one */
299 saa_wbytes(strs
, name
, (long)(1 + strlen(name
)));
300 strslen
+= 1 + strlen(name
);
302 sym
= saa_wstruct(syms
);
305 sym
->type
= is_global
? SYM_GLOBAL
: 0;
306 sym
->segment
= segment
;
307 if (segment
== NO_SEG
)
308 sym
->type
|= SECT_ABS
;
309 else if (segment
== stext
.index
) {
310 sym
->type
|= SECT_TEXT
;
312 sym
->next
= stext
.gsyms
;
314 } else if (!stext
.asym
)
316 } else if (segment
== sdata
.index
) {
317 sym
->type
|= SECT_DATA
;
319 sym
->next
= sdata
.gsyms
;
321 } else if (!sdata
.asym
)
323 } else if (segment
== sbss
.index
) {
324 sym
->type
|= SECT_BSS
;
326 sym
->next
= sbss
.gsyms
;
328 } else if (!sbss
.asym
)
331 sym
->type
= SYM_GLOBAL
;
335 sym
->value
= (sym
->type
== SYM_GLOBAL
? 0 : offset
);
337 if (is_global
&& sym
->type
!= SYM_GLOBAL
) {
339 * Global symbol exported _from_ this module. We must check
340 * the special text for type information.
344 int n
= strcspn(special
, " ");
346 if (!nasm_strnicmp(special
, "function", n
))
347 sym
->type
|= SYM_FUNCTION
;
348 else if (!nasm_strnicmp(special
, "data", n
) ||
349 !nasm_strnicmp(special
, "object", n
))
350 sym
->type
|= SYM_DATA
;
352 error(ERR_NONFATAL
, "unrecognised symbol type `%.*s'",
355 struct tokenval tokval
;
358 char *saveme
= stdscan_bufptr
; /* bugfix? fbk 8/10/00 */
361 error(ERR_NONFATAL
, "Linux a.out does not support"
362 " symbol size information");
364 while (special
[n
] && isspace(special
[n
]))
367 * We have a size expression; attempt to
370 sym
->type
|= SYM_WITH_SIZE
;
372 stdscan_bufptr
= special
+ n
;
373 tokval
.t_type
= TOKEN_INVALID
;
374 e
= evaluate(stdscan
, NULL
, &tokval
, &fwd
, 0, error
,
379 sym
->name
= nasm_strdup(name
);
382 error(ERR_NONFATAL
, "cannot use relocatable"
383 " expression as symbol size");
385 sym
->size
= reloc_value(e
);
388 stdscan_bufptr
= saveme
; /* bugfix? fbk 8/10/00 */
395 * define the references from external-symbol segment numbers
396 * to these symbol records.
398 if (segment
!= NO_SEG
&& segment
!= stext
.index
&&
399 segment
!= sdata
.index
&& segment
!= sbss
.index
)
400 bsym
= raa_write(bsym
, segment
, nsyms
);
404 if (sym
->type
& SYM_WITH_SIZE
)
405 nsyms
++; /* and another for the size */
407 if (special
&& !special_used
)
408 error(ERR_NONFATAL
, "no special symbol features supported here");
411 static void aout_add_reloc(struct Section
*sect
, long segment
,
412 int reltype
, int bytes
)
416 r
= *sect
->tail
= nasm_malloc(sizeof(struct Reloc
));
417 sect
->tail
= &r
->next
;
420 r
->address
= sect
->len
;
421 r
->symbol
= (segment
== NO_SEG
? -SECT_ABS
:
422 segment
== stext
.index
? -SECT_TEXT
:
423 segment
== sdata
.index
? -SECT_DATA
:
424 segment
== sbss
.index
? -SECT_BSS
:
425 raa_read(bsym
, segment
));
426 r
->reltype
= reltype
;
428 r
->reltype
|= RELTYPE_SYMFLAG
;
435 * This routine deals with ..got and ..sym relocations: the more
436 * complicated kinds. In shared-library writing, some relocations
437 * with respect to global symbols must refer to the precise symbol
438 * rather than referring to an offset from the base of the section
439 * _containing_ the symbol. Such relocations call to this routine,
440 * which searches the symbol list for the symbol in question.
442 * RELTYPE_GOT references require the _exact_ symbol address to be
443 * used; RELTYPE_ABSOLUTE references can be at an offset from the
444 * symbol. The boolean argument `exact' tells us this.
446 * Return value is the adjusted value of `addr', having become an
447 * offset from the symbol rather than the section. Should always be
448 * zero when returning from an exact call.
450 * Limitation: if you define two symbols at the same place,
451 * confusion will occur.
453 * Inefficiency: we search, currently, using a linked list which
454 * isn't even necessarily sorted.
456 static long aout_add_gsym_reloc(struct Section
*sect
,
457 long segment
, long offset
,
458 int type
, int bytes
, int exact
)
460 struct Symbol
*sym
, *sm
, *shead
;
464 * First look up the segment to find whether it's text, data,
465 * bss or an external symbol.
468 if (segment
== stext
.index
)
470 else if (segment
== sdata
.index
)
472 else if (segment
== sbss
.index
)
475 if (exact
&& offset
!= 0)
476 error(ERR_NONFATAL
, "unable to find a suitable global symbol"
477 " for this reference");
479 aout_add_reloc(sect
, segment
, type
, bytes
);
485 * Find a symbol pointing _exactly_ at this one.
487 for (sym
= shead
; sym
; sym
= sym
->next
)
488 if (sym
->value
== offset
)
492 * Find the nearest symbol below this one.
495 for (sm
= shead
; sm
; sm
= sm
->next
)
496 if (sm
->value
<= offset
&& (!sym
|| sm
->value
> sym
->value
))
500 error(ERR_NONFATAL
, "unable to find a suitable global symbol"
501 " for this reference");
505 r
= *sect
->tail
= nasm_malloc(sizeof(struct Reloc
));
506 sect
->tail
= &r
->next
;
509 r
->address
= sect
->len
;
510 r
->symbol
= sym
->symnum
;
511 r
->reltype
= type
| RELTYPE_SYMFLAG
;
516 return offset
- sym
->value
;
520 * This routine deals with ..gotoff relocations. These _must_ refer
521 * to a symbol, due to a perversity of *BSD's PIC implementation,
522 * and it must be a non-global one as well; so we store `asym', the
523 * first nonglobal symbol defined in each section, and always work
524 * from that. Relocation type is always RELTYPE_GOTOFF.
526 * Return value is the adjusted value of `addr', having become an
527 * offset from the `asym' symbol rather than the section.
529 static long aout_add_gotoff_reloc(struct Section
*sect
, long segment
,
530 long offset
, int bytes
)
536 * First look up the segment to find whether it's text, data,
537 * bss or an external symbol.
540 if (segment
== stext
.index
)
542 else if (segment
== sdata
.index
)
544 else if (segment
== sbss
.index
)
547 error(ERR_NONFATAL
, "`..gotoff' relocations require a non-global"
548 " symbol in the section");
550 r
= *sect
->tail
= nasm_malloc(sizeof(struct Reloc
));
551 sect
->tail
= &r
->next
;
554 r
->address
= sect
->len
;
555 r
->symbol
= asym
->symnum
;
556 r
->reltype
= RELTYPE_GOTOFF
;
561 return offset
- asym
->value
;
564 static void aout_out(long segto
, const void *data
, unsigned long type
,
565 long segment
, long wrt
)
568 long realbytes
= type
& OUT_SIZMASK
;
570 unsigned char mydata
[4], *p
;
575 * handle absolute-assembly (structure definitions)
577 if (segto
== NO_SEG
) {
578 if (type
!= OUT_RESERVE
)
579 error(ERR_NONFATAL
, "attempt to assemble code in [ABSOLUTE]"
584 if (segto
== stext
.index
)
586 else if (segto
== sdata
.index
)
588 else if (segto
== sbss
.index
)
591 error(ERR_WARNING
, "attempt to assemble code in"
592 " segment %d: defaulting to `.text'", segto
);
596 if (!s
&& type
!= OUT_RESERVE
) {
597 error(ERR_WARNING
, "attempt to initialise memory in the"
598 " BSS section: ignored");
599 if (type
== OUT_REL2ADR
)
601 else if (type
== OUT_REL4ADR
)
603 sbss
.len
+= realbytes
;
607 if (type
== OUT_RESERVE
) {
609 error(ERR_WARNING
, "uninitialised space declared in"
610 " %s section: zeroing",
611 (segto
== stext
.index
? "code" : "data"));
612 aout_sect_write(s
, NULL
, realbytes
);
614 sbss
.len
+= realbytes
;
615 } else if (type
== OUT_RAWDATA
) {
616 if (segment
!= NO_SEG
)
617 error(ERR_PANIC
, "OUT_RAWDATA with other than NO_SEG");
618 aout_sect_write(s
, data
, realbytes
);
619 } else if (type
== OUT_ADDRESS
) {
620 addr
= *(long *)data
;
621 if (segment
!= NO_SEG
) {
623 error(ERR_NONFATAL
, "a.out format does not support"
624 " segment base references");
627 aout_add_reloc(s
, segment
, RELTYPE_ABSOLUTE
,
631 "Linux a.out format does not support"
633 wrt
= NO_SEG
; /* we can at least _try_ to continue */
634 } else if (wrt
== aout_gotpc_sect
+ 1) {
636 aout_add_reloc(s
, segment
, RELTYPE_GOTPC
, realbytes
);
637 } else if (wrt
== aout_gotoff_sect
+ 1) {
639 addr
= aout_add_gotoff_reloc(s
, segment
,
641 } else if (wrt
== aout_got_sect
+ 1) {
644 aout_add_gsym_reloc(s
, segment
, addr
, RELTYPE_GOT
,
646 } else if (wrt
== aout_sym_sect
+ 1) {
647 addr
= aout_add_gsym_reloc(s
, segment
, addr
,
648 RELTYPE_ABSOLUTE
, realbytes
,
650 } else if (wrt
== aout_plt_sect
+ 1) {
653 "a.out format cannot produce non-PC-"
654 "relative PLT references");
657 "a.out format does not support this"
659 wrt
= NO_SEG
; /* we can at least _try_ to continue */
668 aout_sect_write(s
, mydata
, realbytes
);
669 } else if (type
== OUT_REL2ADR
) {
670 if (segment
== segto
)
671 error(ERR_PANIC
, "intra-segment OUT_REL2ADR");
672 if (segment
!= NO_SEG
&& segment
% 2) {
673 error(ERR_NONFATAL
, "a.out format does not support"
674 " segment base references");
677 aout_add_reloc(s
, segment
, RELTYPE_RELATIVE
, 2);
679 error(ERR_NONFATAL
, "Linux a.out format does not support"
681 wrt
= NO_SEG
; /* we can at least _try_ to continue */
682 } else if (wrt
== aout_plt_sect
+ 1) {
684 aout_add_reloc(s
, segment
, RELTYPE_PLT
, 2);
685 } else if (wrt
== aout_gotpc_sect
+ 1 ||
686 wrt
== aout_gotoff_sect
+ 1 ||
687 wrt
== aout_got_sect
+ 1) {
688 error(ERR_NONFATAL
, "a.out format cannot produce PC-"
689 "relative GOT references");
691 error(ERR_NONFATAL
, "a.out format does not support this"
693 wrt
= NO_SEG
; /* we can at least _try_ to continue */
697 WRITESHORT(p
, *(long *)data
- (realbytes
+ s
->len
));
698 aout_sect_write(s
, mydata
, 2L);
699 } else if (type
== OUT_REL4ADR
) {
700 if (segment
== segto
)
701 error(ERR_PANIC
, "intra-segment OUT_REL4ADR");
702 if (segment
!= NO_SEG
&& segment
% 2) {
703 error(ERR_NONFATAL
, "a.out format does not support"
704 " segment base references");
707 aout_add_reloc(s
, segment
, RELTYPE_RELATIVE
, 4);
709 error(ERR_NONFATAL
, "Linux a.out format does not support"
711 wrt
= NO_SEG
; /* we can at least _try_ to continue */
712 } else if (wrt
== aout_plt_sect
+ 1) {
714 aout_add_reloc(s
, segment
, RELTYPE_PLT
, 4);
715 } else if (wrt
== aout_gotpc_sect
+ 1 ||
716 wrt
== aout_gotoff_sect
+ 1 ||
717 wrt
== aout_got_sect
+ 1) {
718 error(ERR_NONFATAL
, "a.out format cannot produce PC-"
719 "relative GOT references");
721 error(ERR_NONFATAL
, "a.out format does not support this"
723 wrt
= NO_SEG
; /* we can at least _try_ to continue */
727 WRITELONG(p
, *(long *)data
- (realbytes
+ s
->len
));
728 aout_sect_write(s
, mydata
, 4L);
732 static void aout_pad_sections(void)
734 static unsigned char pad
[] = { 0x90, 0x90, 0x90, 0x90 };
736 * Pad each of the text and data sections with NOPs until their
737 * length is a multiple of four. (NOP == 0x90.) Also increase
738 * the length of the BSS section similarly.
740 aout_sect_write(&stext
, pad
, (-(long)stext
.len
) & 3);
741 aout_sect_write(&sdata
, pad
, (-(long)sdata
.len
) & 3);
742 sbss
.len
= (sbss
.len
+ 3) & ~3;
746 * a.out files have the curious property that all references to
747 * things in the data or bss sections are done by addresses which
748 * are actually relative to the start of the _text_ section, in the
749 * _file_. (No relation to what happens after linking. No idea why
750 * this should be so. It's very strange.) So we have to go through
751 * the relocation table, _after_ the final size of each section is
752 * known, and fix up the relocations pointed to.
754 static void aout_fixup_relocs(struct Section
*sect
)
758 saa_rewind(sect
->data
);
759 for (r
= sect
->head
; r
; r
= r
->next
) {
760 unsigned char *p
, *q
, blk
[4];
763 saa_fread(sect
->data
, r
->address
, blk
, (long)r
->bytes
);
767 l
+= ((long)*p
++) << 8;
769 l
+= ((long)*p
++) << 16;
770 l
+= ((long)*p
++) << 24;
773 if (r
->symbol
== -SECT_DATA
)
775 else if (r
->symbol
== -SECT_BSS
)
776 l
+= stext
.len
+ sdata
.len
;
779 else if (r
->bytes
== 2)
783 saa_fwrite(sect
->data
, r
->address
, blk
, (long)r
->bytes
);
787 static void aout_write(void)
790 * Emit the a.out header.
792 /* OMAGIC, M_386 or MID_I386, no flags */
793 fwritelong(bsd
? 0x07018600 | is_pic
: 0x640107L
, aoutfp
);
794 fwritelong(stext
.len
, aoutfp
);
795 fwritelong(sdata
.len
, aoutfp
);
796 fwritelong(sbss
.len
, aoutfp
);
797 fwritelong(nsyms
* 12, aoutfp
); /* length of symbol table */
798 fwritelong(0L, aoutfp
); /* object files have no entry point */
799 fwritelong(stext
.nrelocs
* 8, aoutfp
); /* size of text relocs */
800 fwritelong(sdata
.nrelocs
* 8, aoutfp
); /* size of data relocs */
803 * Write out the code section and the data section.
805 saa_fpwrite(stext
.data
, aoutfp
);
806 saa_fpwrite(sdata
.data
, aoutfp
);
809 * Write out the relocations.
811 aout_write_relocs(stext
.head
);
812 aout_write_relocs(sdata
.head
);
815 * Write the symbol table.
820 * And the string table.
822 fwritelong(strslen
+ 4, aoutfp
); /* length includes length count */
823 saa_fpwrite(strs
, aoutfp
);
826 static void aout_write_relocs(struct Reloc
*r
)
831 fwritelong(r
->address
, aoutfp
);
837 word2
|= r
->reltype
<< 24;
838 word2
|= (r
->bytes
== 1 ? 0 :
839 r
->bytes
== 2 ? 0x2000000L
: 0x4000000L
);
840 fwritelong(word2
, aoutfp
);
846 static void aout_write_syms(void)
851 for (i
= 0; i
< nsyms
; i
++) {
852 struct Symbol
*sym
= saa_rstruct(syms
);
853 fwritelong(sym
->strpos
, aoutfp
);
854 fwritelong((long)sym
->type
& ~SYM_WITH_SIZE
, aoutfp
);
856 * Fix up the symbol value now we know the final section
859 if ((sym
->type
& SECT_MASK
) == SECT_DATA
)
860 sym
->value
+= stext
.len
;
861 if ((sym
->type
& SECT_MASK
) == SECT_BSS
)
862 sym
->value
+= stext
.len
+ sdata
.len
;
863 fwritelong(sym
->value
, aoutfp
);
865 * Output a size record if necessary.
867 if (sym
->type
& SYM_WITH_SIZE
) {
868 fwritelong(sym
->strpos
, aoutfp
);
869 fwritelong(0x0DL
, aoutfp
); /* special value: means size */
870 fwritelong(sym
->size
, aoutfp
);
871 i
++; /* use up another of `nsyms' */
876 static void aout_sect_write(struct Section
*sect
,
877 const unsigned char *data
, unsigned long len
)
879 saa_wbytes(sect
->data
, data
, len
);
883 static long aout_segbase(long segment
)
888 static int aout_directive(char *directive
, char *value
, int pass
)
893 static void aout_filename(char *inname
, char *outname
, efunc error
)
895 standard_extension(inname
, outname
, ".o", error
);
898 static const char *aout_stdmac
[] = {
899 "%define __SECT__ [section .text]",
900 "%macro __NASM_CDecl__ 1",
905 static int aout_set_info(enum geninfo type
, char **val
)
909 #endif /* OF_AOUT || OF_AOUTB */
913 struct ofmt of_aout
= {
914 "Linux a.out object files",
935 struct ofmt of_aoutb
= {
936 "NetBSD/FreeBSD a.out object files",