1 /* ----------------------------------------------------------------------- *
3 * Copyright 1996-2013 The NASM Authors - All Rights Reserved
4 * See the file AUTHORS included with the NASM distribution for
5 * the specific copyright holders.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above
14 * copyright notice, this list of conditions and the following
15 * disclaimer in the documentation and/or other materials provided
16 * with the distribution.
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
19 * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
20 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
21 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
25 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
26 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 * ----------------------------------------------------------------------- */
35 * outaout.c output routines for the Netwide Assembler to produce
36 * Linux a.out object files
53 #if defined OF_AOUT || defined OF_AOUTB
55 #define RELTYPE_ABSOLUTE 0x00
56 #define RELTYPE_RELATIVE 0x01
57 #define RELTYPE_GOTPC 0x01 /* no explicit GOTPC in a.out */
58 #define RELTYPE_GOTOFF 0x10
59 #define RELTYPE_GOT 0x10 /* distinct from GOTOFF bcos sym not sect */
60 #define RELTYPE_PLT 0x21
61 #define RELTYPE_SYMFLAG 0x08
65 int32_t address
; /* relative to _start_ of section */
66 int32_t symbol
; /* symbol number or -ve section id */
67 int bytes
; /* 2 or 4 */
68 int reltype
; /* see above */
72 int32_t strpos
; /* string table position of name */
73 int type
; /* symbol type - see flags below */
74 int32_t value
; /* address, or COMMON variable size */
75 int32_t size
; /* size for data or function exports */
76 int32_t segment
; /* back-reference used by gsym_reloc */
77 struct Symbol
*next
; /* list of globals in each section */
78 struct Symbol
*nextfwd
; /* list of unresolved-size symbols */
79 char *name
; /* for unresolved-size symbols */
80 int32_t symnum
; /* index into symbol table */
84 * Section IDs - used in Reloc.symbol when negative, and in
85 * Symbol.type when positive.
87 #define SECT_ABS 2 /* absolute value */
88 #define SECT_TEXT 4 /* text section */
89 #define SECT_DATA 6 /* data section */
90 #define SECT_BSS 8 /* bss section */
91 #define SECT_MASK 0xE /* mask out any of the above */
94 * More flags used in Symbol.type.
96 #define SYM_GLOBAL 1 /* it's a global symbol */
97 #define SYM_DATA 0x100 /* used for shared libs */
98 #define SYM_FUNCTION 0x200 /* used for shared libs */
99 #define SYM_WITH_SIZE 0x4000 /* not output; internal only */
102 * Bit more explanation of symbol types: SECT_xxx denotes a local
103 * symbol. SECT_xxx|SYM_GLOBAL denotes a global symbol, defined in
104 * this module. Just SYM_GLOBAL, with zero value, denotes an
105 * external symbol referenced in this module. And just SYM_GLOBAL,
106 * but with a non-zero value, declares a C `common' variable, of
112 uint32_t len
, size
, nrelocs
;
114 struct Reloc
*head
, **tail
;
115 struct Symbol
*gsyms
, *asym
;
118 static struct Section stext
, sdata
, sbss
;
120 static struct SAA
*syms
;
121 static uint32_t nsyms
;
123 static struct RAA
*bsym
;
125 static struct SAA
*strs
;
126 static uint32_t strslen
;
128 static struct Symbol
*fwds
;
133 static void aout_write(void);
134 static void aout_write_relocs(struct Reloc
*);
135 static void aout_write_syms(void);
136 static void aout_sect_write(struct Section
*, const uint8_t *,
138 static void aout_pad_sections(void);
139 static void aout_fixup_relocs(struct Section
*);
142 * Special section numbers which are used to define special
143 * symbols, which can be used with WRT to provide PIC relocation
146 static int32_t aout_gotpc_sect
, aout_gotoff_sect
;
147 static int32_t aout_got_sect
, aout_plt_sect
;
148 static int32_t aout_sym_sect
;
150 static void aoutg_init(void)
152 stext
.data
= saa_init(1L);
154 stext
.tail
= &stext
.head
;
155 sdata
.data
= saa_init(1L);
157 sdata
.tail
= &sdata
.head
;
158 stext
.len
= stext
.size
= sdata
.len
= sdata
.size
= sbss
.len
= 0;
159 stext
.nrelocs
= sdata
.nrelocs
= 0;
160 stext
.gsyms
= sdata
.gsyms
= sbss
.gsyms
= NULL
;
161 stext
.index
= seg_alloc();
162 sdata
.index
= seg_alloc();
163 sbss
.index
= seg_alloc();
164 stext
.asym
= sdata
.asym
= sbss
.asym
= NULL
;
165 syms
= saa_init((int32_t)sizeof(struct Symbol
));
175 static void aout_init(void)
180 aout_gotpc_sect
= aout_gotoff_sect
= aout_got_sect
=
181 aout_plt_sect
= aout_sym_sect
= NO_SEG
;
188 extern const struct ofmt of_aoutb
;
190 static void aoutb_init(void)
195 is_pic
= 0x00; /* may become 0x40 */
197 aout_gotpc_sect
= seg_alloc();
198 backend_label("..gotpc", aout_gotpc_sect
+ 1, 0L);
199 aout_gotoff_sect
= seg_alloc();
200 backend_label("..gotoff", aout_gotoff_sect
+ 1, 0L);
201 aout_got_sect
= seg_alloc();
202 backend_label("..got", aout_got_sect
+ 1, 0L);
203 aout_plt_sect
= seg_alloc();
204 backend_label("..plt", aout_plt_sect
+ 1, 0L);
205 aout_sym_sect
= seg_alloc();
206 backend_label("..sym", aout_sym_sect
+ 1, 0L);
211 static void aout_cleanup(void)
216 aout_fixup_relocs(&stext
);
217 aout_fixup_relocs(&sdata
);
219 saa_free(stext
.data
);
222 stext
.head
= stext
.head
->next
;
225 saa_free(sdata
.data
);
228 sdata
.head
= sdata
.head
->next
;
236 static int32_t aout_section_names(char *name
, int *bits
)
239 * Default to 32 bits.
246 if (!strcmp(name
, ".text"))
248 else if (!strcmp(name
, ".data"))
250 else if (!strcmp(name
, ".bss"))
256 static void aout_deflabel(char *name
, int32_t segment
, int64_t offset
,
257 int is_global
, char *special
)
259 int pos
= strslen
+ 4;
261 int special_used
= false;
263 if (name
[0] == '.' && name
[1] == '.' && name
[2] != '@') {
265 * This is a NASM special symbol. We never allow it into
266 * the a.out symbol table, even if it's a valid one. If it
267 * _isn't_ a valid one, we should barf immediately.
269 if (strcmp(name
, "..gotpc") && strcmp(name
, "..gotoff") &&
270 strcmp(name
, "..got") && strcmp(name
, "..plt") &&
271 strcmp(name
, "..sym"))
272 nasm_nonfatal("unrecognised special symbol `%s'", name
);
276 if (is_global
== 3) {
279 * Fix up a forward-reference symbol size from the first
282 for (s
= &fwds
; *s
; s
= &(*s
)->nextfwd
)
283 if (!strcmp((*s
)->name
, name
)) {
284 struct tokenval tokval
;
288 p
= nasm_skip_spaces(nasm_skip_word(p
));
291 tokval
.t_type
= TOKEN_INVALID
;
292 e
= evaluate(stdscan
, NULL
, &tokval
, NULL
, 1, NULL
);
295 nasm_nonfatal("cannot use relocatable"
296 " expression as symbol size");
298 (*s
)->size
= reloc_value(e
);
302 * Remove it from the list of unresolved sizes.
304 nasm_free((*s
)->name
);
308 return; /* it wasn't an important one */
311 saa_wbytes(strs
, name
, (int32_t)(1 + strlen(name
)));
312 strslen
+= 1 + strlen(name
);
314 sym
= saa_wstruct(syms
);
317 sym
->type
= is_global
? SYM_GLOBAL
: 0;
318 sym
->segment
= segment
;
319 if (segment
== NO_SEG
)
320 sym
->type
|= SECT_ABS
;
321 else if (segment
== stext
.index
) {
322 sym
->type
|= SECT_TEXT
;
324 sym
->next
= stext
.gsyms
;
326 } else if (!stext
.asym
)
328 } else if (segment
== sdata
.index
) {
329 sym
->type
|= SECT_DATA
;
331 sym
->next
= sdata
.gsyms
;
333 } else if (!sdata
.asym
)
335 } else if (segment
== sbss
.index
) {
336 sym
->type
|= SECT_BSS
;
338 sym
->next
= sbss
.gsyms
;
340 } else if (!sbss
.asym
)
343 sym
->type
= SYM_GLOBAL
;
347 sym
->value
= (sym
->type
== SYM_GLOBAL
? 0 : offset
);
349 if (is_global
&& sym
->type
!= SYM_GLOBAL
) {
351 * Global symbol exported _from_ this module. We must check
352 * the special text for type information.
356 int n
= strcspn(special
, " ");
358 if (!nasm_strnicmp(special
, "function", n
))
359 sym
->type
|= SYM_FUNCTION
;
360 else if (!nasm_strnicmp(special
, "data", n
) ||
361 !nasm_strnicmp(special
, "object", n
))
362 sym
->type
|= SYM_DATA
;
364 nasm_nonfatal("unrecognised symbol type `%.*s'",
367 struct tokenval tokval
;
370 char *saveme
= stdscan_get();
373 nasm_nonfatal("Linux a.out does not support"
374 " symbol size information");
376 while (special
[n
] && nasm_isspace(special
[n
]))
379 * We have a size expression; attempt to
382 sym
->type
|= SYM_WITH_SIZE
;
384 stdscan_set(special
+ n
);
385 tokval
.t_type
= TOKEN_INVALID
;
386 e
= evaluate(stdscan
, NULL
, &tokval
, &fwd
, 0, NULL
);
390 sym
->name
= nasm_strdup(name
);
393 nasm_nonfatal("cannot use relocatable"
394 " expression as symbol size");
396 sym
->size
= reloc_value(e
);
406 * define the references from external-symbol segment numbers
407 * to these symbol records.
409 if (segment
!= NO_SEG
&& segment
!= stext
.index
&&
410 segment
!= sdata
.index
&& segment
!= sbss
.index
)
411 bsym
= raa_write(bsym
, segment
, nsyms
);
415 if (sym
->type
& SYM_WITH_SIZE
)
416 nsyms
++; /* and another for the size */
418 if (special
&& !special_used
)
419 nasm_nonfatal("no special symbol features supported here");
422 static void aout_add_reloc(struct Section
*sect
, int32_t segment
,
423 int reltype
, int bytes
)
427 r
= *sect
->tail
= nasm_malloc(sizeof(struct Reloc
));
428 sect
->tail
= &r
->next
;
431 r
->address
= sect
->len
;
432 r
->symbol
= (segment
== NO_SEG
? -SECT_ABS
:
433 segment
== stext
.index
? -SECT_TEXT
:
434 segment
== sdata
.index
? -SECT_DATA
:
435 segment
== sbss
.index
? -SECT_BSS
:
436 raa_read(bsym
, segment
));
437 r
->reltype
= reltype
;
439 r
->reltype
|= RELTYPE_SYMFLAG
;
446 * This routine deals with ..got and ..sym relocations: the more
447 * complicated kinds. In shared-library writing, some relocations
448 * with respect to global symbols must refer to the precise symbol
449 * rather than referring to an offset from the base of the section
450 * _containing_ the symbol. Such relocations call to this routine,
451 * which searches the symbol list for the symbol in question.
453 * RELTYPE_GOT references require the _exact_ symbol address to be
454 * used; RELTYPE_ABSOLUTE references can be at an offset from the
455 * symbol. The boolean argument `exact' tells us this.
457 * Return value is the adjusted value of `addr', having become an
458 * offset from the symbol rather than the section. Should always be
459 * zero when returning from an exact call.
461 * Limitation: if you define two symbols at the same place,
462 * confusion will occur.
464 * Inefficiency: we search, currently, using a linked list which
465 * isn't even necessarily sorted.
467 static int32_t aout_add_gsym_reloc(struct Section
*sect
,
468 int32_t segment
, int32_t offset
,
469 int type
, int bytes
, int exact
)
471 struct Symbol
*sym
, *sm
, *shead
;
475 * First look up the segment to find whether it's text, data,
476 * bss or an external symbol.
479 if (segment
== stext
.index
)
481 else if (segment
== sdata
.index
)
483 else if (segment
== sbss
.index
)
486 if (exact
&& offset
!= 0)
487 nasm_nonfatal("unable to find a suitable global symbol"
488 " for this reference");
490 aout_add_reloc(sect
, segment
, type
, bytes
);
496 * Find a symbol pointing _exactly_ at this one.
498 list_for_each(sym
, shead
)
499 if (sym
->value
== offset
)
503 * Find the nearest symbol below this one.
506 list_for_each(sm
, shead
)
507 if (sm
->value
<= offset
&& (!sym
|| sm
->value
> sym
->value
))
511 nasm_nonfatal("unable to find a suitable global symbol"
512 " for this reference");
516 r
= *sect
->tail
= nasm_malloc(sizeof(struct Reloc
));
517 sect
->tail
= &r
->next
;
520 r
->address
= sect
->len
;
521 r
->symbol
= sym
->symnum
;
522 r
->reltype
= type
| RELTYPE_SYMFLAG
;
527 return offset
- sym
->value
;
531 * This routine deals with ..gotoff relocations. These _must_ refer
532 * to a symbol, due to a perversity of *BSD's PIC implementation,
533 * and it must be a non-global one as well; so we store `asym', the
534 * first nonglobal symbol defined in each section, and always work
535 * from that. Relocation type is always RELTYPE_GOTOFF.
537 * Return value is the adjusted value of `addr', having become an
538 * offset from the `asym' symbol rather than the section.
540 static int32_t aout_add_gotoff_reloc(struct Section
*sect
, int32_t segment
,
541 int32_t offset
, int bytes
)
547 * First look up the segment to find whether it's text, data,
548 * bss or an external symbol.
551 if (segment
== stext
.index
)
553 else if (segment
== sdata
.index
)
555 else if (segment
== sbss
.index
)
558 nasm_nonfatal("`..gotoff' relocations require a non-global"
559 " symbol in the section");
561 r
= *sect
->tail
= nasm_malloc(sizeof(struct Reloc
));
562 sect
->tail
= &r
->next
;
565 r
->address
= sect
->len
;
566 r
->symbol
= asym
->symnum
;
567 r
->reltype
= RELTYPE_GOTOFF
;
572 return offset
- asym
->value
;
575 static void aout_out(int32_t segto
, const void *data
,
576 enum out_type type
, uint64_t size
,
577 int32_t segment
, int32_t wrt
)
581 uint8_t mydata
[4], *p
;
583 if (segto
== stext
.index
)
585 else if (segto
== sdata
.index
)
587 else if (segto
== sbss
.index
)
590 nasm_warn(WARN_OTHER
, "attempt to assemble code in"
591 " segment %d: defaulting to `.text'", segto
);
595 if (!s
&& type
!= OUT_RESERVE
) {
596 nasm_warn(WARN_OTHER
, "attempt to initialize memory in the"
597 " BSS section: ignored");
598 sbss
.len
+= realsize(type
, size
);
602 memset(mydata
, 0, sizeof(mydata
));
604 if (type
== OUT_RESERVE
) {
606 nasm_warn(WARN_ZEROING
, "uninitialized space declared in"
607 " %s section: zeroing",
608 (segto
== stext
.index
? "code" : "data"));
609 aout_sect_write(s
, NULL
, size
);
612 } else if (type
== OUT_RAWDATA
) {
613 aout_sect_write(s
, data
, size
);
614 } else if (type
== OUT_ADDRESS
) {
615 int asize
= abs((int)size
);
616 addr
= *(int64_t *)data
;
617 if (segment
!= NO_SEG
) {
619 nasm_nonfatal("a.out format does not support"
620 " segment base references");
623 aout_add_reloc(s
, segment
, RELTYPE_ABSOLUTE
, asize
);
625 nasm_nonfatal("Linux a.out format does not support"
627 wrt
= NO_SEG
; /* we can at least _try_ to continue */
628 } else if (wrt
== aout_gotpc_sect
+ 1) {
630 aout_add_reloc(s
, segment
, RELTYPE_GOTPC
, asize
);
631 } else if (wrt
== aout_gotoff_sect
+ 1) {
633 addr
= aout_add_gotoff_reloc(s
, segment
, addr
, asize
);
634 } else if (wrt
== aout_got_sect
+ 1) {
636 addr
= aout_add_gsym_reloc(s
, segment
, addr
, RELTYPE_GOT
,
638 } else if (wrt
== aout_sym_sect
+ 1) {
639 addr
= aout_add_gsym_reloc(s
, segment
, addr
,
640 RELTYPE_ABSOLUTE
, asize
,
642 } else if (wrt
== aout_plt_sect
+ 1) {
644 nasm_nonfatal("a.out format cannot produce non-PC-"
645 "relative PLT references");
647 nasm_nonfatal("a.out format does not support this"
649 wrt
= NO_SEG
; /* we can at least _try_ to continue */
658 aout_sect_write(s
, mydata
, asize
);
659 } else if (type
== OUT_REL2ADR
) {
660 if (segment
!= NO_SEG
&& segment
% 2) {
661 nasm_nonfatal("a.out format does not support"
662 " segment base references");
665 aout_add_reloc(s
, segment
, RELTYPE_RELATIVE
, 2);
667 nasm_nonfatal("Linux a.out format does not support"
669 wrt
= NO_SEG
; /* we can at least _try_ to continue */
670 } else if (wrt
== aout_plt_sect
+ 1) {
672 aout_add_reloc(s
, segment
, RELTYPE_PLT
, 2);
673 } else if (wrt
== aout_gotpc_sect
+ 1 ||
674 wrt
== aout_gotoff_sect
+ 1 ||
675 wrt
== aout_got_sect
+ 1) {
676 nasm_nonfatal("a.out format cannot produce PC-"
677 "relative GOT references");
679 nasm_nonfatal("a.out format does not support this"
681 wrt
= NO_SEG
; /* we can at least _try_ to continue */
685 WRITESHORT(p
, *(int64_t *)data
- (size
+ s
->len
));
686 aout_sect_write(s
, mydata
, 2L);
687 } else if (type
== OUT_REL4ADR
) {
688 if (segment
!= NO_SEG
&& segment
% 2) {
689 nasm_nonfatal("a.out format does not support"
690 " segment base references");
693 aout_add_reloc(s
, segment
, RELTYPE_RELATIVE
, 4);
695 nasm_nonfatal("Linux a.out format does not support"
697 wrt
= NO_SEG
; /* we can at least _try_ to continue */
698 } else if (wrt
== aout_plt_sect
+ 1) {
700 aout_add_reloc(s
, segment
, RELTYPE_PLT
, 4);
701 } else if (wrt
== aout_gotpc_sect
+ 1 ||
702 wrt
== aout_gotoff_sect
+ 1 ||
703 wrt
== aout_got_sect
+ 1) {
704 nasm_nonfatal("a.out format cannot produce PC-"
705 "relative GOT references");
707 nasm_nonfatal("a.out format does not support this"
709 wrt
= NO_SEG
; /* we can at least _try_ to continue */
713 WRITELONG(p
, *(int64_t *)data
- (size
+ s
->len
));
714 aout_sect_write(s
, mydata
, 4L);
718 static void aout_pad_sections(void)
720 static uint8_t pad
[] = { 0x90, 0x90, 0x90, 0x90 };
722 * Pad each of the text and data sections with NOPs until their
723 * length is a multiple of four. (NOP == 0x90.) Also increase
724 * the length of the BSS section similarly.
726 aout_sect_write(&stext
, pad
, (-(int32_t)stext
.len
) & 3);
727 aout_sect_write(&sdata
, pad
, (-(int32_t)sdata
.len
) & 3);
728 sbss
.len
= ALIGN(sbss
.len
, 4);
732 * a.out files have the curious property that all references to
733 * things in the data or bss sections are done by addresses which
734 * are actually relative to the start of the _text_ section, in the
735 * _file_. (No relation to what happens after linking. No idea why
736 * this should be so. It's very strange.) So we have to go through
737 * the relocation table, _after_ the final size of each section is
738 * known, and fix up the relocations pointed to.
740 static void aout_fixup_relocs(struct Section
*sect
)
744 saa_rewind(sect
->data
);
745 list_for_each(r
, sect
->head
) {
746 uint8_t *p
, *q
, blk
[4];
749 saa_fread(sect
->data
, r
->address
, blk
, (int32_t)r
->bytes
);
753 l
+= ((int32_t)*p
++) << 8;
755 l
+= ((int32_t)*p
++) << 16;
756 l
+= ((int32_t)*p
++) << 24;
759 if (r
->symbol
== -SECT_DATA
)
761 else if (r
->symbol
== -SECT_BSS
)
762 l
+= stext
.len
+ sdata
.len
;
765 else if (r
->bytes
== 2)
769 saa_fwrite(sect
->data
, r
->address
, blk
, (int32_t)r
->bytes
);
773 static void aout_write(void)
776 * Emit the a.out header.
778 /* OMAGIC, M_386 or MID_I386, no flags */
779 fwriteint32_t(bsd
? 0x07018600 | is_pic
: 0x640107L
, ofile
);
780 fwriteint32_t(stext
.len
, ofile
);
781 fwriteint32_t(sdata
.len
, ofile
);
782 fwriteint32_t(sbss
.len
, ofile
);
783 fwriteint32_t(nsyms
* 12, ofile
); /* length of symbol table */
784 fwriteint32_t(0L, ofile
); /* object files have no entry point */
785 fwriteint32_t(stext
.nrelocs
* 8, ofile
); /* size of text relocs */
786 fwriteint32_t(sdata
.nrelocs
* 8, ofile
); /* size of data relocs */
789 * Write out the code section and the data section.
791 saa_fpwrite(stext
.data
, ofile
);
792 saa_fpwrite(sdata
.data
, ofile
);
795 * Write out the relocations.
797 aout_write_relocs(stext
.head
);
798 aout_write_relocs(sdata
.head
);
801 * Write the symbol table.
806 * And the string table.
808 fwriteint32_t(strslen
+ 4, ofile
); /* length includes length count */
809 saa_fpwrite(strs
, ofile
);
812 static void aout_write_relocs(struct Reloc
*r
)
814 list_for_each(r
, r
) {
817 fwriteint32_t(r
->address
, ofile
);
823 word2
|= r
->reltype
<< 24;
824 word2
|= (r
->bytes
== 1 ? 0 :
825 r
->bytes
== 2 ? 0x2000000L
: 0x4000000L
);
826 fwriteint32_t(word2
, ofile
);
830 static void aout_write_syms(void)
835 for (i
= 0; i
< nsyms
; i
++) {
836 struct Symbol
*sym
= saa_rstruct(syms
);
837 fwriteint32_t(sym
->strpos
, ofile
);
838 fwriteint32_t((int32_t)sym
->type
& ~SYM_WITH_SIZE
, ofile
);
840 * Fix up the symbol value now we know the final section
843 if ((sym
->type
& SECT_MASK
) == SECT_DATA
)
844 sym
->value
+= stext
.len
;
845 if ((sym
->type
& SECT_MASK
) == SECT_BSS
)
846 sym
->value
+= stext
.len
+ sdata
.len
;
847 fwriteint32_t(sym
->value
, ofile
);
849 * Output a size record if necessary.
851 if (sym
->type
& SYM_WITH_SIZE
) {
852 fwriteint32_t(sym
->strpos
, ofile
);
853 fwriteint32_t(0x0DL
, ofile
); /* special value: means size */
854 fwriteint32_t(sym
->size
, ofile
);
855 i
++; /* use up another of `nsyms' */
860 static void aout_sect_write(struct Section
*sect
,
861 const uint8_t *data
, uint32_t len
)
863 saa_wbytes(sect
->data
, data
, len
);
867 extern macros_t aout_stdmac
[];
869 #endif /* OF_AOUT || OF_AOUTB */
873 const struct ofmt of_aout
= {
874 "Linux a.out object files",
884 nasm_do_legacy_output
,
893 NULL
/* pragma list */
900 const struct ofmt of_aoutb
= {
901 "NetBSD/FreeBSD a.out object files",
911 nasm_do_legacy_output
,
920 NULL
/* pragma list */