NASM = nasm.$(O) nasmlib.$(O) raa.$(O) saa.$(O) \
float.$(O) insnsa.$(O) insnsb.$(O) \
assemble.$(O) labels.$(O) hashtbl.$(O) crc64.$(O) parser.$(O) \
- outform.$(O) output/outbin.$(O) \
+ outform.$(O) outlib.$(O) output/outbin.$(O) \
output/outaout.$(O) output/outcoff.$(O) \
output/outelf32.$(O) output/outelf64.$(O) \
output/outobj.$(O) output/outas86.$(O) output/outrdf2.$(O) \
nasmlib.h pptok.h preproc.h regs.h sync.h tokens.h version.h
outform.$(O): outform.c compiler.h config.h insnsi.h nasm.h nasmlib.h \
outform.h pptok.h preproc.h regs.h version.h
+outlib.$(O): outlib.c compiler.h config.h insnsi.h nasm.h nasmlib.h outlib.h \
+ pptok.h preproc.h regs.h version.h
output/outaout.$(O): output/outaout.c compiler.h config.h insnsi.h nasm.h \
nasmlib.h outform.h pptok.h preproc.h raa.h regs.h saa.h stdscan.h \
version.h
output/outdbg.$(O): output/outdbg.c compiler.h config.h insnsi.h nasm.h \
nasmlib.h outform.h pptok.h preproc.h regs.h version.h
output/outelf32.$(O): output/outelf32.c compiler.h config.h insnsi.h nasm.h \
- nasmlib.h outform.h pptok.h preproc.h raa.h regs.h saa.h stdscan.h \
+ nasmlib.h outform.h outlib.h pptok.h preproc.h raa.h regs.h saa.h stdscan.h \
version.h
output/outelf64.$(O): output/outelf64.c compiler.h config.h insnsi.h nasm.h \
nasmlib.h outform.h pptok.h preproc.h raa.h regs.h saa.h stdscan.h \
NASM = nasm.$(O) nasmlib.$(O) raa.$(O) saa.$(O) \
float.$(O) insnsa.$(O) insnsb.$(O) \
assemble.$(O) labels.$(O) hashtbl.$(O) crc64.$(O) parser.$(O) \
- outform.$(O) output/outbin.$(O) \
+ outform.$(O) outlib.$(O) output/outbin.$(O) \
output/outaout.$(O) output/outcoff.$(O) \
output/outelf32.$(O) output/outelf64.$(O) \
output/outobj.$(O) output/outas86.$(O) output/outrdf2.$(O) \
nasmlib.h pptok.h preproc.h regs.h sync.h tokens.h version.h
outform.$(O): outform.c compiler.h insnsi.h nasm.h nasmlib.h outform.h \
pptok.h preproc.h regs.h version.h
+outlib.$(O): outlib.c compiler.h insnsi.h nasm.h nasmlib.h outlib.h pptok.h \
+ preproc.h regs.h version.h
output/outaout.$(O): output/outaout.c compiler.h insnsi.h nasm.h nasmlib.h \
outform.h pptok.h preproc.h raa.h regs.h saa.h stdscan.h version.h
output/outas86.$(O): output/outas86.c compiler.h insnsi.h nasm.h nasmlib.h \
output/outdbg.$(O): output/outdbg.c compiler.h insnsi.h nasm.h nasmlib.h \
outform.h pptok.h preproc.h regs.h version.h
output/outelf32.$(O): output/outelf32.c compiler.h insnsi.h nasm.h nasmlib.h \
- outform.h pptok.h preproc.h raa.h regs.h saa.h stdscan.h version.h
+ outform.h outlib.h pptok.h preproc.h raa.h regs.h saa.h stdscan.h version.h
output/outelf64.$(O): output/outelf64.c compiler.h insnsi.h nasm.h nasmlib.h \
outform.h pptok.h preproc.h raa.h regs.h saa.h stdscan.h version.h
output/outieee.$(O): output/outieee.c compiler.h insnsi.h nasm.h nasmlib.h \
NASM = nasm.o nasmlib.o raa.o saa.o \
float.o insnsa.o insnsb.o \
assemble.o labels.o hashtbl.o crc64.o parser.o \
- outform.o outbin.o \
+ outform.o outlib.o outbin.o \
outaout.o outcoff.o \
outelf32.o outelf64.o \
outobj.o outas86.o outrdf2.o \
nasmlib.h pptok.h preproc.h regs.h sync.h tokens.h version.h
outform.o: outform.c compiler.h config.h insnsi.h nasm.h nasmlib.h outform.h \
pptok.h preproc.h regs.h version.h
+outlib.o: outlib.c compiler.h config.h insnsi.h nasm.h nasmlib.h outlib.h \
+ pptok.h preproc.h regs.h version.h
outaout.o: outaout.c compiler.h config.h insnsi.h nasm.h nasmlib.h outform.h \
pptok.h preproc.h raa.h regs.h saa.h stdscan.h version.h
outas86.o: outas86.c compiler.h config.h insnsi.h nasm.h nasmlib.h outform.h \
outdbg.o: outdbg.c compiler.h config.h insnsi.h nasm.h nasmlib.h outform.h \
pptok.h preproc.h regs.h version.h
outelf32.o: outelf32.c compiler.h config.h insnsi.h nasm.h nasmlib.h \
- outform.h pptok.h preproc.h raa.h regs.h saa.h stdscan.h version.h
+ outform.h outlib.h pptok.h preproc.h raa.h regs.h saa.h stdscan.h version.h
outelf64.o: outelf64.c compiler.h config.h insnsi.h nasm.h nasmlib.h \
outform.h pptok.h preproc.h raa.h regs.h saa.h stdscan.h version.h
outieee.o: outieee.c compiler.h config.h insnsi.h nasm.h nasmlib.h outform.h \
NASM = nasm.$(O) nasmlib.$(O) raa.$(O) saa.$(O) &
float.$(O) insnsa.$(O) insnsb.$(O) &
assemble.$(O) labels.$(O) hashtbl.$(O) crc64.$(O) parser.$(O) &
- outform.$(O) output\outbin.$(O) &
+ outform.$(O) outlib.$(O) output\outbin.$(O) &
output\outaout.$(O) output\outcoff.$(O) &
output\outelf32.$(O) output\outelf64.$(O) &
output\outobj.$(O) output\outas86.$(O) output\outrdf2.$(O) &
nasmlib.h pptok.h preproc.h regs.h sync.h tokens.h version.h
outform.$(O): outform.c compiler.h insnsi.h nasm.h nasmlib.h outform.h &
pptok.h preproc.h regs.h version.h
+outlib.$(O): outlib.c compiler.h insnsi.h nasm.h nasmlib.h outlib.h pptok.h &
+ preproc.h regs.h version.h
output\outaout.$(O): output\outaout.c compiler.h insnsi.h nasm.h nasmlib.h &
outform.h pptok.h preproc.h raa.h regs.h saa.h stdscan.h version.h
output\outas86.$(O): output\outas86.c compiler.h insnsi.h nasm.h nasmlib.h &
output\outdbg.$(O): output\outdbg.c compiler.h insnsi.h nasm.h nasmlib.h &
outform.h pptok.h preproc.h regs.h version.h
output\outelf32.$(O): output\outelf32.c compiler.h insnsi.h nasm.h nasmlib.h &
- outform.h pptok.h preproc.h raa.h regs.h saa.h stdscan.h version.h
+ outform.h outlib.h pptok.h preproc.h raa.h regs.h saa.h stdscan.h version.h
output\outelf64.$(O): output\outelf64.c compiler.h insnsi.h nasm.h nasmlib.h &
outform.h pptok.h preproc.h raa.h regs.h saa.h stdscan.h version.h
output\outieee.$(O): output\outieee.c compiler.h insnsi.h nasm.h nasmlib.h &
NASM = nasm.$(O) nasmlib.$(O) raa.$(O) saa.$(O) \
float.$(O) insnsa.$(O) insnsb.$(O) \
assemble.$(O) labels.$(O) hashtbl.$(O) crc64.$(O) parser.$(O) \
- outform.$(O) output/outbin.$(O) \
+ outform.$(O) outlib.$(O) output/outbin.$(O) \
output/outaout.$(O) output/outcoff.$(O) \
output/outelf32.$(O) output/outelf64.$(O) \
output/outobj.$(O) output/outas86.$(O) output/outrdf2.$(O) \
nasmlib.h pptok.h preproc.h regs.h sync.h tokens.h version.h
outform.$(O): outform.c compiler.h insnsi.h nasm.h nasmlib.h outform.h \
pptok.h preproc.h regs.h version.h
+outlib.$(O): outlib.c compiler.h insnsi.h nasm.h nasmlib.h outlib.h pptok.h \
+ preproc.h regs.h version.h
output/outaout.$(O): output/outaout.c compiler.h insnsi.h nasm.h nasmlib.h \
outform.h pptok.h preproc.h raa.h regs.h saa.h stdscan.h version.h
output/outas86.$(O): output/outas86.c compiler.h insnsi.h nasm.h nasmlib.h \
output/outdbg.$(O): output/outdbg.c compiler.h insnsi.h nasm.h nasmlib.h \
outform.h pptok.h preproc.h regs.h version.h
output/outelf32.$(O): output/outelf32.c compiler.h insnsi.h nasm.h nasmlib.h \
- outform.h pptok.h preproc.h raa.h regs.h saa.h stdscan.h version.h
+ outform.h outlib.h pptok.h preproc.h raa.h regs.h saa.h stdscan.h version.h
output/outelf64.$(O): output/outelf64.c compiler.h insnsi.h nasm.h nasmlib.h \
outform.h pptok.h preproc.h raa.h regs.h saa.h stdscan.h version.h
output/outieee.$(O): output/outieee.c compiler.h insnsi.h nasm.h nasmlib.h \
--- /dev/null
+/*
+ * libout.c
+ *
+ * Common routines for the output backends.
+ */
+
+#include "compiler.h"
+#include "nasm.h"
+#include "outlib.h"
+
+uint64_t realsize(enum out_type type, uint64_t size)
+{
+ switch (type) {
+ case OUT_REL2ADR:
+ return 2;
+ case OUT_REL4ADR:
+ return 4;
+ case OUT_REL8ADR:
+ return 8;
+ default:
+ return size;
+ }
+}
--- /dev/null
+#ifndef NASM_OUTLIB_H
+#define NSAM_OUTLIB_H
+
+#include "nasm.h"
+
+uint64_t realsize(enum out_type type, uint64_t size);
+
+#endif /* LIBOUT_H */
+
#include "raa.h"
#include "stdscan.h"
#include "outform.h"
+#include "outlib.h"
#if defined OF_AOUT || defined OF_AOUTB
if (!s && type != OUT_RESERVE) {
error(ERR_WARNING, "attempt to initialize memory in the"
" BSS section: ignored");
- if (type == OUT_REL2ADR)
- size = 2;
- else if (type == OUT_REL4ADR)
- size = 4;
- sbss.len += size;
+ sbss.len += realsize(type, size);
return;
}
#include "saa.h"
#include "raa.h"
#include "outform.h"
+#include "outlib.h"
#ifdef OF_AS86
if (!s && type != OUT_RESERVE) {
error(ERR_WARNING, "attempt to initialize memory in the"
" BSS section: ignored");
- if (type == OUT_REL2ADR)
- size = 2;
- else if (type == OUT_REL4ADR)
- size = 4;
- bsslen += size;
+ bsslen += realsize(type, size);
return;
}
#include "labels.h"
#include "eval.h"
#include "outform.h"
+#include "outlib.h"
#ifdef OF_BIN
} else if (type == OUT_REL2ADR || type == OUT_REL4ADR ||
type == OUT_REL8ADR) {
int64_t addr = *(int64_t *)data - size;
- switch (type) {
- case OUT_REL2ADR:
- size = 2;
- break;
- case OUT_REL4ADR:
- size = 4;
- break;
- case OUT_REL8ADR:
- size = 8;
- break;
- default:
- size = 0; /* Shut up warning */
- break;
- }
+ size = realsize(type, size);
if (segment != NO_SEG && !find_section_by_index(segment)) {
if (segment % 2)
error(ERR_NONFATAL, "binary output format does not support"
#include "saa.h"
#include "raa.h"
#include "outform.h"
+#include "outlib.h"
#if defined(OF_COFF) || defined(OF_WIN32) || defined(OF_WIN64)
if (!s->data && type != OUT_RESERVE) {
error(ERR_WARNING, "attempt to initialize memory in"
" BSS section `%s': ignored", s->name);
- if (type == OUT_REL2ADR)
- size = 2;
- else if (type == OUT_REL4ADR)
- size = 4;
- s->len += size;
+ s->len += realsize(type, size);
return;
}
#include "raa.h"
#include "stdscan.h"
#include "outform.h"
+#include "outlib.h"
#ifdef OF_ELF32
if (s->type == SHT_NOBITS && type != OUT_RESERVE) {
error(ERR_WARNING, "attempt to initialize memory in"
" BSS section `%s': ignored", s->name);
- if (type == OUT_REL2ADR)
- size = 2;
- else if (type == OUT_REL4ADR)
- size = 4;
- s->len += size;
+ s->len += realsize(type, size);
return;
}
#include "raa.h"
#include "stdscan.h"
#include "outform.h"
+#include "outlib.h"
/* Definitions in lieu of elf.h */
#define SHT_NULL 0 /* Inactive section header */
if (s->type == SHT_NOBITS && type != OUT_RESERVE) {
error(ERR_WARNING, "attempt to initialize memory in"
" BSS section `%s': ignored", s->name);
- switch (type) {
- case OUT_REL2ADR:
- size = 2;
- break;
- case OUT_REL4ADR:
- size = 4;
- break;
- case OUT_REL8ADR:
- size = 8;
- break;
- default:
- break; /* size is already set */
- }
- s->len += size;
+ s->len += realsize(type, size);
return;
}
#include "saa.h"
#include "raa.h"
#include "outform.h"
-#include "compiler.h"
+#include "outlib.h"
#if defined(OF_MACHO)
if (s == sbss && type != OUT_RESERVE) {
error(ERR_WARNING, "attempt to initialize memory in the"
" BSS section: ignored");
-
- switch (type) {
- case OUT_REL2ADR:
- size = 2;
- break;
-
- case OUT_REL4ADR:
- size = 4;
- break;
-
- default:
- break;
- }
-
- s->size += size;
+ s->size += realsize(type, size);
return;
}
if (type == OUT_REL2ADR) {
ldata += (size - 2);
size = 2;
- }
- if (type == OUT_REL4ADR) {
+ } else if (type == OUT_REL4ADR) {
ldata += (size - 4);
size = 4;
}