static struct ofmt *outfmt;
static ListGen *list;
-static int32_t calcsize(int32_t, int32_t, int, insn *, const int8_t *);
-static void gencode(int32_t, int32_t, int, insn *, const int8_t *, int32_t);
+static int32_t calcsize(int32_t, int32_t, int, insn *, const char *);
+static void gencode(int32_t, int32_t, int, insn *, const char *, int32_t);
static int regval(operand * o);
static int regflag(operand * o);
static int matches(struct itemplate *, insn *, int bits);
uint32_t type, int32_t segment, int32_t wrt)
{
static int32_t lineno = 0; /* static!!! */
- static int8_t *lnfname = NULL;
+ static char *lnfname = NULL;
if ((type & OUT_TYPMASK) == OUT_ADDRESS) {
if (segment != NO_SEG || wrt != NO_SEG) {
}
static int jmp_match(int32_t segment, int32_t offset, int bits,
- insn * ins, const int8_t *code)
+ insn * ins, const char *code)
{
int32_t isize;
uint8_t c = code[0];
}
if (instruction->opcode == I_INCBIN) {
- static int8_t fname[FILENAME_MAX];
+ static char fname[FILENAME_MAX];
FILE *fp;
int32_t len;
- int8_t *prefix = "", *combine;
- int8_t **pPrevPath = NULL;
+ char *prefix = "", *combine;
+ char **pPrevPath = NULL;
len = FILENAME_MAX - 1;
if (len > instruction->eops->stringlen)
error(ERR_NONFATAL, "`incbin': unable to seek on file `%s'",
fname);
else {
- static int8_t buf[2048];
+ static char buf[2048];
int32_t t = instruction->times;
int32_t base = 0;
m += jmp_match(segment, offset, bits, instruction, temp->code);
if (m == 100) { /* matches! */
- const int8_t *codes = temp->code;
+ const char *codes = temp->code;
int32_t insn_size = calcsize(segment, offset, bits,
instruction, codes);
itimes = instruction->times;
}
if (instruction->opcode == I_INCBIN) {
- int8_t fname[FILENAME_MAX];
+ char fname[FILENAME_MAX];
FILE *fp;
int32_t len;
- int8_t *prefix = "", *combine;
- int8_t **pPrevPath = NULL;
+ char *prefix = "", *combine;
+ char **pPrevPath = NULL;
len = FILENAME_MAX - 1;
if (len > instruction->eops->stringlen)
if (m == 100) {
/* we've matched an instruction. */
int32_t isize;
- const int8_t *codes = temp->code;
+ const char *codes = temp->code;
int j;
isize = calcsize(segment, offset, bits, instruction, codes);
}
static int32_t calcsize(int32_t segment, int32_t offset, int bits,
- insn * ins, const int8_t *codes)
+ insn * ins, const char *codes)
{
int32_t length = 0;
uint8_t c;
return length; }
static void gencode(int32_t segment, int32_t offset, int bits,
- insn * ins, const int8_t *codes, int32_t insn_end)
+ insn * ins, const char *codes, int32_t insn_end)
{
- static int8_t condval[] = { /* conditional opcodes */
+ static char condval[] = { /* conditional opcodes */
0x7, 0x3, 0x2, 0x6, 0x2, 0x4, 0xF, 0xD, 0xC, 0xE, 0x6, 0x2,
0x3, 0x7, 0x3, 0x5, 0xE, 0xC, 0xD, 0xF, 0x1, 0xB, 0x9, 0x5,
0x0, 0xA, 0xA, 0xB, 0x8, 0x4
return 0;
}
-static const int8_t *whichcond(int condval)
+static const char *whichcond(int condval)
{
static int conds[] = {
C_O, C_NO, C_C, C_NC, C_Z, C_NZ, C_NA, C_A,
break;
case 1:
op->segment |= SEG_DISP8;
- op->offset = (int8_t)*data++;
+ op->offset = (char)*data++;
break;
case 2:
op->segment |= SEG_DISP16;
break;
case 1:
op->segment |= SEG_DISP8;
- op->offset = (int8_t)*data++;
+ op->offset = (char)*data++;
break;
case 2:
op->segment |= SEG_DISP32;
if (*data++)
return FALSE;
if (c >= 014 && c <= 016) {
- ins->oprs[c - 014].offset = (int8_t)*data++;
+ ins->oprs[c - 014].offset = (char)*data++;
ins->oprs[c - 014].segment |= SEG_SIGNED;
}
if (c >= 020 && c <= 022)
ins->oprs[c - 044].addr_size = asize;
}
if (c >= 050 && c <= 052) {
- ins->oprs[c - 050].offset = (int8_t)*data++;
+ ins->oprs[c - 050].offset = (char)*data++;
ins->oprs[c - 050].segment |= SEG_RELATIVE;
}
if (c >= 060 && c <= 062) {
return data - origdata;
}
-int32_t disasm(uint8_t *data, int8_t *output, int outbufsize, int segsize,
+int32_t disasm(uint8_t *data, char *output, int outbufsize, int segsize,
int32_t offset, int autosync, uint32_t prefer)
{
struct itemplate **p, **best_p;
int length, best_length = 0;
- int8_t *segover;
+ char *segover;
int rep, lock, asize, osize, i, slen, colon;
uint8_t *origdata;
int works;
if (ins.oprs[i].segment & SEG_DISP8) {
int sign = '+';
if (ins.oprs[i].offset & 0x80) {
- ins.oprs[i].offset = -(int8_t)ins.oprs[i].offset;
+ ins.oprs[i].offset = -(char)ins.oprs[i].offset;
sign = '-';
}
slen +=
}
output[slen] = '\0';
if (segover) { /* unused segment override */
- int8_t *p = output;
+ char *p = output;
int count = slen + 1;
while (count--)
p[count + 3] = p[count];
return length;
}
-int32_t eatbyte(uint8_t *data, int8_t *output, int outbufsize)
+int32_t eatbyte(uint8_t *data, char *output, int outbufsize)
{
snprintf(output, outbufsize, "db 0x%02X", *data);
return 1;
#define INSN_MAX 32 /* one instruction can't be longer than this */
-int32_t disasm(uint8_t *data, int8_t *output, int outbufsize, int segsize,
+int32_t disasm(uint8_t *data, char *output, int outbufsize, int segsize,
int32_t offset, int autosync, uint32_t prefer);
-int32_t eatbyte(uint8_t *data, int8_t *output, int outbufsize);
+int32_t eatbyte(uint8_t *data, char *output, int outbufsize);
#endif
}
}
-static void ieee_flconvert(int8_t *string, uint16_t *mant,
+static void ieee_flconvert(char *string, uint16_t *mant,
int32_t *exponent, efunc error)
{
- int8_t digits[MANT_DIGITS];
- int8_t *p, *q, *r;
+ char digits[MANT_DIGITS];
+ char *p, *q, *r;
uint16_t mult[MANT_WORDS], bit;
uint16_t *m;
int32_t tenpwr, twopwr;
#define put(a,b) ( (*(a)=(b)), ((a)[1]=(b)>>8) )
-static int to_double(int8_t *str, int32_t sign, uint8_t *result,
+static int to_double(char *str, int32_t sign, uint8_t *result,
efunc error)
{
uint16_t mant[MANT_WORDS];
return 1; /* success */
}
-static int to_float(int8_t *str, int32_t sign, uint8_t *result,
+static int to_float(char *str, int32_t sign, uint8_t *result,
efunc error)
{
uint16_t mant[MANT_WORDS];
return 1;
}
-static int to_ldoub(int8_t *str, int32_t sign, uint8_t *result,
+static int to_ldoub(char *str, int32_t sign, uint8_t *result,
efunc error)
{
uint16_t mant[MANT_WORDS];
return 1;
}
-int float_const(int8_t *number, int32_t sign, uint8_t *result, int bytes,
+int float_const(char *number, int32_t sign, uint8_t *result, int bytes,
efunc error)
{
if (bytes == 4)
#ifndef NASM_FLOAT_H
#define NASM_FLOAT_H
-int float_const(int8_t *number, int32_t sign, uint8_t *result, int bytes,
+int float_const(char *number, int32_t sign, uint8_t *result, int bytes,
efunc error);
#endif
int opcode; /* the token, passed from "parser.c" */
int operands; /* number of operands */
int32_t opd[3]; /* bit flags for operand types */
- const int8_t *code; /* the code it assembles to */
+ const char *code; /* the code it assembles to */
uint32_t flags; /* some flags */
};
print A "/* This file auto-generated from insns.dat by insns.pl" .
" - don't edit it */\n\n";
- print A "#include \<inttypes.h\>\n\n";
print A "#include \"nasm.h\"\n";
print A "#include \"insns.h\"\n";
print A "\n";
print D "/* This file auto-generated from insns.dat by insns.pl" .
" - don't edit it */\n\n";
- print D "#include \<inttypes.h\>\n\n";
print D "#include \"nasm.h\"\n";
print D "#include \"insns.h\"\n";
print D "\n";
print N "/* This file is auto-generated from insns.dat by insns.pl" .
" - don't edit it */\n\n";
print N "/* This file in included by names.c */\n\n";
- print N "#include \<inttypes.h\>\n\n";
- print N "static const int8_t *insn_names[] = {";
+ print N "static const char *insn_names[] = {";
$first = 1;
foreach $i (@opcodes) {
print N "," if ( !$first );
}
print N "\n};\n\n";
print N "/* Conditional instructions */\n";
- print N "static const int8_t *icn[] = {";
+ print N "static const char *icn[] = {";
$first = 1;
foreach $i (@opcodes_cc) {
print N "," if ( !$first );
union label { /* actual label structures */
struct {
int32_t segment, offset;
- int8_t *label, *special;
+ char *label, *special;
int is_global, is_norm;
} defn;
struct {
struct permts { /* permanent text storage */
struct permts *next; /* for the linked list */
int size, usage; /* size and used space in ... */
- int8_t data[PERMTS_SIZE]; /* ... the data block itself */
+ char data[PERMTS_SIZE]; /* ... the data block itself */
};
extern int global_offset_changed; /* defined in nasm.c */
static struct permts *perm_tail; /* end of perm. text storage */
static void init_block(union label *blk);
-static int8_t *perm_copy(int8_t *string1, int8_t *string2);
+static char *perm_copy(char *string1, char *string2);
-static int8_t *prevlabel;
+static char *prevlabel;
static int initialized = FALSE;
-int8_t lprefix[PREFIX_MAX] = { 0 };
-int8_t lpostfix[PREFIX_MAX] = { 0 };
+char lprefix[PREFIX_MAX] = { 0 };
+char lpostfix[PREFIX_MAX] = { 0 };
/*
* Internal routine: finds the `union label' corresponding to the
* given label name. Creates a new one, if it isn't found, and if
* `create' is TRUE.
*/
-static union label *find_label(int8_t *label, int create)
+static union label *find_label(char *label, int create)
{
int hash = 0;
- int8_t *p, *prev;
+ char *p, *prev;
int prevlen;
union label *lptr;
return NULL;
}
-int lookup_label(int8_t *label, int32_t *segment, int32_t *offset)
+int lookup_label(char *label, int32_t *segment, int32_t *offset)
{
union label *lptr;
return 0;
}
-int is_extern(int8_t *label)
+int is_extern(char *label)
{
union label *lptr;
return 0;
}
-void redefine_label(int8_t *label, int32_t segment, int32_t offset, int8_t *special,
+void redefine_label(char *label, int32_t segment, int32_t offset, char *special,
int is_norm, int isextrn, struct ofmt *ofmt,
efunc error)
{
if (pass0 == 1) {
exi = !!(lptr->defn.is_global & GLOBAL_BIT);
if (exi) {
- int8_t *xsymbol;
+ char *xsymbol;
int slen;
slen = strlen(lprefix);
slen += strlen(lptr->defn.label);
slen += strlen(lpostfix);
- slen++; /* room for that null int8_t */
+ slen++; /* room for that null char */
xsymbol = nasm_malloc(slen);
snprintf(xsymbol, slen, "%s%s%s", lprefix, lptr->defn.label,
lpostfix);
/* if (pass0 == 1) */
}
-void define_label(int8_t *label, int32_t segment, int32_t offset, int8_t *special,
+void define_label(char *label, int32_t segment, int32_t offset, char *special,
int is_norm, int isextrn, struct ofmt *ofmt, efunc error)
{
union label *lptr;
if (pass0 == 1 || (!is_norm && !isextrn && (segment & 1))) {
exi = !!(lptr->defn.is_global & GLOBAL_BIT);
if (exi) {
- int8_t *xsymbol;
+ char *xsymbol;
int slen;
slen = strlen(lprefix);
slen += strlen(lptr->defn.label);
} /* if (pass0 == 1) */
}
-void define_common(int8_t *label, int32_t segment, int32_t size, int8_t *special,
+void define_common(char *label, int32_t segment, int32_t size, char *special,
struct ofmt *ofmt, efunc error)
{
union label *lptr;
special);
}
-void declare_as_global(int8_t *label, int8_t *special, efunc error)
+void declare_as_global(char *label, char *special, efunc error)
{
union label *lptr;
blk[LABEL_BLOCK - 1].admin.next = NULL;
}
-static int8_t *perm_copy(int8_t *string1, int8_t *string2)
+static char *perm_copy(char *string1, char *string2)
{
- int8_t *p, *q;
+ char *p, *q;
int len = strlen(string1) + strlen(string2) + 1;
if (perm_tail->size - perm_tail->usage < len) {
* distributed in the NASM archive.
*/
-extern int8_t lprefix[PREFIX_MAX];
-extern int8_t lpostfix[PREFIX_MAX];
+extern char lprefix[PREFIX_MAX];
+extern char lpostfix[PREFIX_MAX];
-int lookup_label(int8_t *label, int32_t *segment, int32_t *offset);
-int is_extern(int8_t *label);
-void define_label(int8_t *label, int32_t segment, int32_t offset, int8_t *special,
+int lookup_label(char *label, int32_t *segment, int32_t *offset);
+int is_extern(char *label);
+void define_label(char *label, int32_t segment, int32_t offset, char *special,
int is_norm, int isextrn, struct ofmt *ofmt,
efunc error);
-void redefine_label(int8_t *label, int32_t segment, int32_t offset, int8_t *special,
+void redefine_label(char *label, int32_t segment, int32_t offset, char *special,
int is_norm, int isextrn, struct ofmt *ofmt,
efunc error);
-void define_common(int8_t *label, int32_t segment, int32_t size, int8_t *special,
+void define_common(char *label, int32_t segment, int32_t size, char *special,
struct ofmt *ofmt, efunc error);
-void declare_as_global(int8_t *label, int8_t *special, efunc error);
+void declare_as_global(char *label, char *special, efunc error);
int init_labels(void);
void cleanup_labels(void);
#define NASMPATH "/usr/local/bin/nasm"
-int8_t *cpp[] = { LCCDIR "cpp", "-D__STDC__=1",
+char *cpp[] = { LCCDIR "cpp", "-D__STDC__=1",
"-Di386", "-D__i386", "-D__i386__",
"-Dlinux", "-D__linux", "-D__linux__",
"-Dunix", "-D__unix", "-D__unix__",
"$1", "$2", "$3", 0
};
-int8_t *include[] = { "-I" LCCDIR "include", "-I/usr/local/include",
+char *include[] = { "-I" LCCDIR "include", "-I/usr/local/include",
"-I/usr/include", 0
};
-int8_t *com[] = { LCCDIR "rcc", "-target=x86/nasm",
+char *com[] = { LCCDIR "rcc", "-target=x86/nasm",
"$1", "$2", "$3", 0
};
-int8_t *as[] = { NASMPATH, "-a", "-faout", "-o", "$3", "$1", "$2", 0 };
-int8_t *ld[] = { "/usr/bin/ld", "-m", "i386linux",
+char *as[] = { NASMPATH, "-a", "-faout", "-o", "$3", "$1", "$2", 0 };
+char *ld[] = { "/usr/bin/ld", "-m", "i386linux",
"-L/usr/i486-linuxaout/lib",
"-o", "$3", "$1",
"/usr/i486-linuxaout/lib/crt0.o",
"$2", "", "-lc", 0
};
-static int8_t *bbexit = LCCDIR "bbexit.o";
+static char *bbexit = LCCDIR "bbexit.o";
-extern int8_t *concat(int8_t *, int8_t *);
-extern int access(const int8_t *, int);
+extern char *concat(char *, char *);
+extern int access(const char *, int);
-int option(int8_t *arg)
+int option(char *arg)
{
if (strncmp(arg, "-lccdir=", 8) == 0) {
cpp[0] = concat(&arg[8], "/cpp");
#define NASMPATH "/usr/local/bin/nasm"
-int8_t *cpp[] = { LCCDIR "cpp", "-D__STDC__=1",
+char *cpp[] = { LCCDIR "cpp", "-D__STDC__=1",
"-D__ELF__", "-Di386", "-D__i386", "-D__i386__",
"-Dlinux", "-D__linux", "-D__linux__",
"$1", "$2", "$3", 0
};
-int8_t *include[] = { "-I" LCCDIR "include", "-I/usr/local/include",
+char *include[] = { "-I" LCCDIR "include", "-I/usr/local/include",
"-I/usr/include", 0
};
-int8_t *com[] = { LCCDIR "rcc", "-target=x86/nasm",
+char *com[] = { LCCDIR "rcc", "-target=x86/nasm",
"$1", "$2", "$3", 0
};
-int8_t *as[] = { NASMPATH, "-a", "-felf", "-o", "$3", "$1", "$2", 0 };
-int8_t *ld[] = { "/usr/bin/ld", "-m", "elf_i386",
+char *as[] = { NASMPATH, "-a", "-felf", "-o", "$3", "$1", "$2", 0 };
+char *ld[] = { "/usr/bin/ld", "-m", "elf_i386",
"-dynamic-linker", "/lib/ld-linux.so.1",
"-L/usr/i486-linux/lib",
"-o", "$3", "$1",
"$2", "",
"-lc", "", "/usr/lib/crtend.o", "/usr/lib/crtn.o", 0
};
-static int8_t *bbexit = LCCDIR "bbexit.o";
+static char *bbexit = LCCDIR "bbexit.o";
-extern int8_t *concat(int8_t *, int8_t *);
-extern int access(const int8_t *, int);
+extern char *concat(char *, char *);
+extern int access(const char *, int);
-int option(int8_t *arg)
+int option(char *arg)
{
if (strncmp(arg, "-lccdir=", 8) == 0) {
cpp[0] = concat(&arg[8], "/cpp");
int inhibiting;
} *mistack;
-static int8_t xdigit[] = "0123456789ABCDEF";
+static char xdigit[] = "0123456789ABCDEF";
#define HEX(a,b) (*(a)=xdigit[((b)>>4)&15],(a)[1]=xdigit[(b)&15]);
-static int8_t listline[LIST_MAX_LEN];
+static char listline[LIST_MAX_LEN];
static int listlinep;
-static int8_t listdata[2 * LIST_INDENT]; /* we need less than that actually */
+static char listdata[2 * LIST_INDENT]; /* we need less than that actually */
static int32_t listoffset;
static int32_t listlineno;
listdata[0] = '\0';
}
-static void list_init(int8_t *fname, efunc error)
+static void list_init(char *fname, efunc error)
{
listfp = fopen(fname, "w");
if (!listfp) {
fclose(listfp);
}
-static void list_out(int32_t offset, int8_t *str)
+static void list_out(int32_t offset, char *str)
{
if (strlen(listdata) + strlen(str) > LIST_HEXBIT) {
strcat(listdata, "-");
if (typ == OUT_RAWDATA) {
uint8_t const *p = data;
- int8_t q[3];
+ char q[3];
while (size--) {
HEX(q, *p);
q[2] = '\0';
}
} else if (typ == OUT_ADDRESS) {
uint64_t d = *(int64_t *)data;
- int8_t q[20];
+ char q[20];
uint8_t p[8], *r = p;
if (size == 4) {
q[0] = '[';
}
} else if (typ == OUT_REL2ADR) {
uint32_t d = *(int32_t *)data;
- int8_t q[11];
+ char q[11];
uint8_t p[4], *r = p;
q[0] = '(';
q[5] = ')';
list_out(offset, q);
} else if (typ == OUT_REL4ADR) {
uint32_t d = *(int32_t *)data;
- int8_t q[11];
+ char q[11];
uint8_t p[4], *r = p;
q[0] = '(';
q[9] = ')';
HEX(q + 7, p[3]);
list_out(offset, q);
} else if (typ == OUT_RESERVE) {
- int8_t q[20];
+ char q[20];
snprintf(q, sizeof(q), "<res %08lX>", size);
list_out(offset, q);
}
}
-static void list_line(int type, int8_t *line)
+static void list_line(int type, char *line)
{
if (!listp)
return;
open(OUTPUT,">macros.c") or die "unable to open macros.c\n";
print OUTPUT "/* This file auto-generated from standard.mac by macros.pl" .
-" - don't edit it */\n\n#include <stddef.h>\n#include <inttypes.h>\n\nstatic const int8_t *stdmac[] = {\n";
+" - don't edit it */\n\n#include <stddef.h>\n\nstatic const char *stdmac[] = {\n";
foreach $fname ( @ARGV ) {
open(INPUT,$fname) or die "unable to open $fname\n";
* distributed in the NASM archive.
*/
-static const int8_t *conditions[] = { /* condition code names */
+static const char *conditions[] = { /* condition code names */
"a", "ae", "b", "be", "c", "e", "g", "ge", "l", "le", "na", "nae",
"nb", "nbe", "nc", "ne", "ng", "nge", "nl", "nle", "no", "np",
"ns", "nz", "o", "p", "pe", "po", "s", "z"
int operand;
};
-static int get_bits(int8_t *value);
-static uint32_t get_cpu(int8_t *cpu_str);
-static void parse_cmdline(int, int8_t **);
-static void assemble_file(int8_t *);
-static int getkw(int8_t **directive, int8_t **value);
+static int get_bits(char *value);
+static uint32_t get_cpu(char *cpu_str);
+static void parse_cmdline(int, char **);
+static void assemble_file(char *);
+static int getkw(char **directive, char **value);
static void register_output_formats(void);
-static void report_error_gnu(int severity, const int8_t *fmt, ...);
-static void report_error_vc(int severity, const int8_t *fmt, ...);
-static void report_error_common(int severity, const int8_t *fmt,
+static void report_error_gnu(int severity, const char *fmt, ...);
+static void report_error_vc(int severity, const char *fmt, ...);
+static void report_error_common(int severity, const char *fmt,
va_list args);
static int is_suppressed_warning(int severity);
static void usage(void);
int pass0;
int maxbits = 0;
-static int8_t inname[FILENAME_MAX];
-static int8_t outname[FILENAME_MAX];
-static int8_t listname[FILENAME_MAX];
+static char inname[FILENAME_MAX];
+static char outname[FILENAME_MAX];
+static char listname[FILENAME_MAX];
static int globallineno; /* for forward-reference tracking */
/* static int pass = 0; */
static struct ofmt *ofmt = NULL;
* Which of the suppressible warnings are suppressed. Entry zero
* doesn't do anything. Initial defaults are given here.
*/
-static int8_t suppressed[1 + ERR_WARN_MAX] = {
+static char suppressed[1 + ERR_WARN_MAX] = {
0, TRUE, TRUE, TRUE, FALSE, TRUE
};
* The option names for the suppressible warnings. As before, entry
* zero does nothing.
*/
-static const int8_t *suppressed_names[1 + ERR_WARN_MAX] = {
+static const char *suppressed_names[1 + ERR_WARN_MAX] = {
NULL, "macro-params", "macro-selfref", "orphan-labels",
"number-overflow",
"gnu-elf-extensions"
* The explanations for the suppressible warnings. As before, entry
* zero does nothing.
*/
-static const int8_t *suppressed_what[1 + ERR_WARN_MAX] = {
+static const char *suppressed_what[1 + ERR_WARN_MAX] = {
NULL,
"macro calls with wrong no. of params",
"cyclic macro self-references",
* not preprocess their source file.
*/
-static void no_pp_reset(int8_t *, int, efunc, evalfunc, ListGen *);
-static int8_t *no_pp_getline(void);
+static void no_pp_reset(char *, int, efunc, evalfunc, ListGen *);
+static char *no_pp_getline(void);
static void no_pp_cleanup(int);
static Preproc no_pp = {
no_pp_reset,
static int terminate_after_phase;
int user_nolist = 0; /* fbk 9/2/00 */
-static void nasm_fputs(const int8_t *line, FILE * outfile)
+static void nasm_fputs(const char *line, FILE * outfile)
{
if (outfile) {
fputs(line, outfile);
/* define some macros dependent of command-line */
{
- int8_t temp[64];
+ char temp[64];
snprintf(temp, sizeof(temp), "__OUTPUT_FORMAT__=%s\n",
ofmt->shortname);
pp_pre_define(temp);
switch (operating_mode) {
case op_depend:
{
- int8_t *line;
+ char *line;
preproc->reset(inname, 0, report_error, evaluate, &nasmlist);
if (outname[0] == '\0')
ofmt->filename(inname, outname, report_error);
case op_preprocess:
{
- int8_t *line;
- int8_t *file_name = NULL;
+ char *line;
+ char *file_name = NULL;
int32_t prior_linnum = 0;
int lineinc = 0;
* Get a parameter for a command line option.
* First arg must be in the form of e.g. -f...
*/
-static int8_t *get_param(int8_t *p, int8_t *q, int *advance)
+static char *get_param(char *p, char *q, int *advance)
{
*advance = 0;
if (p[2]) { /* the parameter's in the option */
}
struct textargs {
- const int8_t *label;
+ const char *label;
int value;
};
};
int stopoptions = 0;
-static int process_arg(int8_t *p, int8_t *q)
+static int process_arg(char *p, char *q)
{
- int8_t *param;
+ char *param;
int i, advance = 0;
if (!p || !p[0])
case 'r':
case 'v':
{
- const int8_t *nasm_version_string =
+ const char *nasm_version_string =
"NASM version " NASM_VER " compiled on " __DATE__
#ifdef DEBUG
" with -DDEBUG"
static void process_respfile(FILE * rfile)
{
- int8_t *buffer, *p, *q, *prevarg;
+ char *buffer, *p, *q, *prevarg;
int bufsize, prevargsize;
bufsize = prevargsize = ARG_BUF_DELTA;
* argv array. Used by the environment variable and response file
* processing.
*/
-static void process_args(int8_t *args)
+static void process_args(char *args)
{
- int8_t *p, *q, *arg, *prevarg;
- int8_t separator = ' ';
+ char *p, *q, *arg, *prevarg;
+ char separator = ' ';
p = args;
if (*p && *p != '-')
process_arg(arg, NULL);
}
-static void parse_cmdline(int argc, int8_t **argv)
+static void parse_cmdline(int argc, char **argv)
{
FILE *rfile;
- int8_t *envreal, *envcopy = NULL, *p, *arg;
+ char *envreal, *envcopy = NULL, *p, *arg;
*inname = *outname = *listname = '\0';
* different to the -@resp file processing below for regular
* NASM.
*/
- int8_t *str = malloc(2048);
+ char *str = malloc(2048);
FILE *f = fopen(&argv[0][1], "r");
if (!str) {
printf("out of memory");
argv++;
}
if (!stopoptions && argv[0][0] == '-' && argv[0][1] == '@') {
- if ((p = get_param(argv[0], argc > 1 ? argv[1] : NULL, &i))) {
- if ((rfile = fopen(p, "r"))) {
+ p = get_param(argv[0], argc > 1 ? argv[1] : NULL, &i);
+ if (p) {
+ rfile = fopen(p, "r");
+ if (rfile) {
process_respfile(rfile);
fclose(rfile);
} else
"no input file specified");
}
-static void assemble_file(int8_t *fname)
+static void assemble_file(char *fname)
{
- int8_t *directive, *value, *p, *q, *special, *line, debugid[80];
+ char *directive, *value, *p, *q, *special, *line, debugid[80];
insn output_ins;
int i, rn_error, validid;
int32_t seg, offs;
/* here we parse our directives; this is not handled by the 'real'
* parser. */
directive = line;
- if ((i = getkw(&directive, &value))) {
+ i = getkw(&directive, &value);
+ if (i) {
switch (i) {
case 1: /* [SEGMENT n] */
seg = ofmt->section(value, pass2, &sb);
#endif
} /* exit from assemble_file (...) */
-static int getkw(int8_t **directive, int8_t **value)
+static int getkw(char **directive, char **value)
{
- int8_t *p, *q, *buf;
+ char *p, *q, *buf;
buf = *directive;
* @param severity the severity of the warning or error
* @param fmt the printf style format string
*/
-static void report_error_gnu(int severity, const int8_t *fmt, ...)
+static void report_error_gnu(int severity, const char *fmt, ...)
{
va_list ap;
if (severity & ERR_NOFILE)
fputs("nasm: ", error_file);
else {
- int8_t *currentfile = NULL;
+ char *currentfile = NULL;
int32_t lineno = 0;
src_get(&lineno, ¤tfile);
fprintf(error_file, "%s:%ld: ", currentfile, lineno);
* @param severity the severity of the warning or error
* @param fmt the printf style format string
*/
-static void report_error_vc(int severity, const int8_t *fmt, ...)
+static void report_error_vc(int severity, const char *fmt, ...)
{
va_list ap;
if (severity & ERR_NOFILE)
fputs("nasm: ", error_file);
else {
- int8_t *currentfile = NULL;
+ char *currentfile = NULL;
int32_t lineno = 0;
src_get(&lineno, ¤tfile);
fprintf(error_file, "%s(%ld) : ", currentfile, lineno);
* @param severity the severity of the warning or error
* @param fmt the printf style format string
*/
-static void report_error_common(int severity, const int8_t *fmt,
+static void report_error_common(int severity, const char *fmt,
va_list args)
{
switch (severity & ERR_MASK) {
static ListGen *no_pp_list;
static int32_t no_pp_lineinc;
-static void no_pp_reset(int8_t *file, int pass, efunc error, evalfunc eval,
+static void no_pp_reset(char *file, int pass, efunc error, evalfunc eval,
ListGen * listgen)
{
src_set_fname(nasm_strdup(file));
(void)eval; /* placate compilers */
}
-static int8_t *no_pp_getline(void)
+static char *no_pp_getline(void)
{
- int8_t *buffer, *p, *q;
+ char *buffer, *p, *q;
int bufsize;
bufsize = BUF_DELTA;
if (!strncmp(buffer, "%line", 5)) {
int32_t ln;
int li;
- int8_t *nm = nasm_malloc(strlen(buffer));
+ char *nm = nasm_malloc(strlen(buffer));
if (sscanf(buffer + 5, "%ld+%d %s", &ln, &li, nm) == 3) {
nasm_free(src_set_fname(nm));
src_set_linnum(ln);
fclose(no_pp_fp);
}
-static uint32_t get_cpu(int8_t *value)
+static uint32_t get_cpu(char *value)
{
if (!strcmp(value, "8086"))
return IF_PLEVEL; /* the maximum level */
}
-static int get_bits(int8_t *value)
+static int get_bits(char *value)
{
int i;
#define NASM_NASM_H
#include <stdio.h>
+#include <inttypes.h>
#include "version.h" /* generated NASM version macros */
#ifndef NULL
/*
* An error reporting function should look like this.
*/
-typedef void (*efunc) (int severity, const int8_t *fmt, ...);
+typedef void (*efunc) (int severity, const char *fmt, ...);
/*
* These are the error severity codes which get passed as the first
/*
* A label-lookup function should look like this.
*/
-typedef int (*lfunc) (int8_t *label, int32_t *segment, int32_t *offset);
+typedef int (*lfunc) (char *label, int32_t *segment, int32_t *offset);
/*
* And a label-definition function like this. The boolean parameter
* should affect the local-label system), or something odder like
* an EQU or a segment-base symbol, which shouldn't.
*/
-typedef void (*ldfunc) (int8_t *label, int32_t segment, int32_t offset,
- int8_t *special, int is_norm, int isextrn,
+typedef void (*ldfunc) (char *label, int32_t segment, int32_t offset,
+ char *special, int is_norm, int isextrn,
struct ofmt * ofmt, efunc error);
/*
/*
* Called to initialize the listing file generator. Before this
* is called, the other routines will silently do nothing when
- * called. The `int8_t *' parameter is the file name to write the
+ * called. The `char *' parameter is the file name to write the
* listing to.
*/
- void (*init) (int8_t *, efunc);
+ void (*init) (char *, efunc);
/*
* Called to clear stuff up and close the listing file.
* whether the line came directly from an input file or is the
* result of a multi-line macro expansion.
*/
- void (*line) (int, int8_t *);
+ void (*line) (int, char *);
/*
* Called to change one of the various levelled mechanisms in
struct tokenval {
int t_type;
int64_t t_integer, t_inttwo;
- int8_t *t_charptr;
+ char *t_charptr;
};
typedef int (*scanner) (void *private_data, struct tokenval * tv);
* of the pass, an error reporting function, an evaluator
* function, and a listing generator to talk to.
*/
- void (*reset) (int8_t *, int, efunc, evalfunc, ListGen *);
+ void (*reset) (char *, int, efunc, evalfunc, ListGen *);
/*
* Called to fetch a line of preprocessed source. The line
* returned has been malloc'ed, and so should be freed after
* use.
*/
- int8_t *(*getline) (void);
+ char *(*getline) (void);
/*
* Called at the end of a pass.
typedef struct extop { /* extended operand */
struct extop *next; /* linked list */
int32_t type; /* defined above */
- int8_t *stringval; /* if it's a string, then here it is */
+ char *stringval; /* if it's a string, then here it is */
int stringlen; /* ... and here's how long it is */
int32_t segment; /* if it's a number/address, then... */
int64_t offset; /* ... it's given here ... */
#define MAXPREFIX 4
typedef struct { /* an instruction itself */
- int8_t *label; /* the label defined, or NULL */
+ char *label; /* the label defined, or NULL */
int prefixes[MAXPREFIX]; /* instruction prefixes, if any */
int nprefix; /* number of entries in above */
int opcode; /* the opcode - not just the string */
* This is a short (one-liner) description of the type of
* output generated by the driver.
*/
- const int8_t *fullname;
+ const char *fullname;
/*
* This is a single keyword used to select the driver.
*/
- const int8_t *shortname;
+ const char *shortname;
/*
* It is set to NULL in all the out modules and is not implemented
* in the main program
*/
- const int8_t *helpstring;
+ const char *helpstring;
/*
* this is a pointer to the first element of the debug information
struct dfmt *current_dfmt;
/*
- * This, if non-NULL, is a NULL-terminated list of `int8_t *'s
+ * This, if non-NULL, is a NULL-terminated list of `char *'s
* pointing to extra standard macros supplied by the object
* format (e.g. a sensible initial default value of __SECT__,
* and user-level equivalents for any format-specific
* directives).
*/
- const int8_t **stdmac;
+ const char **stdmac;
/*
* This procedure is called at the start of an output session.
* and the second parameter gives the value. This function returns
* 1 if recognized, 0 if unrecognized
*/
- int (*setinfo) (enum geninfo type, int8_t **string);
+ int (*setinfo) (enum geninfo type, char **string);
/*
* This procedure is called by assemble() to write actual
* been an EXTERN, a COMMON or a GLOBAL. The distinction should
* be obvious to the output format from the other parameters.
*/
- void (*symdef) (int8_t *name, int32_t segment, int32_t offset, int is_global,
- int8_t *special);
+ void (*symdef) (char *name, int32_t segment, int32_t offset, int is_global,
+ char *special);
/*
* This procedure is called when the source code requests a
* the segment, by setting `*bits' to 16 or 32. Or, if it
* doesn't wish to define a default, it can leave `bits' alone.
*/
- int32_t (*section) (int8_t *name, int pass, int *bits);
+ int32_t (*section) (char *name, int pass, int *bits);
/*
* This procedure is called to modify the segment base values
* should also return non-zero if it correctly processes the
* directive.
*/
- int (*directive) (int8_t *directive, int8_t *value, int pass);
+ int (*directive) (char *directive, char *value, int pass);
/*
* This procedure is called before anything else - even before
* The parameter `outname' points to an area of storage
* guaranteed to be at least FILENAME_MAX in size.
*/
- void (*filename) (int8_t *inname, int8_t *outname, efunc error);
+ void (*filename) (char *inname, char *outname, efunc error);
/*
* This procedure is called after assembly finishes, to allow
* This is a short (one-liner) description of the type of
* output generated by the driver.
*/
- const int8_t *fullname;
+ const char *fullname;
/*
* This is a single keyword used to select the driver.
*/
- const int8_t *shortname;
+ const char *shortname;
/*
* init - called initially to set up local pointer to object format,
* linenum - called any time there is output with a change of
* line number or file.
*/
- void (*linenum) (const int8_t *filename, int32_t linenumber, int32_t segto);
+ void (*linenum) (const char *filename, int32_t linenumber, int32_t segto);
/*
* debug_deflabel - called whenever a label is defined. Parameters
* would be called before the output format version.
*/
- void (*debug_deflabel) (int8_t *name, int32_t segment, int32_t offset,
- int is_global, int8_t *special);
+ void (*debug_deflabel) (char *name, int32_t segment, int32_t offset,
+ int is_global, char *special);
/*
* debug_directive - called whenever a DEBUG directive other than 'LINE'
* is encountered. 'directive' contains the first parameter to the
* function with 'directive' equal to "VAR" and 'params' equal to
* "_somevar:int".
*/
- void (*debug_directive) (const int8_t *directive, const int8_t *params);
+ void (*debug_directive) (const char *directive, const char *params);
/*
* typevalue - called whenever the assembler wishes to register a type
}
#ifdef LOGALLOC
-void *nasm_malloc_log(int8_t *file, int line, size_t size)
+void *nasm_malloc_log(char *file, int line, size_t size)
#else
void *nasm_malloc(size_t size)
#endif
}
#ifdef LOGALLOC
-void *nasm_realloc_log(int8_t *file, int line, void *q, size_t size)
+void *nasm_realloc_log(char *file, int line, void *q, size_t size)
#else
void *nasm_realloc(void *q, size_t size)
#endif
}
#ifdef LOGALLOC
-void nasm_free_log(int8_t *file, int line, void *q)
+void nasm_free_log(char *file, int line, void *q)
#else
void nasm_free(void *q)
#endif
}
#ifdef LOGALLOC
-int8_t *nasm_strdup_log(int8_t *file, int line, const int8_t *s)
+char *nasm_strdup_log(char *file, int line, const char *s)
#else
-int8_t *nasm_strdup(const int8_t *s)
+char *nasm_strdup(const char *s)
#endif
{
- int8_t *p;
+ char *p;
int size = strlen(s) + 1;
p = malloc(size);
}
#ifdef LOGALLOC
-int8_t *nasm_strndup_log(int8_t *file, int line, int8_t *s, size_t len)
+char *nasm_strndup_log(char *file, int line, char *s, size_t len)
#else
-int8_t *nasm_strndup(int8_t *s, size_t len)
+char *nasm_strndup(char *s, size_t len)
#endif
{
- int8_t *p;
+ char *p;
int size = len + 1;
p = malloc(size);
}
#if !defined(stricmp) && !defined(strcasecmp)
-int nasm_stricmp(const int8_t *s1, const int8_t *s2)
+int nasm_stricmp(const char *s1, const char *s2)
{
while (*s1 && tolower(*s1) == tolower(*s2))
s1++, s2++;
#endif
#if !defined(strnicmp) && !defined(strncasecmp)
-int nasm_strnicmp(const int8_t *s1, const int8_t *s2, int n)
+int nasm_strnicmp(const char *s1, const char *s2, int n)
{
while (n > 0 && *s1 && tolower(*s1) == tolower(*s2))
s1++, s2++, n--;
#define lib_isnumchar(c) ( isalnum(c) || (c) == '$')
#define numvalue(c) ((c)>='a' ? (c)-'a'+10 : (c)>='A' ? (c)-'A'+10 : (c)-'0')
-int64_t readnum(int8_t *str, int *error)
+int64_t readnum(char *str, int *error)
{
- int8_t *r = str, *q;
+ char *r = str, *q;
int32_t radix;
uint64_t result, checklimit;
int digit, last;
return result * sign;
}
-int64_t readstrnum(int8_t *str, int length, int *warn)
+int64_t readstrnum(char *str, int length, int *warn)
{
int64_t charconst = 0;
int i;
fputc((int)((data >> 24) & 255), fp);
}
-void standard_extension(int8_t *inname, int8_t *outname, int8_t *extension,
+void standard_extension(char *inname, char *outname, char *extension,
efunc error)
{
- int8_t *p, *q;
+ char *p, *q;
if (*outname) /* file name already exists, */
return; /* so do nothing */
void saa_wbytes(struct SAA *s, const void *data, int32_t len)
{
- const int8_t *d = data;
+ const char *d = data;
while (len > 0) {
int32_t l = s->end->length - s->end->posn;
void saa_rnbytes(struct SAA *s, void *data, int32_t len)
{
- int8_t *d = data;
+ char *d = data;
while (len > 0) {
int32_t l;
{
struct SAA *p;
int64_t pos;
- int8_t *cdata = data;
+ char *cdata = data;
if (!s->rptr || posn < s->rptr->start)
saa_rewind(s);
{
struct SAA *p;
int64_t pos;
- int8_t *cdata = data;
+ char *cdata = data;
if (!s->rptr || posn < s->rptr->start)
saa_rewind(s);
void saa_fpwrite(struct SAA *s, FILE * fp)
{
- int8_t *data;
+ char *data;
int32_t len;
saa_rewind(s);
- while ((data = saa_rbytes(s, &len)))
+// while ((data = saa_rbytes(s, &len)))
+ for (; (data = saa_rbytes(s, &len));)
fwrite(data, 1, len, fp);
}
* by the scanner.
*/
#include "names.c"
-static const int8_t *special_names[] = {
+static const char *special_names[] = {
"byte", "dword", "far", "long", "near", "nosplit", "qword",
"short", "strict", "to", "tword", "word"
};
-static const int8_t *prefix_names[] = {
+static const char *prefix_names[] = {
"a16", "a32", "lock", "o16", "o32", "rep", "repe", "repne",
"repnz", "repz", "times"
};
* formats. It keeps a succession of temporary-storage strings in
* stdscan_tempstorage, which can be cleared using stdscan_reset.
*/
-static int8_t **stdscan_tempstorage = NULL;
+static char **stdscan_tempstorage = NULL;
static int stdscan_tempsize = 0, stdscan_templen = 0;
#define STDSCAN_TEMP_DELTA 256
nasm_free(stdscan_tempstorage);
}
-static int8_t *stdscan_copy(int8_t *p, int len)
+static char *stdscan_copy(char *p, int len)
{
- int8_t *text;
+ char *text;
text = nasm_malloc(len + 1);
strncpy(text, p, len);
stdscan_tempsize += STDSCAN_TEMP_DELTA;
stdscan_tempstorage = nasm_realloc(stdscan_tempstorage,
stdscan_tempsize *
- sizeof(int8_t *));
+ sizeof(char *));
}
stdscan_tempstorage[stdscan_templen++] = text;
return text;
}
-int8_t *stdscan_bufptr = NULL;
+char *stdscan_bufptr = NULL;
int stdscan(void *private_data, struct tokenval *tv)
{
- int8_t ourcopy[MAX_KEYWORD + 1], *r, *s;
+ char ourcopy[MAX_KEYWORD + 1], *r, *s;
(void)private_data; /* Don't warn that this parameter is unused */
}
for (i = 0; i < elements(icn); i++)
if (!strncmp(ourcopy, icn[i], strlen(icn[i]))) {
- int8_t *p = ourcopy + strlen(icn[i]);
+ char *p = ourcopy + strlen(icn[i]);
tv->t_integer = ico[i];
if ((tv->t_inttwo = bsi(p, conditions,
elements(conditions))) >= 0)
tv->t_charptr = NULL;
return tv->t_type = TOKEN_NUM;
} else if (*stdscan_bufptr == '\'' || *stdscan_bufptr == '"') { /* a char constant */
- int8_t quote = *stdscan_bufptr++, *r;
+ char quote = *stdscan_bufptr++, *r;
int rn_warn;
r = tv->t_charptr = stdscan_bufptr;
while (*stdscan_bufptr && *stdscan_bufptr != quote)
/*
* Binary search.
*/
-int bsi(int8_t *string, const int8_t **array, int size)
+int bsi(char *string, const char **array, int size)
{
int i = -1, j = size; /* always, i < index < j */
while (j - i >= 2) {
return -1; /* we haven't got it :( */
}
-static int8_t *file_name = NULL;
+static char *file_name = NULL;
static int32_t line_number = 0;
-int8_t *src_set_fname(int8_t *newname)
+char *src_set_fname(char *newname)
{
- int8_t *oldname = file_name;
+ char *oldname = file_name;
file_name = newname;
return oldname;
}
return line_number;
}
-int src_get(int32_t *xline, int8_t **xname)
+int src_get(int32_t *xline, char **xname)
{
if (!file_name || !*xname || strcmp(*xname, file_name)) {
nasm_free(*xname);
return 0;
}
-void nasm_quote(int8_t **str)
+void nasm_quote(char **str)
{
int ln = strlen(*str);
- int8_t q = (*str)[0];
- int8_t *p;
+ char q = (*str)[0];
+ char *p;
if (ln > 1 && (*str)[ln - 1] == q && (q == '"' || q == '\''))
return;
q = '"';
*str = p;
}
-int8_t *nasm_strcat(int8_t *one, int8_t *two)
+char *nasm_strcat(char *one, char *two)
{
- int8_t *rslt;
+ char *rslt;
int l1 = strlen(one);
rslt = nasm_malloc(l1 + strlen(two) + 1);
strcpy(rslt, one);
void null_debug_init(struct ofmt *of, void *id, FILE * fp, efunc error)
{
}
-void null_debug_linenum(const int8_t *filename, int32_t linenumber, int32_t segto)
+void null_debug_linenum(const char *filename, int32_t linenumber, int32_t segto)
{
}
-void null_debug_deflabel(int8_t *name, int32_t segment, int32_t offset,
- int is_global, int8_t *special)
+void null_debug_deflabel(char *name, int32_t segment, int32_t offset,
+ int is_global, char *special)
{
}
-void null_debug_routine(const int8_t *directive, const int8_t *params)
+void null_debug_routine(const char *directive, const char *params)
{
}
void null_debug_typevalue(int32_t type)
void *nasm_malloc(size_t);
void *nasm_realloc(void *, size_t);
void nasm_free(void *);
-int8_t *nasm_strdup(const int8_t *);
-int8_t *nasm_strndup(int8_t *, size_t);
+char *nasm_strdup(const char *);
+char *nasm_strndup(char *, size_t);
#else
-void *nasm_malloc_log(int8_t *, int, size_t);
-void *nasm_realloc_log(int8_t *, int, void *, size_t);
-void nasm_free_log(int8_t *, int, void *);
-int8_t *nasm_strdup_log(int8_t *, int, const int8_t *);
-int8_t *nasm_strndup_log(int8_t *, int, int8_t *, size_t);
+void *nasm_malloc_log(char *, int, size_t);
+void *nasm_realloc_log(char *, int, void *, size_t);
+void nasm_free_log(char *, int, void *);
+char *nasm_strdup_log(char *, int, const char *);
+char *nasm_strndup_log(char *, int, char *, size_t);
#define nasm_malloc(x) nasm_malloc_log(__FILE__,__LINE__,x)
#define nasm_realloc(x,y) nasm_realloc_log(__FILE__,__LINE__,x,y)
#define nasm_free(x) nasm_free_log(__FILE__,__LINE__,x)
#define nasm_stricmp strcasecmp
#endif
#else
-int nasm_stricmp(const int8_t *, const int8_t *);
+int nasm_stricmp(const char *, const char *);
#endif
#if defined(strnicmp) || defined(strncasecmp)
#define nasm_strnicmp strncasecmp
#endif
#else
-int nasm_strnicmp(const int8_t *, const int8_t *, int);
+int nasm_strnicmp(const char *, const char *, int);
#endif
/*
* Convert a string into a number, using NASM number rules. Sets
* `*error' to TRUE if an error occurs, and FALSE otherwise.
*/
-int64_t readnum(int8_t *str, int *error);
+int64_t readnum(char *str, int *error);
/*
* Convert a character constant into a number. Sets
* str points to and length covers the middle of the string,
* without the quotes.
*/
-int64_t readstrnum(int8_t *str, int length, int *warn);
+int64_t readstrnum(char *str, int length, int *warn);
/*
* seg_init: Initialise the segment-number allocator.
* function to add an extension to the name of the input file
*/
#ifdef NASM_NASM_H
-void standard_extension(int8_t *inname, int8_t *outname, int8_t *extension,
+void standard_extension(char *inname, char *outname, char *extension,
efunc error);
#endif
*/
struct SAA *next, *end, *rptr;
int32_t elem_len, length, posn, start, rpos;
- int8_t *data;
+ char *data;
};
struct SAA *saa_init(int32_t elem_len); /* 1 == byte */
/*
* Standard scanner.
*/
-extern int8_t *stdscan_bufptr;
+extern char *stdscan_bufptr;
void stdscan_reset(void);
int stdscan(void *private_data, struct tokenval *tv);
#endif
* matching `string', or <0 if no match. `array' is taken to
* contain `size' elements.
*/
-int bsi(int8_t *string, const int8_t **array, int size);
+int bsi(char *string, const char **array, int size);
-int8_t *src_set_fname(int8_t *newname);
+char *src_set_fname(char *newname);
int32_t src_set_linnum(int32_t newline);
int32_t src_get_linnum(void);
/*
* It return 0 if the information was the same as the last time you
* checked, -1 if the name changed and (new-old) if just the line changed.
*/
-int src_get(int32_t *xline, int8_t **xname);
+int src_get(int32_t *xline, char **xname);
-void nasm_quote(int8_t **str);
-int8_t *nasm_strcat(int8_t *one, int8_t *two);
+void nasm_quote(char **str);
+char *nasm_strcat(char *one, char *two);
void nasmlib_cleanup(void);
-void null_debug_routine(const int8_t *directive, const int8_t *params);
+void null_debug_routine(const char *directive, const char *params);
extern struct dfmt null_debug_form;
extern struct dfmt *null_debug_arr[2];
#define BPL 8 /* bytes per line of hex dump */
-static const int8_t *help =
+static const char *help =
"usage: ndisasm [-a] [-i] [-h] [-r] [-u] [-b bits] [-o origin] [-s sync...]\n"
" [-e bytes] [-k start,bytes] [-p vendor] file\n"
" -a or -i activates auto (intelligent) sync\n"
" -k avoids disassembling <bytes> bytes from position <start>\n"
" -p selects the preferred vendor instruction set (intel, amd, cyrix, idt)\n";
-static void output_ins(uint32_t, uint8_t *, int, int8_t *);
+static void output_ins(uint32_t, uint8_t *, int, char *);
static void skip(uint32_t dist, FILE * fp);
int main(int argc, char **argv)
{
uint8_t buffer[INSN_MAX * 2], *p, *q;
- int8_t outbuf[256];
- int8_t *pname = *argv;
- int8_t *filename = NULL;
+ char outbuf[256];
+ char *pname = *argv;
+ char *filename = NULL;
uint32_t nextsync, synclen, initskip = 0L;
int lenread;
int32_t lendis;
init_sync();
while (--argc) {
- int8_t *v, *vv, *p = *++argv;
+ char *v, *vv, *p = *++argv;
if (*p == '-' && p[1]) {
p++;
while (*p)
}
static void output_ins(uint32_t offset, uint8_t *data,
- int datalen, int8_t *insn)
+ int datalen, char *insn)
{
int bytes;
fprintf(stdout, "%08lX ", offset);
*/
static void skip(uint32_t dist, FILE * fp)
{
- int8_t buffer[256]; /* should fit on most stacks :-) */
+ char buffer[256]; /* should fit on most stacks :-) */
/*
* Got to be careful with fseek: at least one fseek I've tried
static int ndrivers = 0;
-struct ofmt *ofmt_find(int8_t *name)
+struct ofmt *ofmt_find(char *name)
{ /* find driver */
int i;
return NULL;
}
-struct dfmt *dfmt_find(struct ofmt *ofmt, int8_t *name)
+struct dfmt *dfmt_find(struct ofmt *ofmt, char *name)
{ /* find driver */
struct dfmt **dfmt = ofmt->debug_formats;
while (*dfmt) {
#endif /* BUILD_DRIVERS_ARRAY */
-struct ofmt *ofmt_find(int8_t *);
-struct dfmt *dfmt_find(struct ofmt *, int8_t *);
+struct ofmt *ofmt_find(char *);
+struct dfmt *dfmt_find(struct ofmt *, char *);
void ofmt_list(struct ofmt *, FILE *);
void dfmt_list(struct ofmt *ofmt, FILE * fp);
struct ofmt *ofmt_register(efunc error);
int32_t segment; /* back-reference used by gsym_reloc */
struct Symbol *next; /* list of globals in each section */
struct Symbol *nextfwd; /* list of unresolved-size symbols */
- int8_t *name; /* for unresolved-size symbols */
+ char *name; /* for unresolved-size symbols */
int32_t symnum; /* index into symbol table */
};
saa_free(strs);
}
-static int32_t aout_section_names(int8_t *name, int pass, int *bits)
+static int32_t aout_section_names(char *name, int pass, int *bits)
{
/*
* Default to 32 bits.
return NO_SEG;
}
-static void aout_deflabel(int8_t *name, int32_t segment, int32_t offset,
- int is_global, int8_t *special)
+static void aout_deflabel(char *name, int32_t segment, int32_t offset,
+ int is_global, char *special)
{
int pos = strslen + 4;
struct Symbol *sym;
if (!strcmp((*s)->name, name)) {
struct tokenval tokval;
expr *e;
- int8_t *p = special;
+ char *p = special;
while (*p && !isspace(*p))
p++;
struct tokenval tokval;
expr *e;
int fwd = FALSE;
- int8_t *saveme = stdscan_bufptr; /* bugfix? fbk 8/10/00 */
+ char *saveme = stdscan_bufptr; /* bugfix? fbk 8/10/00 */
if (!bsd) {
error(ERR_NONFATAL, "Linux a.out does not support"
return segment;
}
-static int aout_directive(int8_t *directive, int8_t *value, int pass)
+static int aout_directive(char *directive, char *value, int pass)
{
return 0;
}
-static void aout_filename(int8_t *inname, int8_t *outname, efunc error)
+static void aout_filename(char *inname, char *outname, efunc error)
{
standard_extension(inname, outname, ".o", error);
}
-static const int8_t *aout_stdmac[] = {
+static const char *aout_stdmac[] = {
"%define __SECT__ [section .text]",
"%macro __NASM_CDecl__ 1",
"%endmacro",
NULL
};
-static int aout_set_info(enum geninfo type, int8_t **val)
+static int aout_set_info(enum geninfo type, char **val)
{
return 0;
}
struct Piece *head, *last, **tail;
};
-static int8_t as86_module[FILENAME_MAX];
+static char as86_module[FILENAME_MAX];
static struct Section stext, sdata;
static uint32_t bsslen;
static void as86_write(void);
static void as86_write_section(struct Section *, int);
-static int as86_add_string(int8_t *name);
+static int as86_add_string(char *name);
static void as86_sect_write(struct Section *, const uint8_t *,
uint32_t);
saa_free(strs);
}
-static int32_t as86_section_names(int8_t *name, int pass, int *bits)
+static int32_t as86_section_names(char *name, int pass, int *bits)
{
/*
* Default is 16 bits.
return NO_SEG;
}
-static int as86_add_string(int8_t *name)
+static int as86_add_string(char *name)
{
int pos = strslen;
int length = strlen(name);
return pos;
}
-static void as86_deflabel(int8_t *name, int32_t segment, int32_t offset,
- int is_global, int8_t *special)
+static void as86_deflabel(char *name, int32_t segment, int32_t offset,
+ int is_global, char *special)
{
struct Symbol *sym;
*/
length = p->bytes;
do {
- int8_t buf[64];
+ char buf[64];
int32_t tmplen = (length > 64 ? 64 : length);
fputc(0x40 | (tmplen & 0x3F), as86fp);
saa_rnbytes(sect->data, buf, tmplen);
return segment;
}
-static int as86_directive(int8_t *directive, int8_t *value, int pass)
+static int as86_directive(char *directive, char *value, int pass)
{
return 0;
}
-static void as86_filename(int8_t *inname, int8_t *outname, efunc error)
+static void as86_filename(char *inname, char *outname, efunc error)
{
- int8_t *p;
+ char *p;
if ((p = strrchr(inname, '.')) != NULL) {
strncpy(as86_module, inname, p - inname);
standard_extension(inname, outname, ".o", error);
}
-static const int8_t *as86_stdmac[] = {
+static const char *as86_stdmac[] = {
"%define __SECT__ [section .text]",
"%macro __NASM_CDecl__ 1",
"%endmacro",
NULL
};
-static int as86_set_info(enum geninfo type, int8_t **val)
+static int as86_set_info(enum geninfo type, char **val)
{
return 0;
}
-void as86_linenumber(int8_t *name, int32_t segment, int32_t offset, int is_main,
+void as86_linenumber(char *name, int32_t segment, int32_t offset, int is_main,
int lineno)
{
}
/* This struct is used to keep track of symbols for map-file generation. */
static struct bin_label {
- int8_t *name;
+ char *name;
struct bin_label *next;
} *no_seg_labels, **nsl_tail;
static struct Section {
- int8_t *name;
+ char *name;
struct SAA *contents;
int32_t length; /* section length in bytes */
uint32_t valign; /* notional section alignment */
uint32_t start; /* section start address */
uint32_t vstart; /* section virtual start address */
- int8_t *follows; /* the section that this one will follow */
- int8_t *vfollows; /* the section that this one will notionally follow */
+ char *follows; /* the section that this one will follow */
+ char *vfollows; /* the section that this one will notionally follow */
int32_t start_index; /* NASM section id for non-relocated version */
int32_t vstart_index; /* the NASM section id */
struct Section *target;
} *relocs, **reloctail;
-extern int8_t *stdscan_bufptr;
-extern int lookup_label(int8_t *label, int32_t *segment, int32_t *offset);
+extern char *stdscan_bufptr;
+extern int lookup_label(char *label, int32_t *segment, int32_t *offset);
static uint8_t format_mode; /* 0 = original bin, 1 = extended bin */
static int32_t current_section; /* only really needed if format_mode = 0 */
#define MAP_SECTIONS 4
#define MAP_SYMBOLS 8
static int map_control = 0;
-static int8_t *infile, *outfile;
+static char *infile, *outfile;
-static const int8_t *bin_stdmac[] = {
+static const char *bin_stdmac[] = {
"%define __SECT__ [section .text]",
"%imacro org 1+.nolist",
"[org %1]",
r->target = s;
}
-static struct Section *find_section_by_name(const int8_t *name)
+static struct Section *find_section_by_name(const char *name)
{
struct Section *s;
return s;
}
-static struct Section *create_section(int8_t *name)
+static struct Section *create_section(char *name)
{ /* Create a new section. */
last_section->next = nasm_malloc(sizeof(struct Section));
last_section->next->ifollows = last_section;
/* Step 7: Generate the map file. */
if (map_control) {
- const int8_t *not_defined = { "not defined" };
+ const char *not_defined = { "not defined" };
/* Display input and output file names. */
fprintf(rf, "\n- NASM Map file ");
}
}
-static void bin_deflabel(int8_t *name, int32_t segment, int32_t offset,
- int is_global, int8_t *special)
+static void bin_deflabel(char *name, int32_t segment, int32_t offset,
+ int is_global, char *special)
{
(void)segment; /* Don't warn that this parameter is unused */
(void)offset; /* Don't warn that this parameter is unused */
ATTRIB_NOBITS, ATTRIB_PROGBITS
};
-static int bin_read_attribute(int8_t **line, int *attribute,
+static int bin_read_attribute(char **line, int *attribute,
uint32_t *value)
{
expr *e;
int attrib_name_size;
struct tokenval tokval;
- int8_t *exp;
+ char *exp;
/* Skip whitespace. */
while (**line && isspace(**line))
(*line)++;
}
} else {
- int8_t c;
+ char c;
int pcount = 1;
/* Full expression (delimited by parenthesis) */
return 1;
}
-static void bin_assign_attributes(struct Section *sec, int8_t *astring)
+static void bin_assign_attributes(struct Section *sec, char *astring)
{
int attribute, check;
uint32_t value;
- int8_t *p;
+ char *p;
while (1) { /* Get the next attribute. */
check = bin_read_attribute(&astring, &attribute, &value);
{
static int labels_defined = 0;
struct Section *sec;
- int8_t *label_name;
+ char *label_name;
size_t base_len;
if (labels_defined)
labels_defined = 1;
}
-static int32_t bin_secname(int8_t *name, int pass, int *bits)
+static int32_t bin_secname(char *name, int pass, int *bits)
{
- int8_t *p;
+ char *p;
struct Section *sec;
/* bin_secname is called with *name = NULL at the start of each
return current_section;
}
-static int bin_directive(int8_t *directive, int8_t *args, int pass)
+static int bin_directive(char *directive, char *args, int pass)
{
/* Handle ORG directive */
if (!nasm_stricmp(directive, "org")) {
/* The 'map' directive allows the user to generate section
* and symbol information to stdout, stderr, or to a file. */
else if (format_mode && !nasm_stricmp(directive, "map")) {
- int8_t *p;
+ char *p;
if (pass != 1)
return 1;
return 0;
}
-static void bin_filename(int8_t *inname, int8_t *outname, efunc error)
+static void bin_filename(char *inname, char *outname, efunc error)
{
standard_extension(inname, outname, "", error);
infile = inname;
return segment;
}
-static int bin_set_info(enum geninfo type, int8_t **val)
+static int bin_set_info(enum geninfo type, char **val)
{
return 0;
}
};
struct Symbol {
- int8_t name[9];
+ char name[9];
int32_t strpos; /* string table position of name */
int section; /* section number where it's defined
* - in COFF codes, not NASM codes */
static FILE *coffp;
static efunc error;
-static int8_t coff_infile[FILENAME_MAX];
+static char coff_infile[FILENAME_MAX];
struct Section {
struct SAA *data;
int32_t index;
struct Reloc *head, **tail;
uint32_t flags; /* section flags */
- int8_t name[9];
+ char name[9];
int32_t pos, relpos;
};
static void coff_sect_write(struct Section *, const uint8_t *,
uint32_t);
static void coff_write(void);
-static void coff_section_header(int8_t *, int32_t, int32_t, int32_t, int32_t, int, int32_t);
+static void coff_section_header(char *, int32_t, int32_t, int32_t, int32_t, int, int32_t);
static void coff_write_relocs(struct Section *);
static void coff_write_symbols(void);
saa_free(strs);
}
-static int coff_make_section(int8_t *name, uint32_t flags)
+static int coff_make_section(char *name, uint32_t flags)
{
struct Section *s;
return nsects - 1;
}
-static int32_t coff_section_names(int8_t *name, int pass, int *bits)
+static int32_t coff_section_names(char *name, int pass, int *bits)
{
- int8_t *p;
+ char *p;
uint32_t flags, align_and = ~0L, align_or = 0L;
int i;
while (*p && isspace(*p))
p++;
while (*p) {
- int8_t *q = p;
+ char *q = p;
while (*p && !isspace(*p))
p++;
if (*p)
return sects[i]->index;
}
-static void coff_deflabel(int8_t *name, int32_t segment, int32_t offset,
- int is_global, int8_t *special)
+static void coff_deflabel(char *name, int32_t segment, int32_t offset,
+ int is_global, char *special)
{
int pos = strslen + 4;
struct Symbol *sym;
typedef struct tagString {
struct tagString *Next;
int len;
- int8_t *String;
+ char *String;
} STRING;
#define EXPORT_SECTION_NAME ".drectve"
static STRING *Exports = NULL;
static struct Section *directive_sec;
-void AddExport(int8_t *name)
+void AddExport(char *name)
{
STRING *rvp = Exports, *newS;
newS = (STRING *) nasm_malloc(sizeof(STRING));
newS->len = strlen(name);
newS->Next = NULL;
- newS->String = (int8_t *)nasm_malloc(newS->len + 1);
+ newS->String = (char *)nasm_malloc(newS->len + 1);
strcpy(newS->String, name);
if (rvp == NULL) {
int i;
if (rvp == NULL)
return;
while (rvp) {
- len = sprintf((int8_t *)buf, "-export:%s ", rvp->String);
+ len = sprintf((char *)buf, "-export:%s ", rvp->String);
coff_sect_write(directive_sec, buf, len);
rvp = rvp->Next;
}
Exports = NULL;
}
-static int coff_directives(int8_t *directive, int8_t *value, int pass)
+static int coff_directives(char *directive, char *value, int pass)
{
if (!strcmp(directive, "export")) {
- int8_t *q, *name;
+ char *q, *name;
if (pass == 2)
return 1; /* ignore in pass two */
saa_fpwrite(strs, coffp);
}
-static void coff_section_header(int8_t *name, int32_t vsize,
+static void coff_section_header(char *name, int32_t vsize,
int32_t datalen, int32_t datapos,
int32_t relpos, int nrelocs, int32_t flags)
{
- int8_t padname[8];
+ char padname[8];
memset(padname, 0, 8);
strncpy(padname, name, 8);
}
}
-static void coff_symbol(int8_t *name, int32_t strpos, int32_t value,
+static void coff_symbol(char *name, int32_t strpos, int32_t value,
int section, int type, int aux)
{
- int8_t padname[8];
+ char padname[8];
if (name) {
memset(padname, 0, 8);
static void coff_write_symbols(void)
{
- int8_t filename[18];
+ char filename[18];
uint32_t i;
/*
return segment;
}
-static void coff_std_filename(int8_t *inname, int8_t *outname, efunc error)
+static void coff_std_filename(char *inname, char *outname, efunc error)
{
strcpy(coff_infile, inname);
standard_extension(inname, outname, ".o", error);
}
-static void coff_win32_filename(int8_t *inname, int8_t *outname, efunc error)
+static void coff_win32_filename(char *inname, char *outname, efunc error)
{
strcpy(coff_infile, inname);
standard_extension(inname, outname, ".obj", error);
}
-static const int8_t *coff_stdmac[] = {
+static const char *coff_stdmac[] = {
"%define __SECT__ [section .text]",
"%macro __NASM_CDecl__ 1",
"%endmacro",
NULL
};
-static int coff_set_info(enum geninfo type, int8_t **val)
+static int coff_set_info(enum geninfo type, char **val)
{
return 0;
}
struct Section {
struct Section *next;
int32_t number;
- int8_t *name;
+ char *name;
} *dbgsect;
FILE *dbgf;
fclose(dbgf);
}
-static int32_t dbg_section_names(int8_t *name, int pass, int *bits)
+static int32_t dbg_section_names(char *name, int pass, int *bits)
{
int seg;
seg = seg_alloc());
else {
int n = strcspn(name, " \t");
- int8_t *sname = nasm_strndup(name, n);
+ char *sname = nasm_strndup(name, n);
struct Section *s;
seg = NO_SEG;
return seg;
}
-static void dbg_deflabel(int8_t *name, int32_t segment, int32_t offset,
- int is_global, int8_t *special)
+static void dbg_deflabel(char *name, int32_t segment, int32_t offset,
+ int is_global, char *special)
{
fprintf(dbgf, "deflabel %s := %08lx:%08lx %s (%d)%s%s\n",
name, segment, offset,
fprintf(dbgf, "raw data = ");
while (realbytes--) {
id = *(uint8_t *)data;
- data = (int8_t *)data + 1;
+ data = (char *)data + 1;
fprintf(dbgf, "%02x ", id);
}
fprintf(dbgf, "\n");
case OUT_ADDRESS:
ldata = 0; /* placate gcc */
if (realbytes == 1)
- ldata = *((int8_t *)data);
+ ldata = *((char *)data);
else if (realbytes == 2)
ldata = *((int16_t *)data);
else if (realbytes == 4)
return segment;
}
-static int dbg_directive(int8_t *directive, int8_t *value, int pass)
+static int dbg_directive(char *directive, char *value, int pass)
{
fprintf(dbgf, "directive [%s] value [%s] (pass %d)\n",
directive, value, pass);
return 1;
}
-static void dbg_filename(int8_t *inname, int8_t *outname, efunc error)
+static void dbg_filename(char *inname, char *outname, efunc error)
{
standard_extension(inname, outname, ".dbg", error);
}
-static int dbg_set_info(enum geninfo type, int8_t **val)
+static int dbg_set_info(enum geninfo type, char **val)
{
(void)type;
(void)val;
return 0;
}
-int8_t *types[] = {
+char *types[] = {
"unknown", "label", "byte", "word", "dword", "float", "qword", "tbyte"
};
void dbgdbg_init(struct ofmt *of, void *id, FILE * fp, efunc error)
{
}
-static void dbgdbg_linnum(const int8_t *lnfname, int32_t lineno, int32_t segto)
+static void dbgdbg_linnum(const char *lnfname, int32_t lineno, int32_t segto)
{
fprintf(dbgf, "dbglinenum %s(%ld) := %08lx\n", lnfname, lineno, segto);
}
-static void dbgdbg_deflabel(int8_t *name, int32_t segment,
- int32_t offset, int is_global, int8_t *special)
+static void dbgdbg_deflabel(char *name, int32_t segment,
+ int32_t offset, int is_global, char *special)
{
fprintf(dbgf, "dbglabel %s := %08lx:%08lx %s (%d)%s%s\n",
name,
is_global == 2 ? "common" : is_global ? "global" : "local",
is_global, special ? ": " : "", special);
}
-static void dbgdbg_define(const int8_t *type, const int8_t *params)
+static void dbgdbg_define(const char *type, const char *params)
{
fprintf(dbgf, "dbgdirective [%s] value [%s]\n", type, params);
}
int32_t globnum; /* symbol table offset if global */
struct Symbol *next; /* list of globals in each section */
struct Symbol *nextfwd; /* list of unresolved-size symbols */
- int8_t *name; /* used temporarily if in above list */
+ char *name; /* used temporarily if in above list */
};
#define SHT_PROGBITS 1
int type; /* SHT_PROGBITS or SHT_NOBITS */
int align; /* alignment: power of two */
uint32_t flags; /* section flags */
- int8_t *name;
+ char *name;
struct SAA *rel;
int32_t rellen;
struct Reloc *head, **tail;
static int nsects, sectlen;
#define SHSTR_DELTA 256
-static int8_t *shstrtab;
+static char *shstrtab;
static int shstrtablen, shstrtabsize;
static struct SAA *syms;
static struct Symbol *fwds;
-static int8_t elf_module[FILENAME_MAX];
+static char elf_module[FILENAME_MAX];
extern struct ofmt of_elf;
#define SEG_ALIGN 16 /* alignment of sections in file */
#define SEG_ALIGN_1 (SEG_ALIGN-1)
-static const int8_t align_str[SEG_ALIGN] = ""; /* ANSI will pad this with 0s */
+static const char align_str[SEG_ALIGN] = ""; /* ANSI will pad this with 0s */
#define ELF_MAX_SECTIONS 16 /* really 10, but let's play safe */
static struct ELF_SECTDATA {
static void elf_write_sections(void);
static struct SAA *elf_build_symtab(int32_t *, int32_t *);
static struct SAA *elf_build_reltab(int32_t *, struct Reloc *);
-static void add_sectname(int8_t *, int8_t *);
+static void add_sectname(char *, char *);
/* this stuff is needed for the stabs debugging format */
#define N_SO 0x64 /* ID for main source file */
struct symlininfo {
int offset;
int section; /* section index */
- int8_t *name; /* shallow-copied pointer of section name */
+ char *name; /* shallow-copied pointer of section name */
};
struct linelist {
struct symlininfo info;
int line;
- int8_t *filename;
+ char *filename;
struct linelist *next;
struct linelist *last;
};
static int stabs_immcall = 0;
static int currentline = 0;
static int numlinestabs = 0;
-static int8_t *stabs_filename = 0;
+static char *stabs_filename = 0;
static int symtabsection;
static uint8_t *stabbuf = 0, *stabstrbuf = 0, *stabrelbuf = 0;
static int stablen, stabstrlen, stabrellen;
static struct dfmt df_stabs;
void stabs_init(struct ofmt *, void *, FILE *, efunc);
-void stabs_linenum(const int8_t *filename, int32_t linenumber, int32_t);
-void stabs_deflabel(int8_t *, int32_t, int32_t, int, int8_t *);
-void stabs_directive(const int8_t *, const int8_t *);
+void stabs_linenum(const char *filename, int32_t linenumber, int32_t);
+void stabs_deflabel(char *, int32_t, int32_t, int, char *);
+void stabs_directive(const char *, const char *);
void stabs_typevalue(int32_t);
void stabs_output(int, void *);
void stabs_generate();
}
}
-static void add_sectname(int8_t *firsthalf, int8_t *secondhalf)
+static void add_sectname(char *firsthalf, char *secondhalf)
{
int len = strlen(firsthalf) + strlen(secondhalf);
while (shstrtablen + len + 1 > shstrtabsize)
shstrtablen += len + 1;
}
-static int elf_make_section(int8_t *name, int type, int flags, int align)
+static int elf_make_section(char *name, int type, int flags, int align)
{
struct Section *s;
return nsects - 1;
}
-static int32_t elf_section_names(int8_t *name, int pass, int *bits)
+static int32_t elf_section_names(char *name, int pass, int *bits)
{
- int8_t *p;
+ char *p;
int flags_and, flags_or, type, align, i;
/*
while (*p && isspace(*p))
p++;
while (*p) {
- int8_t *q = p;
+ char *q = p;
while (*p && !isspace(*p))
p++;
if (*p)
return sects[i]->index;
}
-static void elf_deflabel(int8_t *name, int32_t segment, int32_t offset,
- int is_global, int8_t *special)
+static void elf_deflabel(char *name, int32_t segment, int32_t offset,
+ int is_global, char *special)
{
int pos = strslen;
struct Symbol *sym;
if (!strcmp((*s)->name, name)) {
struct tokenval tokval;
expr *e;
- int8_t *p = special;
+ char *p = special;
while (*p && !isspace(*p))
p++;
struct tokenval tokval;
expr *e;
int fwd = FALSE;
- int8_t *saveme = stdscan_bufptr; /* bugfix? fbk 8/10/00 */
+ char *saveme = stdscan_bufptr; /* bugfix? fbk 8/10/00 */
while (special[n] && isspace(special[n]))
n++;
{
int nsections, align;
int scount;
- int8_t *p;
+ char *p;
int commlen;
- int8_t comment[64];
+ char comment[64];
int i;
struct SAA *symtab;
return segment;
}
-static int elf_directive(int8_t *directive, int8_t *value, int pass)
+static int elf_directive(char *directive, char *value, int pass)
{
return 0;
}
-static void elf_filename(int8_t *inname, int8_t *outname, efunc error)
+static void elf_filename(char *inname, char *outname, efunc error)
{
strcpy(elf_module, inname);
standard_extension(inname, outname, ".o", error);
}
-static const int8_t *elf_stdmac[] = {
+static const char *elf_stdmac[] = {
"%define __SECT__ [section .text]",
"%macro __NASM_CDecl__ 1",
"%define $_%1 $%1",
"%endmacro",
NULL
};
-static int elf_set_info(enum geninfo type, int8_t **val)
+static int elf_set_info(enum geninfo type, char **val)
{
return 0;
}
{
}
-void stabs_linenum(const int8_t *filename, int32_t linenumber, int32_t segto)
+void stabs_linenum(const char *filename, int32_t linenumber, int32_t segto)
{
if (!stabs_filename) {
- stabs_filename = (int8_t *)nasm_malloc(strlen(filename) + 1);
+ stabs_filename = (char *)nasm_malloc(strlen(filename) + 1);
strcpy(stabs_filename, filename);
} else {
if (strcmp(stabs_filename, filename)) {
/* why not nasm_free(stabs_filename); we're done with the old one */
- stabs_filename = (int8_t *)nasm_malloc(strlen(filename) + 1);
+ stabs_filename = (char *)nasm_malloc(strlen(filename) + 1);
strcpy(stabs_filename, filename);
}
}
currentline = linenumber;
}
-void stabs_deflabel(int8_t *name, int32_t segment, int32_t offset, int is_global,
- int8_t *special)
+void stabs_deflabel(char *name, int32_t segment, int32_t offset, int is_global,
+ char *special)
{
}
-void stabs_directive(const int8_t *directive, const int8_t *params)
+void stabs_directive(const char *directive, const char *params)
{
}
{
int i, numfiles, strsize, numstabs = 0, currfile, mainfileindex;
uint8_t *sbuf, *ssbuf, *rbuf, *sptr, *rptr;
- int8_t **allfiles;
+ char **allfiles;
int *fileidx;
struct linelist *ptr;
ptr = stabslines;
- allfiles = (int8_t **)nasm_malloc(numlinestabs * sizeof(int8_t *));
+ allfiles = (char **)nasm_malloc(numlinestabs * sizeof(char *));
for (i = 0; i < numlinestabs; i++)
allfiles[i] = 0;
numfiles = 0;
rptr = rbuf;
for (i = 0; i < numfiles; i++) {
- strcpy((int8_t *)ssbuf + fileidx[i], allfiles[i]);
+ strcpy((char *)ssbuf + fileidx[i], allfiles[i]);
}
ssbuf[0] = 0;
#define ARRAY_BOT 0x1
-static int8_t ieee_infile[FILENAME_MAX];
+static char ieee_infile[FILENAME_MAX];
static int ieee_uppercase;
static efunc error;
static struct FileName {
struct FileName *next;
- int8_t *name;
+ char *name;
int32_t index;
} *fnhead, **fntail;
static struct ieeePublic {
struct ieeePublic *next;
- int8_t *name;
+ char *name;
int32_t offset;
int32_t segment; /* only if it's far-absolute */
int32_t index;
static struct ieeeExternal {
struct ieeeExternal *next;
- int8_t *name;
+ char *name;
int32_t commonsize;
} *exthead, **exttail;
} combine;
int32_t use32; /* is this segment 32-bit? */
struct ieeePublic *pubhead, **pubtail, *lochead, **loctail;
- int8_t *name;
+ char *name;
} *seghead, **segtail, *ieee_seg_needs_update;
struct ieeeObjData {
static void ieee_write_fixup(int32_t, int32_t, struct ieeeSection *,
int, uint32_t, int32_t);
static void ieee_install_fixup(struct ieeeSection *, struct ieeeFixupp *);
-static int32_t ieee_segment(int8_t *, int, int *);
+static int32_t ieee_segment(char *, int, int *);
static void ieee_write_file(int debuginfo);
static void ieee_write_byte(struct ieeeSection *, int);
static void ieee_write_word(struct ieeeSection *, int);
static void ieee_write_dword(struct ieeeSection *, int32_t);
-static void ieee_putascii(int8_t *, ...);
+static void ieee_putascii(char *, ...);
static void ieee_putcs(int);
static int32_t ieee_putld(int32_t, int32_t, uint8_t *);
static int32_t ieee_putlr(struct ieeeFixupp *);
-static void ieee_unqualified_name(int8_t *, int8_t *);
+static void ieee_unqualified_name(char *, char *);
/*
* pup init
checksum = 0;
of_ieee.current_dfmt->init(&of_ieee, NULL, fp, errfunc);
}
-static int ieee_set_info(enum geninfo type, int8_t **val)
+static int ieee_set_info(enum geninfo type, char **val)
{
(void)type;
(void)val;
/*
* callback for labels
*/
-static void ieee_deflabel(int8_t *name, int32_t segment,
- int32_t offset, int is_global, int8_t *special)
+static void ieee_deflabel(char *name, int32_t segment,
+ int32_t offset, int is_global, char *special)
{
/*
* We have three cases:
/*
* segment registry
*/
-static int32_t ieee_segment(int8_t *name, int pass, int *bits)
+static int32_t ieee_segment(char *name, int pass, int *bits)
{
/*
* We call the label manager here to define a name for the new
} else {
struct ieeeSection *seg;
int ieee_idx, attrs, rn_error;
- int8_t *p;
+ char *p;
/*
* Look for segment attributes.
/*
* directives supported
*/
-static int ieee_directive(int8_t *directive, int8_t *value, int pass)
+static int ieee_directive(char *directive, char *value, int pass)
{
(void)value;
/*
* filename
*/
-static void ieee_filename(int8_t *inname, int8_t *outname, efunc error)
+static void ieee_filename(char *inname, char *outname, efunc error)
{
strcpy(ieee_infile, inname);
standard_extension(inname, outname, ".o", error);
struct ieeeObjData *data;
struct ieeeFixupp *fix;
struct Array *arr;
- static int8_t boast[] = "The Netwide Assembler " NASM_VER;
+ static char boast[] = "The Netwide Assembler " NASM_VER;
int i;
/*
if (!debuginfo && !strcmp(seg->name, "??LINE"))
seg = seg->next;
while (seg) {
- int8_t buf[256];
- int8_t attrib;
+ char buf[256];
+ char attrib;
switch (seg->combine) {
case CMB_PUBLIC:
default:
i = 1;
for (seg = seghead; seg; seg = seg->next) {
for (pub = seg->pubhead; pub; pub = pub->next) {
- int8_t buf[256];
+ char buf[256];
ieee_unqualified_name(buf, pub->name);
ieee_putascii("NI%X,%02X%s.\r\n", i, strlen(buf), buf);
if (pub->segment == -1)
pub = fpubhead;
i = 1;
while (pub) {
- int8_t buf[256];
+ char buf[256];
ieee_unqualified_name(buf, pub->name);
ieee_putascii("NI%X,%02X%s.\r\n", i, strlen(buf), buf);
if (pub->segment == -1)
ext = exthead;
i = 1;
while (ext) {
- int8_t buf[256];
+ char buf[256];
ieee_unqualified_name(buf, ext->name);
ieee_putascii("NX%X,%02X%s.\r\n", i++, strlen(buf), buf);
ext = ext->next;
i = 1;
for (seg = seghead; seg && debuginfo; seg = seg->next) {
for (loc = seg->lochead; loc; loc = loc->next) {
- int8_t buf[256];
+ char buf[256];
ieee_unqualified_name(buf, loc->name);
ieee_putascii("NN%X,%02X%s.\r\n", i, strlen(buf), buf);
if (loc->segment == -1)
ieee_write_byte(seg, (data >> 16) & 0xFF);
ieee_write_byte(seg, (data >> 24) & 0xFF);
}
-static void ieee_putascii(int8_t *format, ...)
+static void ieee_putascii(char *format, ...)
{
- int8_t buffer[256];
+ char buffer[256];
int i, l;
va_list ap;
* becomes an issue if real mode code is used. A pure 32-bit linker could
* get away without defining the virtual mode...
*/
- int8_t buf[40];
+ char buf[40];
int32_t size = p->size;
switch (p->ftype) {
case FT_SEG:
/* Dump all segment data (text and fixups )*/
-static void ieee_unqualified_name(int8_t *dest, int8_t *source)
+static void ieee_unqualified_name(char *dest, char *source)
{
if (ieee_uppercase) {
while (*source)
* so, we have to make sure the ??LINE segment is avaialbe
* as the first segment when this debug format is selected
*/
-static void dbgls_linnum(const int8_t *lnfname, int32_t lineno, int32_t segto)
+static void dbgls_linnum(const char *lnfname, int32_t lineno, int32_t segto)
{
struct FileName *fn;
struct ieeeSection *seg;
seg->currentpos);
}
-static void dbgls_deflabel(int8_t *name, int32_t segment,
- int32_t offset, int is_global, int8_t *special)
+static void dbgls_deflabel(char *name, int32_t segment,
+ int32_t offset, int is_global, char *special)
{
struct ieeeSection *seg;
int used_special; /* have we used the special text? */
int align;
/* data that goes into the file */
- int8_t sectname[16]; /* what this section is called */
- int8_t segname[16]; /* segment this section will be in */
+ char sectname[16]; /* what this section is called */
+ char segname[16]; /* segment this section will be in */
uint32_t size; /* in-memory and -file size */
uint32_t nreloc; /* relocation entry count */
uint32_t flags; /* type and attributes (masked) */
static struct sectmap {
- const int8_t *nasmsect;
- const int8_t *segname;
- const int8_t *sectname;
+ const char *nasmsect;
+ const char *segname;
+ const char *sectname;
const int32_t flags;
} sectmap[] = { {
".text", "__TEXT", "__text", S_REGULAR|S_ATTR_SOME_INSTRUCTIONS}, {
struct symbol {
/* nasm internal data */
struct symbol *next; /* next symbol in the list */
- int8_t *name; /* name of this symbol */
+ char *name; /* name of this symbol */
int32_t initial_snum; /* symbol number used above in
reloc */
int32_t snum; /* true snum for reloc */
if (align != (align & -align)) {
return -1;
} else {
-#if __GNUC__ >= 4
+#ifdef __GNUC__
return (align ? __builtin_ctzl (align) : 0);
#else
uint32_t result = 0;
}
}
-static struct section *get_section_by_name(const int8_t *segname,
- const int8_t *sectname)
+static struct section *get_section_by_name(const char *segname,
+ const char *sectname)
{
struct section *s;
return s;
}
-static int32_t get_section_index_by_name(const int8_t *segname,
- const int8_t *sectname)
+static int32_t get_section_index_by_name(const char *segname,
+ const char *sectname)
{
struct section *s;
return -1;
}
-static int8_t *get_section_name_by_index(const int32_t index)
+static char *get_section_name_by_index(const int32_t index)
{
struct section *s;
static void macho_init(FILE * fp, efunc errfunc, ldfunc ldef,
evalfunc eval)
{
- int8_t zero = 0;
+ char zero = 0;
machofp = fp;
error = errfunc;
strs = saa_init(1L);
/* string table starts with a zero byte - don't ask why */
- saa_wbytes(strs, &zero, sizeof(int8_t));
+ saa_wbytes(strs, &zero, sizeof(char));
strslen = 1;
}
-static int macho_setinfo(enum geninfo type, int8_t **val)
+static int macho_setinfo(enum geninfo type, char **val)
{
return 0;
}
}
}
-static int32_t macho_section(int8_t *name, int pass, int *bits)
+static int32_t macho_section(char *name, int pass, int *bits)
{
int32_t index, originalIndex;
- int8_t *sectionAttributes;
+ char *sectionAttributes;
struct sectmap *sm;
struct section *s;
for (sm = sectmap; sm->nasmsect != NULL; ++sm) {
/* make lookup into section name translation table */
if (!strcmp(name, sm->nasmsect)) {
- int8_t *currentAttribute;
+ char *currentAttribute;
/* try to find section with that name */
originalIndex = index = get_section_index_by_name(sm->segname,
&& (currentAttribute = strtok((char*)§ionAttributes, " \t"))) {
if (0 != *currentAttribute) {
if (0 == strncasecmp("align=", currentAttribute, 6)) {
- int8_t *end;
+ char *end;
int newAlignment, value;
value = strtoul(currentAttribute + 6, (char**)&end, 0);
return NO_SEG;
}
-static void macho_symdef(int8_t *name, int32_t section, int32_t offset,
- int is_global, int8_t *special)
+static void macho_symdef(char *name, int32_t section, int32_t offset,
+ int is_global, char *special)
{
struct symbol *sym;
return section;
}
-static int macho_directive(int8_t *directive, int8_t *value, int pass)
+static int macho_directive(char *directive, char *value, int pass)
{
return 0;
}
-static void macho_filename(int8_t *inname, int8_t *outname, efunc error)
+static void macho_filename(char *inname, char *outname, efunc error)
{
standard_extension(inname, outname, ".o", error);
}
-static const int8_t *macho_stdmac[] = {
+static const char *macho_stdmac[] = {
"%define __SECT__ [section .text]",
"%macro __NASM_CDecl__ 1",
"%endmacro",
uint32_t i,j;
*numsyms = 0;
- *strtabsize = sizeof (int8_t);
+ *strtabsize = sizeof (char);
symp = &syms;
{
struct section *s, *s2;
struct reloc *r;
- int8_t *rel_paddata = "\0\0\0";
+ char *rel_paddata = "\0\0\0";
uint8_t fi, *p, *q, blk[4];
int32_t l;
** uint32_t command type == LC_SEGMENT
** uint32_t size of load command
** (including section load commands)
- ** int8_t[16] segment name
+ ** char[16] segment name
** uint32_t in-memory offset
** uint32_t in-memory size
** uint32_t in-file offset to data area
** uint32_t flags
**
** section commands
- ** int8_t[16] section name
- ** int8_t[16] segment name
+ ** char[16] section name
+ ** char[16] segment name
** uint32_t in-memory offset
** uint32_t in-memory size
** uint32_t in-file offset
/*
* Writes a counted string
*/
-static ObjRecord *obj_name(ObjRecord * orp, int8_t *name)
+static ObjRecord *obj_name(ObjRecord * orp, char *name)
{
int len = strlen(name);
uint8_t *ptr;
* This concludes the low level section of outobj.c
*/
-static int8_t obj_infile[FILENAME_MAX];
+static char obj_infile[FILENAME_MAX];
static efunc error;
static evalfunc evaluate;
static struct FileName {
struct FileName *next;
- int8_t *name;
+ char *name;
struct LineNumber *lnhead, **lntail;
int index;
} *fnhead, **fntail;
static struct Public {
struct Public *next;
- int8_t *name;
+ char *name;
int32_t offset;
int32_t segment; /* only if it's far-absolute */
int type; /* only for local debug syms */
static struct External {
struct External *next;
- int8_t *name;
+ char *name;
int32_t commonsize;
int32_t commonelem; /* element size if FAR, else zero */
int index; /* OBJ-file external index */
DEFWRT_GROUP /* a group */
} defwrt_type;
union {
- int8_t *string;
+ char *string;
struct Segment *seg;
struct Group *grp;
} defwrt_ptr;
} combine;
int32_t use32; /* is this segment 32-bit? */
struct Public *pubhead, **pubtail, *lochead, **loctail;
- int8_t *name;
- int8_t *segclass, *overlay; /* `class' is a C++ keyword :-) */
+ char *name;
+ char *segclass, *overlay; /* `class' is a C++ keyword :-) */
ObjRecord *orp;
} *seghead, **segtail, *obj_seg_needs_update;
static struct Group {
struct Group *next;
- int8_t *name;
+ char *name;
int32_t index; /* NASM segment id */
int32_t obj_index; /* OBJ-file group index */
int32_t nentries; /* number of elements... */
int32_t nindices; /* ...and number of index elts... */
union {
int32_t index;
- int8_t *name;
+ char *name;
} segs[GROUP_MAX]; /* ...in this */
} *grphead, **grptail, *obj_grp_needs_update;
static struct ImpDef {
struct ImpDef *next;
- int8_t *extname;
- int8_t *libname;
+ char *extname;
+ char *libname;
unsigned int impindex;
- int8_t *impname;
+ char *impname;
} *imphead, **imptail;
static struct ExpDef {
struct ExpDef *next;
- int8_t *intname;
- int8_t *extname;
+ char *intname;
+ char *extname;
unsigned int ordinal;
int flags;
} *exphead, **exptail;
/* The current segment */
static struct Segment *current_seg;
-static int32_t obj_segment(int8_t *, int, int *);
+static int32_t obj_segment(char *, int, int *);
static void obj_write_file(int debuginfo);
-static int obj_directive(int8_t *, int8_t *, int);
+static int obj_directive(char *, char *, int);
static void obj_init(FILE * fp, efunc errfunc, ldfunc ldef, evalfunc eval)
{
of_obj.current_dfmt->init(&of_obj, NULL, fp, errfunc);
}
-static int obj_set_info(enum geninfo type, int8_t **val)
+static int obj_set_info(enum geninfo type, char **val)
{
(void)type;
(void)val;
}
}
-static void obj_ext_set_defwrt(struct External *ext, int8_t *id)
+static void obj_ext_set_defwrt(struct External *ext, char *id)
{
struct Segment *seg;
struct Group *grp;
dws = ext;
}
-static void obj_deflabel(int8_t *name, int32_t segment,
- int32_t offset, int is_global, int8_t *special)
+static void obj_deflabel(char *name, int32_t segment,
+ int32_t offset, int is_global, char *special)
{
/*
* We have three cases:
* We might have a default-WRT specification.
*/
if (!nasm_strnicmp(special, "wrt", 3)) {
- int8_t *p;
+ char *p;
int len;
special += 3;
special += strspn(special, " \t");
obj_commit(forp);
}
-static int32_t obj_segment(int8_t *name, int pass, int *bits)
+static int32_t obj_segment(char *name, int pass, int *bits)
{
/*
* We call the label manager here to define a name for the new
struct Group *grp;
struct External **extp;
int obj_idx, i, attrs, rn_error;
- int8_t *p;
+ char *p;
/*
* Look for segment attributes.
}
}
-static int obj_directive(int8_t *directive, int8_t *value, int pass)
+static int obj_directive(char *directive, char *value, int pass)
{
if (!strcmp(directive, "group")) {
- int8_t *p, *q, *v;
+ char *p, *q, *v;
if (pass == 1) {
struct Group *grp;
struct Segment *seg;
return 1;
}
if (!strcmp(directive, "import")) {
- int8_t *q, *extname, *libname, *impname;
+ char *q, *extname, *libname, *impname;
if (pass == 2)
return 1; /* ignore in pass two */
return 1;
}
if (!strcmp(directive, "export")) {
- int8_t *q, *extname, *intname, *v;
+ char *q, *extname, *intname, *v;
struct ExpDef *export;
int flags = 0;
unsigned int ordinal = 0;
return segment; /* no special treatment */
}
-static void obj_filename(int8_t *inname, int8_t *outname, efunc lerror)
+static void obj_filename(char *inname, char *outname, efunc lerror)
{
strcpy(obj_infile, inname);
standard_extension(inname, outname, ".obj", lerror);
struct External *ext;
struct ImpDef *imp;
struct ExpDef *export;
- static int8_t boast[] = "The Netwide Assembler " NASM_VER;
+ static char boast[] = "The Netwide Assembler " NASM_VER;
int lname_idx;
ObjRecord *orp;
fputc((-cksum) & 0xFF, ofp);
}
-static const int8_t *obj_stdmac[] = {
+static const char *obj_stdmac[] = {
"%define __SECT__ [section .text]",
"%imacro group 1+.nolist",
"[group %1]",
}
}
-static void dbgbi_linnum(const int8_t *lnfname, int32_t lineno, int32_t segto)
+static void dbgbi_linnum(const char *lnfname, int32_t lineno, int32_t segto)
{
struct FileName *fn;
struct LineNumber *ln;
fn->lntail = &ln->next;
}
-static void dbgbi_deflabel(int8_t *name, int32_t segment,
- int32_t offset, int is_global, int8_t *special)
+static void dbgbi_deflabel(char *name, int32_t segment,
+ int32_t offset, int is_global, char *special)
{
struct Segment *seg;
typedef int16_t int16; /* not sure if this will be required to be altered
at all... best to typedef it just in case */
-static const int8_t *RDOFFId = "RDOFF1"; /* written to start of RDOFF files */
+static const char *RDOFFId = "RDOFF1"; /* written to start of RDOFF files */
/* the records that can be found in the RDOFF header */
* 32764. */
struct RelocRec {
- int8_t type; /* must be 1 */
- int8_t segment; /* only 0 for code, or 1 for data supported,
+ char type; /* must be 1 */
+ char segment; /* only 0 for code, or 1 for data supported,
* but add 64 for relative refs (ie do not require
* reloc @ loadtime, only linkage) */
int32_t offset; /* from start of segment in which reference is loc'd */
- int8_t length; /* 1 2 or 4 bytes */
+ char length; /* 1 2 or 4 bytes */
int16 refseg; /* segment to which reference refers to */
};
struct ImportRec {
- int8_t type; /* must be 2 */
+ char type; /* must be 2 */
int16 segment; /* segment number allocated to the label for reloc
* records - label is assumed to be at offset zero
* in this segment, so linker must fix up with offset
* of segment and of offset within segment */
- int8_t label[33]; /* zero terminated... should be written to file until
+ char label[33]; /* zero terminated... should be written to file until
* the zero, but not after it - max len = 32 chars */
};
struct ExportRec {
- int8_t type; /* must be 3 */
- int8_t segment; /* segment referred to (0/1) */
+ char type; /* must be 3 */
+ char segment; /* segment referred to (0/1) */
int32_t offset; /* offset within segment */
- int8_t label[33]; /* zero terminated as above. max len = 32 chars */
+ char label[33]; /* zero terminated as above. max len = 32 chars */
};
struct DLLRec {
- int8_t type; /* must be 4 */
- int8_t libname[128]; /* name of library to link with at load time */
+ char type; /* must be 4 */
+ char libname[128]; /* name of library to link with at load time */
};
struct BSSRec {
- int8_t type; /* must be 5 */
+ char type; /* must be 5 */
int32_t amount; /* number of bytes BSS to reserve */
};
typedef struct memorybuffer {
int length;
- int8_t buffer[BUF_BLOCK_LEN];
+ char buffer[BUF_BLOCK_LEN];
struct memorybuffer *next;
} memorybuffer;
bsslength = 0;
}
-static int32_t rdf_section_names(int8_t *name, int pass, int *bits)
+static int32_t rdf_section_names(char *name, int pass, int *bits)
{
/*
* Default is 32 bits.
membufwrite(header, r->libname, strlen(r->libname) + 1);
}
-static void rdf_deflabel(int8_t *name, int32_t segment, int32_t offset,
- int is_global, int8_t *special)
+static void rdf_deflabel(char *name, int32_t segment, int32_t offset,
+ int is_global, char *special)
{
struct ExportRec r;
struct ImportRec ri;
return segment;
}
-static int rdf_directive(int8_t *directive, int8_t *value, int pass)
+static int rdf_directive(char *directive, char *value, int pass)
{
struct DLLRec r;
return 0;
}
-static void rdf_filename(int8_t *inname, int8_t *outname, efunc error)
+static void rdf_filename(char *inname, char *outname, efunc error)
{
standard_extension(inname, outname, ".rdf", error);
}
-static int8_t *rdf_stdmac[] = {
+static char *rdf_stdmac[] = {
"%define __SECT__ [section .text]",
"%imacro library 1+.nolist",
"[library %1]",
NULL
};
-static int rdf_set_info(enum geninfo type, int8_t **val)
+static int rdf_set_info(enum geninfo type, char **val)
{
return 0;
}
#include "rdoff/rdoff.h"
/* This signature is written to start of RDOFF files */
-static const int8_t *RDOFF2Id = RDOFF2_SIGNATURE;
+static const char *RDOFF2Id = RDOFF2_SIGNATURE;
/* Note that whenever a segment is referred to in the RDOFF file, its number
* is always half of the segment number that NASM uses to refer to it; this
#define COUNT_SEGTYPES 9
-static int8_t *segmenttypes[COUNT_SEGTYPES] = {
+static char *segmenttypes[COUNT_SEGTYPES] = {
"null", "text", "code", "data",
"comment", "lcomment", "pcomment",
"symdebug", "linedebug"
static efunc error;
static struct seginfo {
- int8_t *segname;
+ char *segname;
int segnumber;
uint16_t segtype;
uint16_t segreserved;
headerlength = 0;
}
-static int32_t rdf2_section_names(int8_t *name, int pass, int *bits)
+static int32_t rdf2_section_names(char *name, int pass, int *bits)
{
int i;
- int8_t *p, *q;
+ char *p, *q;
int code = -1;
int reserved = 0;
*/
static void write_reloc_rec(struct RelocRec *r)
{
- int8_t buf[4], *b;
+ char buf[4], *b;
if (r->refseg != (uint16_t) NO_SEG && (r->refseg & 1)) /* segment base ref */
r->type = RDFREC_SEGRELOC;
*/
static void write_export_rec(struct ExportRec *r)
{
- int8_t buf[4], *b;
+ char buf[4], *b;
r->segment >>= 1;
static void write_import_rec(struct ImportRec *r)
{
- int8_t buf[4], *b;
+ char buf[4], *b;
r->segment >>= 1;
*/
static void write_bss_rec(struct BSSRec *r)
{
- int8_t buf[4], *b;
+ char buf[4], *b;
saa_wbytes(header, &r->type, 1);
saa_wbytes(header, &r->reclen, 1);
*/
static void write_common_rec(struct CommonRec *r)
{
- int8_t buf[4], *b;
+ char buf[4], *b;
r->segment >>= 1;
/*
* Handle export, import and common records.
*/
-static void rdf2_deflabel(int8_t *name, int32_t segment, int32_t offset,
- int is_global, int8_t *special)
+static void rdf2_deflabel(char *name, int32_t segment, int32_t offset,
+ int is_global, char *special)
{
struct ExportRec r;
struct ImportRec ri;
struct CommonRec ci;
static int farsym = 0;
static int i;
- int8_t symflags = 0;
+ char symflags = 0;
int len;
/* Check if the label length is OK */
static void membufwrite(int segment, const void *data, int bytes)
{
int i;
- int8_t buf[4], *b;
+ char buf[4], *b;
for (i = 0; i < nsegments; i++) {
if (segments[i].segnumber == segment)
/*
* Handle RDOFF2 specific directives
*/
-static int rdf2_directive(int8_t *directive, int8_t *value, int pass)
+static int rdf2_directive(char *directive, char *value, int pass)
{
int n;
return 0;
}
-static void rdf2_filename(int8_t *inname, int8_t *outname, efunc error)
+static void rdf2_filename(char *inname, char *outname, efunc error)
{
standard_extension(inname, outname, ".rdf", error);
}
-static const int8_t *rdf2_stdmac[] = {
+static const char *rdf2_stdmac[] = {
"%define __SECT__ [section .text]",
"%imacro library 1+.nolist",
"[library %1]",
NULL
};
-static int rdf2_set_info(enum geninfo type, int8_t **val)
+static int rdf2_set_info(enum geninfo type, char **val)
{
return 0;
}
location = locp;
}
-insn *parse_line(int pass, int8_t *buffer, insn * result,
+insn *parse_line(int pass, char *buffer, insn * result,
efunc errfunc, evalfunc evaluate, ldfunc ldef)
{
int operand;
int32_t sign = +1L;
if (i == '-') {
- int8_t *save = stdscan_bufptr;
+ char *save = stdscan_bufptr;
i = stdscan(NULL, &tokval);
sign = -1L;
if (i != TOKEN_FLOAT || !is_comma_next()) {
nasm_realloc(eop, sizeof(extop) + eop->stringlen);
tail = &eop->next;
*fixptr = eop;
- eop->stringval = (int8_t *)eop + sizeof(extop);
+ eop->stringval = (char *)eop + sizeof(extop);
if (eop->stringlen < 4 ||
!float_const(tokval.t_charptr, sign,
(uint8_t *)eop->stringval,
static int is_comma_next(void)
{
- int8_t *p;
+ char *p;
int i;
struct tokenval tv;
#define NASM_PARSER_H
void parser_global_info(struct ofmt *output, loc_t * locp);
-insn *parse_line(int pass, int8_t *buffer, insn * result,
+insn *parse_line(int pass, char *buffer, insn * result,
efunc error, evalfunc evaluate, ldfunc ldef);
void cleanup_insn(insn * instruction);
*/
struct SMacro {
SMacro *next;
- int8_t *name;
+ char *name;
int casesense;
int nparam;
int in_progress;
*/
struct MMacro {
MMacro *next;
- int8_t *name;
+ char *name;
int casesense;
int64_t nparam_min, nparam_max;
int plus; /* is the last parameter greedy? */
struct Context {
Context *next;
SMacro *localmac;
- int8_t *name;
+ char *name;
uint32_t number;
};
*/
struct Token {
Token *next;
- int8_t *text;
+ char *text;
SMacro *mac; /* associated macro for TOK_SMAC_END */
int type;
};
FILE *fp;
Cond *conds;
Line *expansion;
- int8_t *fname;
+ char *fname;
int lineno, lineinc;
MMacro *mstk; /* stack of active macros/reps */
};
*/
struct IncPath {
IncPath *next;
- int8_t *path;
+ char *path;
};
/*
* we treat CXZ and ECXZ as condition codes, albeit non-invertible
* ones, so we need a different enum...
*/
-static const int8_t *conditions[] = {
+static const char *conditions[] = {
"a", "ae", "b", "be", "c", "cxz", "e", "ecxz", "g", "ge", "l", "le",
"na", "nae", "nb", "nbe", "nc", "ne", "ng", "nge", "nl", "nle", "no",
"np", "ns", "nz", "o", "p", "pe", "po", "s", "z"
/*
* Directive names.
*/
-static const int8_t *directives[] = {
+static const char *directives[] = {
"%arg",
"%assign", "%clear", "%define", "%elif", "%elifctx", "%elifdef",
"%elifid", "%elifidn", "%elifidni", "%elifmacro", "%elifnctx",
TM_IFNDEF, TM_INCLUDE, TM_LOCAL
};
-static const int8_t *tasm_directives[] = {
+static const char *tasm_directives[] = {
"arg", "elif", "else", "endif", "if", "ifdef", "ifdifi",
"ifndef", "include", "local"
};
static int StackSize = 4;
-static int8_t *StackPointer = "ebp";
+static char *StackPointer = "ebp";
static int ArgOffset = 8;
static int LocalOffset = 4;
#define PARAM_DELTA 16
/*
- * The standard macro set: defined as `static int8_t *stdmac[]'. Also
+ * The standard macro set: defined as `static char *stdmac[]'. Also
* gives our position in the macro set, when we're processing it.
*/
#include "macros.c"
-static const int8_t **stdmacpos;
+static const char **stdmacpos;
/*
* The extra standard macros that come from the object format, if
* any.
*/
-static const int8_t **extrastdmac = NULL;
+static const char **extrastdmac = NULL;
int any_extrastdmac;
/*
static Token *expand_mmac_params(Token * tline);
static Token *expand_smacro(Token * tline);
static Token *expand_id(Token * tline);
-static Context *get_ctx(int8_t *name, int all_contexts);
+static Context *get_ctx(char *name, int all_contexts);
static void make_tok_num(Token * tok, int32_t val);
-static void error(int severity, const int8_t *fmt, ...);
+static void error(int severity, const char *fmt, ...);
static void *new_Block(size_t size);
static void delete_Blocks(void);
-static Token *new_Token(Token * next, int type, int8_t *text, int txtlen);
+static Token *new_Token(Token * next, int type, char *text, int txtlen);
static Token *delete_Token(Token * t);
/*
* place to do it for the moment, and it is a hack (ideally it would
* be nice to be able to use the NASM pre-processor to do it).
*/
-static int8_t *check_tasm_directive(int8_t *line)
+static char *check_tasm_directive(char *line)
{
int32_t i, j, k, m, len;
- int8_t *p = line, *oldline, oldchar;
+ char *p = line, *oldline, oldchar;
/* Skip whitespace */
while (isspace(*p) && *p != 0)
* flags') into NASM preprocessor line number indications (`%line
* lineno file').
*/
-static int8_t *prepreproc(int8_t *line)
+static char *prepreproc(char *line)
{
int lineno, fnlen;
- int8_t *fname, *oldline;
+ char *fname, *oldline;
if (line[0] == '#' && line[1] == ' ') {
oldline = line;
* invariant under case changes. We implement this by applying a
* perfectly normal hash function to the uppercase of the string.
*/
-static int hash(int8_t *s)
+static int hash(char *s)
{
unsigned int h = 0;
int i = 0;
* return lines from the standard macro set if this has not already
* been done.
*/
-static int8_t *read_line(void)
+static char *read_line(void)
{
- int8_t *buffer, *p, *q;
+ char *buffer, *p, *q;
int bufsize, continued_count;
if (stdmacpos) {
if (*stdmacpos) {
- int8_t *ret = nasm_strdup(*stdmacpos++);
+ char *ret = nasm_strdup(*stdmacpos++);
if (!*stdmacpos && any_extrastdmac) {
stdmacpos = extrastdmac;
any_extrastdmac = FALSE;
* don't need to parse the value out of e.g. numeric tokens: we
* simply split one string into many.
*/
-static Token *tokenize(int8_t *line)
+static Token *tokenize(char *line)
{
- int8_t *p = line;
+ char *p = line;
int type;
Token *list = NULL;
Token *t, **tail = &list;
/*
* A string token.
*/
- int8_t c = *p;
+ char c = *p;
p++;
type = TOK_STRING;
while (*p && *p != c)
* Anything else is an operator of some kind. We check
* for all the double-character operators (>>, <<, //,
* %%, <=, >=, ==, !=, <>, &&, ||, ^^), but anything
- * else is a single-int8_tacter operator.
+ * else is a single-character operator.
*/
type = TOK_OTHER;
if ((p[0] == '>' && p[1] == '>') ||
* back to the caller. It sets the type and text elements, and
* also the mac and next elements to NULL.
*/
-static Token *new_Token(Token * next, int type, int8_t *text, int txtlen)
+static Token *new_Token(Token * next, int type, char *text, int txtlen)
{
Token *t;
int i;
* If expand_locals is not zero, identifiers of the form "%$*xxx"
* will be transformed into ..@ctxnum.xxx
*/
-static int8_t *detoken(Token * tlist, int expand_locals)
+static char *detoken(Token * tlist, int expand_locals)
{
Token *t;
int len;
- int8_t *line, *p;
+ char *line, *p;
len = 0;
for (t = tlist; t; t = t->next) {
if (t->type == TOK_PREPROC_ID && t->text[1] == '!') {
- int8_t *p = getenv(t->text + 2);
+ char *p = getenv(t->text + 2);
nasm_free(t->text);
if (p)
t->text = nasm_strdup(p);
t->text[0] == '%' && t->text[1] == '$') {
Context *ctx = get_ctx(t->text, FALSE);
if (ctx) {
- int8_t buffer[40];
- int8_t *p, *q = t->text + 2;
+ char buffer[40];
+ char *p, *q = t->text + 2;
q += strspn(q, "$");
snprintf(buffer, sizeof(buffer), "..@%lu.", ctx->number);
if (tline->type == TOK_STRING) {
int rn_warn;
- int8_t q, *r;
+ char q, *r;
int l;
r = tline->text;
* simple wrapper which calls either strcmp or nasm_stricmp
* depending on the value of the `casesense' parameter.
*/
-static int mstrcmp(int8_t *p, int8_t *q, int casesense)
+static int mstrcmp(char *p, char *q, int casesense)
{
return casesense ? strcmp(p, q) : nasm_stricmp(p, q);
}
* only the context that directly results from the number of $'s
* in variable's name.
*/
-static Context *get_ctx(int8_t *name, int all_contexts)
+static Context *get_ctx(char *name, int all_contexts)
{
Context *ctx;
SMacro *m;
* the include path one by one until it finds the file or reaches
* the end of the path.
*/
-static FILE *inc_fopen(int8_t *file)
+static FILE *inc_fopen(char *file)
{
FILE *fp;
- int8_t *prefix = "", *combine;
+ char *prefix = "", *combine;
IncPath *ip = ipath;
static int namelen = 0;
int len = strlen(file);
* is true, macro will be searched in outer contexts as well.
*/
static int
-smacro_defined(Context * ctx, int8_t *name, int nparam, SMacro ** defn,
+smacro_defined(Context * ctx, char *name, int nparam, SMacro ** defn,
int nocase)
{
SMacro *m;
* First tokenize the string, apply "expand_smacro" and then de-tokenize back.
* The returned variable should ALWAYS be freed after usage.
*/
-void expand_macros_in_string(int8_t **p)
+void expand_macros_in_string(char **p)
{
Token *line = tokenize(*p);
line = expand_smacro(line);
int i, j, nparam, nolist;
int64_t k, m;
int offset;
- int8_t *p, *mname;
+ char *p, *mname;
Include *inc;
Context *ctx;
Cond *cond;
*/
offset = ArgOffset;
do {
- int8_t *arg, directive[256];
+ char *arg, directive[256];
int size = StackSize;
/* Find the argument name */
*/
offset = LocalOffset;
do {
- int8_t *local, directive[256];
+ char *local, directive[256];
int size = StackSize;
/* Find the argument name */
(((tline->text[1] == '+' || tline->text[1] == '-')
&& tline->text[2]) || tline->text[1] == '%'
|| (tline->text[1] >= '0' && tline->text[1] <= '9'))) {
- int8_t *text = NULL;
+ char *text = NULL;
int type = 0, cc; /* type = 0 to placate optimisers */
- int8_t tmpbuf[30];
+ char tmpbuf[30];
int n, i;
MMacro *mac;
break;
case TOK_ID:
if (tt->type == TOK_ID || tt->type == TOK_NUMBER) {
- int8_t *tmp = nasm_strcat(t->text, tt->text);
+ char *tmp = nasm_strcat(t->text, tt->text);
nasm_free(t->text);
t->text = tmp;
t->next = delete_Token(tt);
break;
case TOK_NUMBER:
if (tt->type == TOK_NUMBER) {
- int8_t *tmp = nasm_strcat(t->text, tt->text);
+ char *tmp = nasm_strcat(t->text, tt->text);
nasm_free(t->text);
t->text = tmp;
t->next = delete_Token(tt);
int nparam, sparam, brackets, rescan;
Token *org_tline = tline;
Context *ctx;
- int8_t *mname;
+ char *mname;
/*
* Trick: we should avoid changing the start token pointer since it can
}
if (tline->type == TOK_OTHER
&& tline->text[1] == 0) {
- int8_t ch = tline->text[0];
+ char ch = tline->text[0];
if (ch == ',' && !paren && brackets <= 0) {
if (++nparam >= sparam) {
sparam += PARAM_DELTA;
if (t->next->type == TOK_ID ||
t->next->type == TOK_PREPROC_ID ||
t->next->type == TOK_NUMBER) {
- int8_t *p = nasm_strcat(t->text, t->next->text);
+ char *p = nasm_strcat(t->text, t->next->text);
nasm_free(t->text);
t->next = delete_Token(t->next);
t->text = p;
* won't want to see same error twice (preprocessing is done once
* per pass) we will want to show errors only during pass one.
*/
-static void error(int severity, const int8_t *fmt, ...)
+static void error(int severity, const char *fmt, ...)
{
va_list arg;
- int8_t buff[1024];
+ char buff[1024];
/* If we're in a dead branch of IF or something like it, ignore the error */
if (istk && istk->conds && !emitting(istk->conds->state))
}
static void
-pp_reset(int8_t *file, int apass, efunc errfunc, evalfunc eval,
+pp_reset(char *file, int apass, efunc errfunc, evalfunc eval,
ListGen * listgen)
{
int h;
pass = apass;
}
-static int8_t *pp_getline(void)
+static char *pp_getline(void)
{
- int8_t *line;
+ char *line;
Token *tline;
while (1) {
while (1) { /* until we get a line we can use */
if (istk->expansion) { /* from a macro expansion */
- int8_t *p;
+ char *p;
Line *l = istk->expansion;
if (istk->mstk)
istk->mstk->lineno++;
}
}
-void pp_include_path(int8_t *path)
+void pp_include_path(char *path)
{
IncPath *i;
/* by alexfru: order of path inclusion fixed (was reverse order) */
* The function use is simple:
*
* The 1st call (with NULL argument) returns a pointer to the 1st path
- * (int8_t** type) or NULL if none include paths available.
+ * (char** type) or NULL if none include paths available.
*
* All subsequent calls take as argument the value returned by this
* function last. The return value is either the next path
- * (int8_t** type) or NULL if the end of the paths list is reached.
+ * (char** type) or NULL if the end of the paths list is reached.
*
* It is maybe not the best way to do things, but I didn't want
* to export too much, just one or two functions and no types or
* Can't say I like the current situation with e.g. this path list either,
* it seems to be never deallocated after creation...
*/
-int8_t **pp_get_include_path_ptr(int8_t **pPrevPath)
+char **pp_get_include_path_ptr(char **pPrevPath)
{
/* This macro returns offset of a member of a structure */
#define GetMemberOffset(StructType,MemberName)\
else
return NULL;
}
- i = (IncPath *) ((int8_t *)pPrevPath - GetMemberOffset(IncPath, path));
+ i = (IncPath *) ((char *)pPrevPath - GetMemberOffset(IncPath, path));
i = i->next;
if (i != NULL)
return &i->path;
#undef GetMemberOffset
}
-void pp_pre_include(int8_t *fname)
+void pp_pre_include(char *fname)
{
Token *inc, *space, *name;
Line *l;
predef = l;
}
-void pp_pre_define(int8_t *definition)
+void pp_pre_define(char *definition)
{
Token *def, *space;
Line *l;
- int8_t *equals;
+ char *equals;
equals = strchr(definition, '=');
space = new_Token(NULL, TOK_WHITESPACE, NULL, 0);
predef = l;
}
-void pp_pre_undefine(int8_t *definition)
+void pp_pre_undefine(char *definition)
{
Token *def, *space;
Line *l;
* PASS A VALID STRING TO THIS FUNCTION!!!!!
*/
-void pp_runtime(int8_t *definition)
+void pp_runtime(char *definition)
{
Token *def;
}
-void pp_extra_stdmac(const int8_t **macros)
+void pp_extra_stdmac(const char **macros)
{
extrastdmac = macros;
}
static void make_tok_num(Token * tok, int32_t val)
{
- int8_t numbuf[20];
+ char numbuf[20];
snprintf(numbuf, sizeof(numbuf), "%ld", val);
tok->text = nasm_strdup(numbuf);
tok->type = TOK_NUMBER;
#ifndef NASM_PREPROC_H
#define NASM_PREPROC_H
-void pp_include_path(int8_t *);
-int8_t **pp_get_include_path_ptr(int8_t **pPrevPath);
-void pp_pre_include(int8_t *);
-void pp_pre_define(int8_t *);
-void pp_pre_undefine(int8_t *);
-void pp_runtime(int8_t *);
-void pp_extra_stdmac(const int8_t **);
+void pp_include_path(char *);
+char **pp_get_include_path_ptr(char **pPrevPath);
+void pp_pre_include(char *);
+void pp_pre_define(char *);
+void pp_pre_undefine(char *);
+void pp_runtime(char *);
+void pp_extra_stdmac(const char **);
extern Preproc nasmpp;
struct segment_infonode seginfo[RDF_MAXSEGS]; /* what are we doing
with each segment? */
void *header;
- int8_t *name;
+ char *name;
struct modulenode *next;
int32_t bss_reloc;
};
* Function prototypes of private utility functions
*/
-void processmodule(const int8_t *filename, struct modulenode *mod);
+void processmodule(const char *filename, struct modulenode *mod);
int allocnewseg(uint16_t type, uint16_t reserved);
int findsegment(uint16_t type, uint16_t reserved);
-void symtab_add(const int8_t *symbol, int segment, int32_t offset);
-int symtab_get(const int8_t *symbol, int *segment, int32_t *offset);
+void symtab_add(const char *symbol, int segment, int32_t offset);
+int symtab_get(const char *symbol, int *segment, int32_t *offset);
/* =========================================================================
* Global data structures.
void *symtab = NULL;
/* objects search path */
-int8_t *objpath = NULL;
+char *objpath = NULL;
/* libraries search path */
-int8_t *libpath = NULL;
+char *libpath = NULL;
/* file to embed as a generic record */
-int8_t *generic_rec_file = NULL;
+char *generic_rec_file = NULL;
/* error file */
static FILE *error_file;
/*
* loadmodule
*
- * Determine the int8_tacteristics of a module, and decide what to do with
+ * Determine the characteristics of a module, and decide what to do with
* each segment it contains (including determining destination segments and
* relocation factors for segments that are kept).
*/
-void loadmodule(const int8_t *filename)
+void loadmodule(const char *filename)
{
if (options.verbose)
printf("loading `%s'\n", filename);
* (b) is fairly easy, because we're now keeping track of how big each
* segment in our output file is...
*/
-void processmodule(const int8_t *filename, struct modulenode *mod)
+void processmodule(const char *filename, struct modulenode *mod)
{
struct segconfig sconf;
int seg, outseg;
/*
* Return 1 if a given module is in the list, 0 otherwise.
*/
-int lookformodule(const int8_t *name)
+int lookformodule(const char *name)
{
struct modulenode *curr = modules;
* routine won't change a previously existing symbol. It will change
* to segment = -2 only if the segment was previously < 0.
*/
-void symtab_add(const int8_t *symbol, int segment, int32_t offset)
+void symtab_add(const char *symbol, int segment, int32_t offset)
{
symtabEnt *ste;
* are assumed to have -1:0 associated. Returns 1 if the symbol was
* successfully located.
*/
-int symtab_get(const int8_t *symbol, int *segment, int32_t *offset)
+int symtab_get(const char *symbol, int *segment, int32_t *offset)
{
symtabEnt *ste = symtabFind(symtab, symbol);
if (!ste) {
* checks that a library can be opened and is in the correct format,
* then adds it to the linked list of libraries.
*/
-void add_library(const int8_t *name)
+void add_library(const char *name)
{
if (rdl_verify(name)) {
rdl_perror("ldrdf", name);
* all the modules into a single output module, and then writes this to a
* file.
*/
-void write_output(const int8_t *filename)
+void write_output(const char *filename)
{
FILE *f;
rdf_headerbuf *rdfheader;
"warning: relocation out of range "
"at %s(%02x:%08lx)\n", cur->name,
(int)hr->r.segment, hr->r.offset);
- *data = (int8_t)offset;
+ *data = (char)offset;
break;
case 2:
offset += *(int16_t *)data;
int main(int argc, char **argv)
{
- int8_t *outname = "aout.rdf";
+ char *outname = "aout.rdf";
int moduleloaded = 0;
- int8_t *respstrings[128] = { 0, };
+ char *respstrings[128] = { 0, };
options.verbose = 0;
options.align = 16;
}
case '@':{
int i = 0;
- int8_t buf[256];
+ char buf[256];
FILE *f;
options.respfile = 1;
argv++, argc--;
while (fgets(buf, sizeof(buf), f) != NULL) {
- int8_t *p;
+ char *p;
if (buf[0] == '\n')
continue;
if ((p = strchr(buf, '\n')) != NULL)
struct segconfig {
uint16_t typelow, typehi; /* range of seg nos for which this is valid */
- int8_t *typedesc; /* a description of the segment type */
+ char *typedesc; /* a description of the segment type */
uint16_t dowhat; /* one of the SEG_xxxx values below */
uint16_t mergetype; /* if SEG_MERGE what type segment do we merge
with?
int32_t origin = 0;
int align = 16;
-int8_t *getfilename(int8_t *pathname)
+char *getfilename(char *pathname)
{
- int8_t *lastslash = pathname - 1;
- int8_t *i = pathname;
+ char *lastslash = pathname - 1;
+ char *i = pathname;
while (*i) {
if (*i == '/')
rdfmodule *m;
int tmp;
FILE *of;
- int8_t *padding;
+ char *padding;
int codepad, datapad, bsspad = 0;
if (argc < 2) {
rdfmodule *m;
int tmp;
FILE *of;
- int8_t *padding;
+ char *padding;
uint8_t *segbin[2];
int pad[2], segn, ofs, i;
int32_t segaddr;
void print_header(int32_t length, int rdf_version)
{
- int8_t buf[129], t, l, s, flags;
+ char buf[129], t, l, s, flags;
uint8_t reclen;
int32_t o, ll;
uint16_t rs;
int main(int argc, char **argv)
{
- int8_t id[7];
+ char id[7];
int32_t l;
uint16_t s;
int verbose = 0;
/*
* an rdoff library is simply a sequence of RDOFF object files, each
* preceded by the name of the module, an ASCII string of up to 255
- * int8_tacters, terminated by a zero.
+ * characters, terminated by a zero.
*
* When a library is being created, special signature block is placed
* in the beginning of the file. It is a string 'RDLIB' followed by a
" d - delete (module-name)\n" " t - list\n";
/* Library signature */
-const int8_t *rdl_signature = "RDLIB2", *sig_modname = ".sig";
+const char *rdl_signature = "RDLIB2", *sig_modname = ".sig";
char **_argv;
#endif
}
-int8_t copybytes(FILE * fp, FILE * fp2, int n)
+char copybytes(FILE * fp, FILE * fp2, int n)
{
int i, t = 0;
exit(1);
}
}
- return (int8_t)t; /* return last int8_t read */
+ return (char)t; /* return last char read */
}
int32_t copyint32_t(FILE * fp, FILE * fp2)
int main(int argc, char **argv)
{
FILE *fp, *fp2 = NULL, *fptmp;
- int8_t *p, buf[256], c;
+ char *p, buf[256], c;
int i;
int32_t l;
time_t t;
- int8_t rdbuf[10];
+ char rdbuf[10];
_argv = argv;
while (!feof(fp)) {
/* read name */
p = buf;
- while ((*(p++) = (int8_t)fgetc(fp)))
+ while ((*(p++) = (char)fgetc(fp)))
if (feof(fp))
break;
while (!feof(fptmp)) {
/* read name */
p = buf;
- while ((*(p++) = (int8_t)fgetc(fptmp)))
+ while ((*(p++) = (char)fgetc(fptmp)))
if (feof(fptmp))
break;
extern int rdf_errno;
-rdfmodule *rdfload(const int8_t *filename)
+rdfmodule *rdfload(const char *filename)
{
rdfmodule *f;
int32_t bsslength = 0;
- int8_t *hdr;
+ char *hdr;
rdfheaderrec *r;
f = malloc(sizeof(rdfmodule));
non-portable */
switch (r->r.length) {
case 1:
- seg[r->r.offset] += (int8_t)rel;
+ seg[r->r.offset] += (char)rel;
break;
case 2:
*(uint16_t *) (seg + r->r.offset) += (uint16_t) rel;
void *symtab;
} rdfmodule;
-rdfmodule *rdfload(const int8_t *filename);
+rdfmodule *rdfload(const char *filename);
int rdf_relocate(rdfmodule * m);
#endif
typedef enum { FALSE, TRUE } bool;
/** Constants **/
-const int8_t commands[] = "adnrtx";
-const int8_t modifiers[] = "cflouvV";
+const char commands[] = "adnrtx";
+const char modifiers[] = "cflouvV";
/** Global variables **/
-int8_t *progname = "rdlar";
-int8_t **_argv = NULL;
+char *progname = "rdlar";
+char **_argv = NULL;
struct {
bool createok;
bool usefname;
/*
* Print an error message and exit
*/
-void error_exit(int errcode, bool useperror, const int8_t *fmt, ...)
+void error_exit(int errcode, bool useperror, const char *fmt, ...)
{
va_list ap;
/*
* Fill in and write a header
*/
-void put_header(struct rdlm_hdr *hdr, FILE * libfp, int8_t *modname)
+void put_header(struct rdlm_hdr *hdr, FILE * libfp, char *modname)
{
int n = 0;
}
/*
- * Copy n bytes from one file to another and return last int8_tacter read.
+ * Copy n bytes from one file to another and return last character read.
*/
-int8_t copybytes(FILE * fp, FILE * fp2, int n)
+char copybytes(FILE * fp, FILE * fp2, int n)
{
int i, t = 0;
if (fputc(t, fp2) == EOF)
error_exit(1, FALSE, "write error");
}
- return (int8_t)t;
+ return (char)t;
}
/*
/*
* Create a new library
*/
-int create_library(int8_t *libname)
+int create_library(char *libname)
{
FILE *libfp;
struct rdlm_hdr hdr;
/*
* Add a module to the library
*/
-int add_module(FILE * libfp, const int8_t *fname, int8_t *modname)
+int add_module(FILE * libfp, const char *fname, char *modname)
{
FILE *modfp;
struct rdlm_hdr hdr = { RDLMMAG, 0, 0, 0, 0, 0, 0 };
FILE *libfp, *tmpfp, *modfp = NULL;
struct stat finfo;
struct rdlm_hdr hdr;
- int8_t buf[MAXMODNAMELEN], *p = NULL;
- int8_t c;
+ char buf[MAXMODNAMELEN], *p = NULL;
+ char c;
int i;
progname = argv[0];
if (options.verbose) {
printf("%ld bytes", hdr.size);
}
- putint8_t('\n');
+ putchar('\n');
}
copybytes(libfp, modfp, hdr.size);
int rdl_error = 0;
-int8_t *rdl_errors[5] = {
+char *rdl_errors[5] = {
"no error", "could not open file", "invalid file structure",
"file contains modules of an unsupported RDOFF version",
"module not found"
};
-int rdl_verify(const int8_t *filename)
+int rdl_verify(const char *filename)
{
FILE *fp = fopen(filename, "rb");
- int8_t buf[257];
+ char buf[257];
int i;
int32_t length;
- static int8_t lastverified[256];
+ static char lastverified[256];
static int lastresult = -1;
if (lastresult != -1 && !strcmp(filename, lastverified))
/*
* A special module, eg a signature block or a directory.
* Format of such a module is defined to be:
- * six int8_t type identifier
+ * six char type identifier
* int32_t count bytes content
* content
* so we can handle it uniformaly with RDOFF2 modules.
return lastresult = 0; /* library in correct format */
}
-int rdl_open(struct librarynode *lib, const int8_t *name)
+int rdl_open(struct librarynode *lib, const char *name)
{
int i = rdl_verify(name);
if (i)
free(lib->name);
}
-int rdl_searchlib(struct librarynode *lib, const int8_t *label, rdffile * f)
+int rdl_searchlib(struct librarynode *lib, const char *label, rdffile * f)
{
- int8_t buf[512];
+ char buf[512];
int i, t;
void *hdr;
rdfheaderrec *r;
int rdl_openmodule(struct librarynode *lib, int moduleno, rdffile * f)
{
- int8_t buf[512];
+ char buf[512];
int i, cmod, t;
int32_t length;
return rdl_error = 4; /* module not found */
}
-void rdl_perror(const int8_t *apname, const int8_t *filename)
+void rdl_perror(const char *apname, const char *filename)
{
if (rdl_error >= 16)
rdfperror(apname, filename);
#define RDL_EVERSION 3
#define RDL_ENOTFOUND 4
-int rdl_verify(const int8_t *filename);
-int rdl_open(struct librarynode *lib, const int8_t *filename);
-int rdl_searchlib(struct librarynode *lib, const int8_t *label, rdffile * f);
+int rdl_verify(const char *filename);
+int rdl_open(struct librarynode *lib, const char *filename);
+int rdl_searchlib(struct librarynode *lib, const char *label, rdffile * f);
int rdl_openmodule(struct librarynode *lib, int module, rdffile * f);
-void rdl_perror(const int8_t *apname, const int8_t *filename);
+void rdl_perror(const char *apname, const char *filename);
#endif
}
/* Segment types */
-static int8_t *knownsegtypes[8] = {
+static char *knownsegtypes[8] = {
"NULL", "text", "data", "object comment",
"linked comment", "loader comment",
"symbolic debug", "line number debug"
};
/* Get a textual string describing the segment type */
-int8_t *translatesegmenttype(uint16_t type)
+char *translatesegmenttype(uint16_t type)
{
if (type < 8)
return knownsegtypes[type];
}
/* This signature is written to the start of RDOFF files */
-const int8_t *RDOFFId = RDOFF2_SIGNATURE;
+const char *RDOFFId = RDOFF2_SIGNATURE;
/* Error messages. Must correspond to the codes defined in rdoff.h */
-const int8_t *rdf_errors[11] = {
+const char *rdf_errors[11] = {
/* 0 */ "no error occurred",
/* 1 */ "could not open file",
/* 2 */ "invalid file format",
The library functions
======================================================================== */
-int rdfopen(rdffile * f, const int8_t *name)
+int rdfopen(rdffile * f, const char *name)
{
FILE *fp;
return rdfopenhere(f, fp, NULL, name);
}
-int rdfopenhere(rdffile * f, FILE * fp, int *refcount, const int8_t *name)
+int rdfopenhere(rdffile * f, FILE * fp, int *refcount, const char *name)
{
- int8_t buf[8];
+ char buf[8];
int32_t initpos;
int32_t l;
uint16_t s;
/*
* Print the message for last error (from rdf_errno)
*/
-void rdfperror(const int8_t *app, const int8_t *name)
+void rdfperror(const char *app, const char *name)
{
fprintf(stderr, "%s:%s: %s\n", app, name, rdf_errors[rdf_errno]);
if (rdf_errno == RDF_ERR_OPEN || rdf_errno == RDF_ERR_READ) {
struct GenericRec {
uint8_t type;
uint8_t reclen;
- int8_t data[128];
+ char data[128];
};
/*
records - label is assumed to be at offset zero
in this segment, so linker must fix up with offset
of segment and of offset within segment */
- int8_t label[EXIM_LABEL_MAX]; /* zero terminated, should be written to file
+ char label[EXIM_LABEL_MAX]; /* zero terminated, should be written to file
until the zero, but not after it */
};
uint8_t flags; /* SYM_* flags (see below) */
uint8_t segment; /* segment referred to (0/1/2) */
int32_t offset; /* offset within segment */
- int8_t label[EXIM_LABEL_MAX]; /* zero terminated as in import */
+ char label[EXIM_LABEL_MAX]; /* zero terminated as in import */
};
/*
struct DLLRec {
uint8_t type; /* must be 4 */
uint8_t reclen; /* content length */
- int8_t libname[MODLIB_NAME_MAX]; /* name of library to link with at load time */
+ char libname[MODLIB_NAME_MAX]; /* name of library to link with at load time */
};
/*
struct ModRec {
uint8_t type; /* must be 8 */
uint8_t reclen; /* content length */
- int8_t modname[MODLIB_NAME_MAX]; /* module name */
+ char modname[MODLIB_NAME_MAX]; /* module name */
};
/*
uint16_t segment; /* segment number */
int32_t size; /* size of common variable */
uint16_t align; /* alignment (power of two) */
- int8_t label[EXIM_LABEL_MAX]; /* zero terminated as in import */
+ char label[EXIM_LABEL_MAX]; /* zero terminated as in import */
};
/* Flags for ExportRec */
#endif
typedef union RDFHeaderRec {
- int8_t type; /* invariant throughout all below */
+ char type; /* invariant throughout all below */
struct GenericRec g; /* type 0 */
struct RelocRec r; /* type == 1 / 6 */
struct ImportRec i; /* type == 2 / 7 */
int32_t eof_offset; /* offset of the first uint8_t beyond the end of this
module */
- int8_t *name; /* name of module in libraries */
+ char *name; /* name of module in libraries */
int *refcount; /* pointer to reference count on file, or NULL */
} rdffile;
/* utility functions */
int32_t translateint32_t(int32_t in);
uint16_t translateint16_t(uint16_t in);
-int8_t *translatesegmenttype(uint16_t type);
+char *translatesegmenttype(uint16_t type);
/* RDOFF file manipulation functions */
-int rdfopen(rdffile * f, const int8_t *name);
-int rdfopenhere(rdffile * f, FILE * fp, int *refcount, const int8_t *name);
+int rdfopen(rdffile * f, const char *name);
+int rdfopenhere(rdffile * f, FILE * fp, int *refcount, const char *name);
int rdfclose(rdffile * f);
int rdffindsegment(rdffile * f, int segno);
int rdfloadseg(rdffile * f, int segment, void *buffer);
rdfheaderrec *rdfgetheaderrec(rdffile * f); /* returns static storage */
void rdfheaderrewind(rdffile * f); /* back to start of header */
-void rdfperror(const int8_t *app, const int8_t *name);
+void rdfperror(const char *app, const char *name);
/* functions to write a new RDOFF header to a file -
use rdfnewheader to allocate a header, rdfaddheader to add records to it,
}
/* ------------------------------------- */
-symtabEnt *symtabFind(void *stab, const int8_t *name)
+symtabEnt *symtabFind(void *stab, const char *name)
{
symtab mytab = (symtab) stab;
int slot = slotnum(name);
{
symtab mytab = (symtab) stab;
int i;
- int8_t *SegNames[3] = { "code", "data", "bss" };
+ char *SegNames[3] = { "code", "data", "bss" };
fprintf(of, "Symbol table is ...\n");
for (i = 0; i < SYMTABSIZE; ++i) {
#include <inttypes.h>
typedef struct {
- int8_t *name;
+ char *name;
int segment;
int32_t offset;
int32_t flags;
void *symtabNew(void);
void symtabDone(void *symtab);
void symtabInsert(void *symtab, symtabEnt * ent);
-symtabEnt *symtabFind(void *symtab, const int8_t *name);
+symtabEnt *symtabFind(void *symtab, const char *name);
void symtabDump(void *symtab, FILE * of);
#endif
} elsif ( $fmt eq 'c' ) {
# Output regs.c
print "/* automatically generated from $file - do not edit */\n";
- print "static const int8_t *reg_names[] = "; $ch = '{';
+ print "static const char *reg_names[] = "; $ch = '{';
# This one has no dummy entry for 0
foreach $reg ( sort(keys(%regs)) ) {
print "$ch\n \"${reg}\"";