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.
20 #if defined OF_AOUT || defined OF_AOUTB
22 #define RELTYPE_ABSOLUTE 0x00
23 #define RELTYPE_RELATIVE 0x01
24 #define RELTYPE_GOTPC 0x01 /* no explicit GOTPC in a.out */
25 #define RELTYPE_GOTOFF 0x10
26 #define RELTYPE_GOT 0x10 /* distinct from GOTOFF bcos sym not sect */
27 #define RELTYPE_PLT 0x21
28 #define RELTYPE_SYMFLAG 0x08
32 int32_t address
; /* relative to _start_ of section */
33 int32_t symbol
; /* symbol number or -ve section id */
34 int bytes
; /* 2 or 4 */
35 int reltype
; /* see above */
39 int32_t strpos
; /* string table position of name */
40 int type
; /* symbol type - see flags below */
41 int32_t value
; /* address, or COMMON variable size */
42 int32_t size
; /* size for data or function exports */
43 int32_t segment
; /* back-reference used by gsym_reloc */
44 struct Symbol
*next
; /* list of globals in each section */
45 struct Symbol
*nextfwd
; /* list of unresolved-size symbols */
46 int8_t *name
; /* for unresolved-size symbols */
47 int32_t symnum
; /* index into symbol table */
51 * Section IDs - used in Reloc.symbol when negative, and in
52 * Symbol.type when positive.
54 #define SECT_ABS 2 /* absolute value */
55 #define SECT_TEXT 4 /* text section */
56 #define SECT_DATA 6 /* data section */
57 #define SECT_BSS 8 /* bss section */
58 #define SECT_MASK 0xE /* mask out any of the above */
61 * More flags used in Symbol.type.
63 #define SYM_GLOBAL 1 /* it's a global symbol */
64 #define SYM_DATA 0x100 /* used for shared libs */
65 #define SYM_FUNCTION 0x200 /* used for shared libs */
66 #define SYM_WITH_SIZE 0x4000 /* not output; internal only */
69 * Bit more explanation of symbol types: SECT_xxx denotes a local
70 * symbol. SECT_xxx|SYM_GLOBAL denotes a global symbol, defined in
71 * this module. Just SYM_GLOBAL, with zero value, denotes an
72 * external symbol referenced in this module. And just SYM_GLOBAL,
73 * but with a non-zero value, declares a C `common' variable, of
79 uint32_t len
, size
, nrelocs
;
81 struct Reloc
*head
, **tail
;
82 struct Symbol
*gsyms
, *asym
;
85 static struct Section stext
, sdata
, sbss
;
87 static struct SAA
*syms
;
88 static uint32_t nsyms
;
90 static struct RAA
*bsym
;
92 static struct SAA
*strs
;
93 static uint32_t strslen
;
95 static struct Symbol
*fwds
;
99 static evalfunc evaluate
;
104 static void aout_write(void);
105 static void aout_write_relocs(struct Reloc
*);
106 static void aout_write_syms(void);
107 static void aout_sect_write(struct Section
*, const uint8_t *,
109 static void aout_pad_sections(void);
110 static void aout_fixup_relocs(struct Section
*);
113 * Special section numbers which are used to define special
114 * symbols, which can be used with WRT to provide PIC relocation
117 static int32_t aout_gotpc_sect
, aout_gotoff_sect
;
118 static int32_t aout_got_sect
, aout_plt_sect
;
119 static int32_t aout_sym_sect
;
121 static void aoutg_init(FILE * fp
, efunc errfunc
, ldfunc ldef
,
127 (void)ldef
; /* placate optimisers */
128 stext
.data
= saa_init(1L);
130 stext
.tail
= &stext
.head
;
131 sdata
.data
= saa_init(1L);
133 sdata
.tail
= &sdata
.head
;
134 stext
.len
= stext
.size
= sdata
.len
= sdata
.size
= sbss
.len
= 0;
135 stext
.nrelocs
= sdata
.nrelocs
= 0;
136 stext
.gsyms
= sdata
.gsyms
= sbss
.gsyms
= NULL
;
137 stext
.index
= seg_alloc();
138 sdata
.index
= seg_alloc();
139 sbss
.index
= seg_alloc();
140 stext
.asym
= sdata
.asym
= sbss
.asym
= NULL
;
141 syms
= saa_init((int32_t)sizeof(struct Symbol
));
151 static void aout_init(FILE * fp
, efunc errfunc
, ldfunc ldef
, evalfunc eval
)
154 aoutg_init(fp
, errfunc
, ldef
, eval
);
156 aout_gotpc_sect
= aout_gotoff_sect
= aout_got_sect
=
157 aout_plt_sect
= aout_sym_sect
= NO_SEG
;
164 extern struct ofmt of_aoutb
;
166 static void aoutb_init(FILE * fp
, efunc errfunc
, ldfunc ldef
,
170 aoutg_init(fp
, errfunc
, ldef
, eval
);
172 is_pic
= 0x00; /* may become 0x40 */
174 aout_gotpc_sect
= seg_alloc();
175 ldef("..gotpc", aout_gotpc_sect
+ 1, 0L, NULL
, FALSE
, FALSE
, &of_aoutb
,
177 aout_gotoff_sect
= seg_alloc();
178 ldef("..gotoff", aout_gotoff_sect
+ 1, 0L, NULL
, FALSE
, FALSE
,
180 aout_got_sect
= seg_alloc();
181 ldef("..got", aout_got_sect
+ 1, 0L, NULL
, FALSE
, FALSE
, &of_aoutb
,
183 aout_plt_sect
= seg_alloc();
184 ldef("..plt", aout_plt_sect
+ 1, 0L, NULL
, FALSE
, FALSE
, &of_aoutb
,
186 aout_sym_sect
= seg_alloc();
187 ldef("..sym", aout_sym_sect
+ 1, 0L, NULL
, FALSE
, FALSE
, &of_aoutb
,
193 static void aout_cleanup(int debuginfo
)
200 aout_fixup_relocs(&stext
);
201 aout_fixup_relocs(&sdata
);
204 saa_free(stext
.data
);
207 stext
.head
= stext
.head
->next
;
210 saa_free(sdata
.data
);
213 sdata
.head
= sdata
.head
->next
;
221 static int32_t aout_section_names(int8_t *name
, int pass
, int *bits
)
224 * Default to 32 bits.
232 if (!strcmp(name
, ".text"))
234 else if (!strcmp(name
, ".data"))
236 else if (!strcmp(name
, ".bss"))
242 static void aout_deflabel(int8_t *name
, int32_t segment
, int32_t offset
,
243 int is_global
, int8_t *special
)
245 int pos
= strslen
+ 4;
247 int special_used
= FALSE
;
249 if (name
[0] == '.' && name
[1] == '.' && name
[2] != '@') {
251 * This is a NASM special symbol. We never allow it into
252 * the a.out symbol table, even if it's a valid one. If it
253 * _isn't_ a valid one, we should barf immediately.
255 if (strcmp(name
, "..gotpc") && strcmp(name
, "..gotoff") &&
256 strcmp(name
, "..got") && strcmp(name
, "..plt") &&
257 strcmp(name
, "..sym"))
258 error(ERR_NONFATAL
, "unrecognised special symbol `%s'", name
);
262 if (is_global
== 3) {
265 * Fix up a forward-reference symbol size from the first
268 for (s
= &fwds
; *s
; s
= &(*s
)->nextfwd
)
269 if (!strcmp((*s
)->name
, name
)) {
270 struct tokenval tokval
;
274 while (*p
&& !isspace(*p
))
276 while (*p
&& isspace(*p
))
280 tokval
.t_type
= TOKEN_INVALID
;
281 e
= evaluate(stdscan
, NULL
, &tokval
, NULL
, 1, error
, NULL
);
284 error(ERR_NONFATAL
, "cannot use relocatable"
285 " expression as symbol size");
287 (*s
)->size
= reloc_value(e
);
291 * Remove it from the list of unresolved sizes.
293 nasm_free((*s
)->name
);
297 return; /* it wasn't an important one */
300 saa_wbytes(strs
, name
, (int32_t)(1 + strlen(name
)));
301 strslen
+= 1 + strlen(name
);
303 sym
= saa_wstruct(syms
);
306 sym
->type
= is_global
? SYM_GLOBAL
: 0;
307 sym
->segment
= segment
;
308 if (segment
== NO_SEG
)
309 sym
->type
|= SECT_ABS
;
310 else if (segment
== stext
.index
) {
311 sym
->type
|= SECT_TEXT
;
313 sym
->next
= stext
.gsyms
;
315 } else if (!stext
.asym
)
317 } else if (segment
== sdata
.index
) {
318 sym
->type
|= SECT_DATA
;
320 sym
->next
= sdata
.gsyms
;
322 } else if (!sdata
.asym
)
324 } else if (segment
== sbss
.index
) {
325 sym
->type
|= SECT_BSS
;
327 sym
->next
= sbss
.gsyms
;
329 } else if (!sbss
.asym
)
332 sym
->type
= SYM_GLOBAL
;
336 sym
->value
= (sym
->type
== SYM_GLOBAL
? 0 : offset
);
338 if (is_global
&& sym
->type
!= SYM_GLOBAL
) {
340 * Global symbol exported _from_ this module. We must check
341 * the special text for type information.
345 int n
= strcspn(special
, " ");
347 if (!nasm_strnicmp(special
, "function", n
))
348 sym
->type
|= SYM_FUNCTION
;
349 else if (!nasm_strnicmp(special
, "data", n
) ||
350 !nasm_strnicmp(special
, "object", n
))
351 sym
->type
|= SYM_DATA
;
353 error(ERR_NONFATAL
, "unrecognised symbol type `%.*s'",
356 struct tokenval tokval
;
359 int8_t *saveme
= stdscan_bufptr
; /* bugfix? fbk 8/10/00 */
362 error(ERR_NONFATAL
, "Linux a.out does not support"
363 " symbol size information");
365 while (special
[n
] && isspace(special
[n
]))
368 * We have a size expression; attempt to
371 sym
->type
|= SYM_WITH_SIZE
;
373 stdscan_bufptr
= special
+ n
;
374 tokval
.t_type
= TOKEN_INVALID
;
375 e
= evaluate(stdscan
, NULL
, &tokval
, &fwd
, 0, error
,
380 sym
->name
= nasm_strdup(name
);
383 error(ERR_NONFATAL
, "cannot use relocatable"
384 " expression as symbol size");
386 sym
->size
= reloc_value(e
);
389 stdscan_bufptr
= saveme
; /* bugfix? fbk 8/10/00 */
396 * define the references from external-symbol segment numbers
397 * to these symbol records.
399 if (segment
!= NO_SEG
&& segment
!= stext
.index
&&
400 segment
!= sdata
.index
&& segment
!= sbss
.index
)
401 bsym
= raa_write(bsym
, segment
, nsyms
);
405 if (sym
->type
& SYM_WITH_SIZE
)
406 nsyms
++; /* and another for the size */
408 if (special
&& !special_used
)
409 error(ERR_NONFATAL
, "no special symbol features supported here");
412 static void aout_add_reloc(struct Section
*sect
, int32_t segment
,
413 int reltype
, int bytes
)
417 r
= *sect
->tail
= nasm_malloc(sizeof(struct Reloc
));
418 sect
->tail
= &r
->next
;
421 r
->address
= sect
->len
;
422 r
->symbol
= (segment
== NO_SEG
? -SECT_ABS
:
423 segment
== stext
.index
? -SECT_TEXT
:
424 segment
== sdata
.index
? -SECT_DATA
:
425 segment
== sbss
.index
? -SECT_BSS
:
426 raa_read(bsym
, segment
));
427 r
->reltype
= reltype
;
429 r
->reltype
|= RELTYPE_SYMFLAG
;
436 * This routine deals with ..got and ..sym relocations: the more
437 * complicated kinds. In shared-library writing, some relocations
438 * with respect to global symbols must refer to the precise symbol
439 * rather than referring to an offset from the base of the section
440 * _containing_ the symbol. Such relocations call to this routine,
441 * which searches the symbol list for the symbol in question.
443 * RELTYPE_GOT references require the _exact_ symbol address to be
444 * used; RELTYPE_ABSOLUTE references can be at an offset from the
445 * symbol. The boolean argument `exact' tells us this.
447 * Return value is the adjusted value of `addr', having become an
448 * offset from the symbol rather than the section. Should always be
449 * zero when returning from an exact call.
451 * Limitation: if you define two symbols at the same place,
452 * confusion will occur.
454 * Inefficiency: we search, currently, using a linked list which
455 * isn't even necessarily sorted.
457 static int32_t aout_add_gsym_reloc(struct Section
*sect
,
458 int32_t segment
, int32_t offset
,
459 int type
, int bytes
, int exact
)
461 struct Symbol
*sym
, *sm
, *shead
;
465 * First look up the segment to find whether it's text, data,
466 * bss or an external symbol.
469 if (segment
== stext
.index
)
471 else if (segment
== sdata
.index
)
473 else if (segment
== sbss
.index
)
476 if (exact
&& offset
!= 0)
477 error(ERR_NONFATAL
, "unable to find a suitable global symbol"
478 " for this reference");
480 aout_add_reloc(sect
, segment
, type
, bytes
);
486 * Find a symbol pointing _exactly_ at this one.
488 for (sym
= shead
; sym
; sym
= sym
->next
)
489 if (sym
->value
== offset
)
493 * Find the nearest symbol below this one.
496 for (sm
= shead
; sm
; sm
= sm
->next
)
497 if (sm
->value
<= offset
&& (!sym
|| sm
->value
> sym
->value
))
501 error(ERR_NONFATAL
, "unable to find a suitable global symbol"
502 " for this reference");
506 r
= *sect
->tail
= nasm_malloc(sizeof(struct Reloc
));
507 sect
->tail
= &r
->next
;
510 r
->address
= sect
->len
;
511 r
->symbol
= sym
->symnum
;
512 r
->reltype
= type
| RELTYPE_SYMFLAG
;
517 return offset
- sym
->value
;
521 * This routine deals with ..gotoff relocations. These _must_ refer
522 * to a symbol, due to a perversity of *BSD's PIC implementation,
523 * and it must be a non-global one as well; so we store `asym', the
524 * first nonglobal symbol defined in each section, and always work
525 * from that. Relocation type is always RELTYPE_GOTOFF.
527 * Return value is the adjusted value of `addr', having become an
528 * offset from the `asym' symbol rather than the section.
530 static int32_t aout_add_gotoff_reloc(struct Section
*sect
, int32_t segment
,
531 int32_t offset
, int bytes
)
537 * First look up the segment to find whether it's text, data,
538 * bss or an external symbol.
541 if (segment
== stext
.index
)
543 else if (segment
== sdata
.index
)
545 else if (segment
== sbss
.index
)
548 error(ERR_NONFATAL
, "`..gotoff' relocations require a non-global"
549 " symbol in the section");
551 r
= *sect
->tail
= nasm_malloc(sizeof(struct Reloc
));
552 sect
->tail
= &r
->next
;
555 r
->address
= sect
->len
;
556 r
->symbol
= asym
->symnum
;
557 r
->reltype
= RELTYPE_GOTOFF
;
562 return offset
- asym
->value
;
565 static void aout_out(int32_t segto
, const void *data
, uint32_t type
,
566 int32_t segment
, int32_t wrt
)
569 int32_t realbytes
= type
& OUT_SIZMASK
;
571 uint8_t mydata
[4], *p
;
576 * handle absolute-assembly (structure definitions)
578 if (segto
== NO_SEG
) {
579 if (type
!= OUT_RESERVE
)
580 error(ERR_NONFATAL
, "attempt to assemble code in [ABSOLUTE]"
585 if (segto
== stext
.index
)
587 else if (segto
== sdata
.index
)
589 else if (segto
== sbss
.index
)
592 error(ERR_WARNING
, "attempt to assemble code in"
593 " segment %d: defaulting to `.text'", segto
);
597 if (!s
&& type
!= OUT_RESERVE
) {
598 error(ERR_WARNING
, "attempt to initialize memory in the"
599 " BSS section: ignored");
600 if (type
== OUT_REL2ADR
)
602 else if (type
== OUT_REL4ADR
)
604 sbss
.len
+= realbytes
;
608 if (type
== OUT_RESERVE
) {
610 error(ERR_WARNING
, "uninitialized space declared in"
611 " %s section: zeroing",
612 (segto
== stext
.index
? "code" : "data"));
613 aout_sect_write(s
, NULL
, realbytes
);
615 sbss
.len
+= realbytes
;
616 } else if (type
== OUT_RAWDATA
) {
617 if (segment
!= NO_SEG
)
618 error(ERR_PANIC
, "OUT_RAWDATA with other than NO_SEG");
619 aout_sect_write(s
, data
, realbytes
);
620 } else if (type
== OUT_ADDRESS
) {
621 addr
= *(int32_t *)data
;
622 if (segment
!= NO_SEG
) {
624 error(ERR_NONFATAL
, "a.out format does not support"
625 " segment base references");
628 aout_add_reloc(s
, segment
, RELTYPE_ABSOLUTE
,
632 "Linux a.out format does not support"
634 wrt
= NO_SEG
; /* we can at least _try_ to continue */
635 } else if (wrt
== aout_gotpc_sect
+ 1) {
637 aout_add_reloc(s
, segment
, RELTYPE_GOTPC
, realbytes
);
638 } else if (wrt
== aout_gotoff_sect
+ 1) {
640 addr
= aout_add_gotoff_reloc(s
, segment
,
642 } else if (wrt
== aout_got_sect
+ 1) {
645 aout_add_gsym_reloc(s
, segment
, addr
, RELTYPE_GOT
,
647 } else if (wrt
== aout_sym_sect
+ 1) {
648 addr
= aout_add_gsym_reloc(s
, segment
, addr
,
649 RELTYPE_ABSOLUTE
, realbytes
,
651 } else if (wrt
== aout_plt_sect
+ 1) {
654 "a.out format cannot produce non-PC-"
655 "relative PLT references");
658 "a.out format does not support this"
660 wrt
= NO_SEG
; /* we can at least _try_ to continue */
669 aout_sect_write(s
, mydata
, realbytes
);
670 } else if (type
== OUT_REL2ADR
) {
671 if (segment
== segto
)
672 error(ERR_PANIC
, "intra-segment OUT_REL2ADR");
673 if (segment
!= NO_SEG
&& segment
% 2) {
674 error(ERR_NONFATAL
, "a.out format does not support"
675 " segment base references");
678 aout_add_reloc(s
, segment
, RELTYPE_RELATIVE
, 2);
680 error(ERR_NONFATAL
, "Linux a.out format does not support"
682 wrt
= NO_SEG
; /* we can at least _try_ to continue */
683 } else if (wrt
== aout_plt_sect
+ 1) {
685 aout_add_reloc(s
, segment
, RELTYPE_PLT
, 2);
686 } else if (wrt
== aout_gotpc_sect
+ 1 ||
687 wrt
== aout_gotoff_sect
+ 1 ||
688 wrt
== aout_got_sect
+ 1) {
689 error(ERR_NONFATAL
, "a.out format cannot produce PC-"
690 "relative GOT references");
692 error(ERR_NONFATAL
, "a.out format does not support this"
694 wrt
= NO_SEG
; /* we can at least _try_ to continue */
698 WRITESHORT(p
, *(int32_t *)data
- (realbytes
+ s
->len
));
699 aout_sect_write(s
, mydata
, 2L);
700 } else if (type
== OUT_REL4ADR
) {
701 if (segment
== segto
)
702 error(ERR_PANIC
, "intra-segment OUT_REL4ADR");
703 if (segment
!= NO_SEG
&& segment
% 2) {
704 error(ERR_NONFATAL
, "a.out format does not support"
705 " segment base references");
708 aout_add_reloc(s
, segment
, RELTYPE_RELATIVE
, 4);
710 error(ERR_NONFATAL
, "Linux a.out format does not support"
712 wrt
= NO_SEG
; /* we can at least _try_ to continue */
713 } else if (wrt
== aout_plt_sect
+ 1) {
715 aout_add_reloc(s
, segment
, RELTYPE_PLT
, 4);
716 } else if (wrt
== aout_gotpc_sect
+ 1 ||
717 wrt
== aout_gotoff_sect
+ 1 ||
718 wrt
== aout_got_sect
+ 1) {
719 error(ERR_NONFATAL
, "a.out format cannot produce PC-"
720 "relative GOT references");
722 error(ERR_NONFATAL
, "a.out format does not support this"
724 wrt
= NO_SEG
; /* we can at least _try_ to continue */
728 WRITELONG(p
, *(int32_t *)data
- (realbytes
+ s
->len
));
729 aout_sect_write(s
, mydata
, 4L);
733 static void aout_pad_sections(void)
735 static uint8_t pad
[] = { 0x90, 0x90, 0x90, 0x90 };
737 * Pad each of the text and data sections with NOPs until their
738 * length is a multiple of four. (NOP == 0x90.) Also increase
739 * the length of the BSS section similarly.
741 aout_sect_write(&stext
, pad
, (-(int32_t)stext
.len
) & 3);
742 aout_sect_write(&sdata
, pad
, (-(int32_t)sdata
.len
) & 3);
743 sbss
.len
= (sbss
.len
+ 3) & ~3;
747 * a.out files have the curious property that all references to
748 * things in the data or bss sections are done by addresses which
749 * are actually relative to the start of the _text_ section, in the
750 * _file_. (No relation to what happens after linking. No idea why
751 * this should be so. It's very strange.) So we have to go through
752 * the relocation table, _after_ the final size of each section is
753 * known, and fix up the relocations pointed to.
755 static void aout_fixup_relocs(struct Section
*sect
)
759 saa_rewind(sect
->data
);
760 for (r
= sect
->head
; r
; r
= r
->next
) {
761 uint8_t *p
, *q
, blk
[4];
764 saa_fread(sect
->data
, r
->address
, blk
, (int32_t)r
->bytes
);
768 l
+= ((int32_t)*p
++) << 8;
770 l
+= ((int32_t)*p
++) << 16;
771 l
+= ((int32_t)*p
++) << 24;
774 if (r
->symbol
== -SECT_DATA
)
776 else if (r
->symbol
== -SECT_BSS
)
777 l
+= stext
.len
+ sdata
.len
;
780 else if (r
->bytes
== 2)
784 saa_fwrite(sect
->data
, r
->address
, blk
, (int32_t)r
->bytes
);
788 static void aout_write(void)
791 * Emit the a.out header.
793 /* OMAGIC, M_386 or MID_I386, no flags */
794 fwriteint32_t(bsd
? 0x07018600 | is_pic
: 0x640107L
, aoutfp
);
795 fwriteint32_t(stext
.len
, aoutfp
);
796 fwriteint32_t(sdata
.len
, aoutfp
);
797 fwriteint32_t(sbss
.len
, aoutfp
);
798 fwriteint32_t(nsyms
* 12, aoutfp
); /* length of symbol table */
799 fwriteint32_t(0L, aoutfp
); /* object files have no entry point */
800 fwriteint32_t(stext
.nrelocs
* 8, aoutfp
); /* size of text relocs */
801 fwriteint32_t(sdata
.nrelocs
* 8, aoutfp
); /* size of data relocs */
804 * Write out the code section and the data section.
806 saa_fpwrite(stext
.data
, aoutfp
);
807 saa_fpwrite(sdata
.data
, aoutfp
);
810 * Write out the relocations.
812 aout_write_relocs(stext
.head
);
813 aout_write_relocs(sdata
.head
);
816 * Write the symbol table.
821 * And the string table.
823 fwriteint32_t(strslen
+ 4, aoutfp
); /* length includes length count */
824 saa_fpwrite(strs
, aoutfp
);
827 static void aout_write_relocs(struct Reloc
*r
)
832 fwriteint32_t(r
->address
, aoutfp
);
838 word2
|= r
->reltype
<< 24;
839 word2
|= (r
->bytes
== 1 ? 0 :
840 r
->bytes
== 2 ? 0x2000000L
: 0x4000000L
);
841 fwriteint32_t(word2
, aoutfp
);
847 static void aout_write_syms(void)
852 for (i
= 0; i
< nsyms
; i
++) {
853 struct Symbol
*sym
= saa_rstruct(syms
);
854 fwriteint32_t(sym
->strpos
, aoutfp
);
855 fwriteint32_t((int32_t)sym
->type
& ~SYM_WITH_SIZE
, aoutfp
);
857 * Fix up the symbol value now we know the final section
860 if ((sym
->type
& SECT_MASK
) == SECT_DATA
)
861 sym
->value
+= stext
.len
;
862 if ((sym
->type
& SECT_MASK
) == SECT_BSS
)
863 sym
->value
+= stext
.len
+ sdata
.len
;
864 fwriteint32_t(sym
->value
, aoutfp
);
866 * Output a size record if necessary.
868 if (sym
->type
& SYM_WITH_SIZE
) {
869 fwriteint32_t(sym
->strpos
, aoutfp
);
870 fwriteint32_t(0x0DL
, aoutfp
); /* special value: means size */
871 fwriteint32_t(sym
->size
, aoutfp
);
872 i
++; /* use up another of `nsyms' */
877 static void aout_sect_write(struct Section
*sect
,
878 const uint8_t *data
, uint32_t len
)
880 saa_wbytes(sect
->data
, data
, len
);
884 static int32_t aout_segbase(int32_t segment
)
889 static int aout_directive(int8_t *directive
, int8_t *value
, int pass
)
894 static void aout_filename(int8_t *inname
, int8_t *outname
, efunc error
)
896 standard_extension(inname
, outname
, ".o", error
);
899 static const int8_t *aout_stdmac
[] = {
900 "%define __SECT__ [section .text]",
901 "%macro __NASM_CDecl__ 1",
906 static int aout_set_info(enum geninfo type
, int8_t **val
)
910 #endif /* OF_AOUT || OF_AOUTB */
914 struct ofmt of_aout
= {
915 "Linux a.out object files",
936 struct ofmt of_aoutb
= {
937 "NetBSD/FreeBSD a.out object files",