- Remove obsolete types like "uint32"; use "uint32_t" consistently.
- Make sure we include <inttypes.h> where needed.
- Header file guards should be FOO_H or SUBDIR_FOO_H; _FOO_H infringes
on the C implementation's namespace and should only be used when
writing libc!
- Change a few "int8_t" back to "char" where appropriate. There are
a lot more places where that should be done, though.
- Clean up the check for getuid/getgid in rdoff/rdlar.h.
AC_MSG_ERROR([NASM requires ISO C99 (specifically, "vsnprintf")])
fi
+AC_CHECK_FUNCS(getuid)
+AC_CHECK_FUNCS(getgid)
+
if test $ac_cv_prog_make_vpathok = no; then
echo Copying generated srcs into build directory to compensate for VPATH breakage
for file in macros.c insnsa.c insnsd.c insnsn.c insnsi.h version.h version.mac; do
puts(line);
}
-int main(int argc, int8_t **argv)
+int main(int argc, char **argv)
{
pass0 = 1;
want_usage = terminate_after_phase = FALSE;
static void output_ins(uint32_t, uint8_t *, int, int8_t *);
static void skip(uint32_t dist, FILE * fp);
-int main(int argc, int8_t **argv)
+int main(int argc, char **argv)
{
uint8_t buffer[INSN_MAX * 2], *p, *q;
int8_t outbuf[256];
static struct seginfo {
int8_t *segname;
int segnumber;
- uint16 segtype;
- uint16 segreserved;
+ uint16_t segtype;
+ uint16_t segreserved;
int32_t seglength;
} segments[RDF_MAXSEGS];
{
int8_t buf[4], *b;
- if (r->refseg != (uint16) NO_SEG && (r->refseg & 1)) /* segment base ref */
+ if (r->refseg != (uint16_t) NO_SEG && (r->refseg & 1)) /* segment base ref */
r->type = RDFREC_SEGRELOC;
r->refseg >>= 1; /* adjust segment nos to RDF rather than NASM */
struct CommonRec ci;
static int farsym = 0;
static int i;
- byte symflags = 0;
+ uint8_t symflags = 0;
int len;
/* Check if the label length is OK */
* length array (of pointers).
*/
-#ifndef _COLLECTN_H
-#define _COLLECTN_H
+#ifndef RDOFF_COLLECTN_H
+#define RDOFF_COLLECTN_H 1
typedef struct tagCollection {
void *p[32]; /* array of pointers to objects */
#include "hash.h"
-typedef unsigned int crc32;
-
-const crc32 consttab[] = {
+const uint32_t consttab[] = {
0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA,
0x076DC419, 0x706AF48F, 0xE963A535, 0x9E6495A3,
0x0EDB8832, 0x79DCB8A4, 0xE0D5E91E, 0x97D2D988,
0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, 0x2D02EF8D
};
-unsigned hash(const int8_t *name)
+uint32_t hash(const char *name)
{
- register const int8_t *n;
- register crc32 hashval = 0xffffffff;
+ register const char *n;
+ register uint32_t hashval = 0xffffffff;
for (n = name; *n; n++)
hashval = (hashval >> 8) ^ consttab[(hashval ^ *n) & 0xff];
hashval ^= 0xffffffff;
- return (hashval);
-
+ return hashval;
}
* distributed in the NASM archive.
*/
-unsigned hash(const int8_t *name);
+#ifndef RDOFF_HASH_H
+#define RDOFF_HASH_H 1
+
+#include <inttypes.h>
+
+uint32_t hash(const char *name);
+
+#endif
*/
void processmodule(const int8_t *filename, struct modulenode *mod);
-int allocnewseg(uint16 type, uint16 reserved);
-int findsegment(uint16 type, uint16 reserved);
+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);
* a segment of the type requested, and if one isn't found allocates a
* new one.
*/
-int allocnewseg(uint16 type, uint16 reserved)
+int allocnewseg(uint16_t type, uint16_t reserved)
{
outputseg[nsegs].type = type;
outputseg[nsegs].number = nsegs;
return nsegs++;
}
-int findsegment(uint16 type, uint16 reserved)
+int findsegment(uint16_t type, uint16_t reserved)
{
int i;
symtabEnt *se;
segtab segs;
int32_t offset;
- byte *data;
+ uint8_t *data;
if ((f = fopen(filename, "wb")) == NULL) {
fprintf(stderr, "ldrdf: couldn't open %s for output\n", filename);
* the output file
*/
for (i = 0; i < nsegs; i++) {
- uint16 s;
+ uint16_t s;
int32_t l;
if (i == 2)
exit(0);
}
-int main(int argc, int8_t **argv)
+int main(int argc, char **argv)
{
int8_t *outname = "aout.rdf";
int moduleloaded = 0;
* types of segment. This may be useful in other contexts also.
*/
-#ifndef UI16
-#define UI16 uint16_t
-#endif
+#ifndef RDOFF_LDSEGS_H
+#define RDOFF_LDSEGS_H 1
+
+#include <inttypes.h>
struct segconfig {
- UI16 typelow, typehi; /* range of seg nos for which this is valid */
- int8_t *typedesc; /* a description of the segment type */
- UI16 dowhat; /* one of the SEG_xxxx values below */
- UI16 mergetype; /* if SEG_MERGE what type segment do we merge with?
+ uint16_t typelow, typehi; /* range of seg nos for which this is valid */
+ int8_t *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?
0 -> same type of segment. This type is also
used with SEG_NEWSEG. */
};
exit(1); \
} \
}
+
+#endif
return lastslash + 1;
}
-int main(int argc, int8_t **argv)
+int main(int argc, char **argv)
{
rdfmodule *m;
int tmp;
return (ofs);
}
-int main(int argc, int8_t **argv)
+int main(int argc, char **argv)
{
rdfmodule *m;
int tmp;
int8_t buf[129], t, l, s, flags;
uint8_t reclen;
int32_t o, ll;
- uint16 rs;
+ uint16_t rs;
while (length > 0) {
fread(&t, 1, 1, infile);
}
}
-int main(int argc, int8_t **argv)
+int main(int argc, char **argv)
{
int8_t id[7];
int32_t l;
- uint16 s;
+ uint16_t s;
int verbose = 0;
int32_t offset;
int foundnullsegment = 0;
*
* All module names beginning with '.' are reserved for possible future
* extensions. The linker ignores all such modules, assuming they have
- * the format of a six byte type & version identifier followed by int32_t
+ * the format of a six uint8_t type & version identifier followed by int32_t
* content size, followed by data.
*/
#include <unistd.h>
#include <errno.h>
#include <string.h>
+#include <inttypes.h>
#include <time.h>
#include <inttypes.h>
* list modules
*/
-const int8_t *usage =
+const char *usage =
"usage:\n"
" rdflib x libname [extra operands]\n\n"
" where x is one of:\n"
seg[r->r.offset] += (int8_t)rel;
break;
case 2:
- *(uint16 *) (seg + r->r.offset) += (uint16) rel;
+ *(uint16_t *) (seg + r->r.offset) += (uint16_t) rel;
break;
case 4:
*(int32_t *)(seg + r->r.offset) += rel;
* file.
*/
-#ifndef _RDFLOAD_H
-#define _RDFLOAD_H
+#ifndef RDOFF_RDFLOAD_H
+#define RDOFF_RDFLOAD_H 1
#define RDOFF_UTILS
/*
* Main
*/
-int main(int argc, int8_t *argv[])
+int main(int argc, char **argv)
{
FILE *libfp, *tmpfp, *modfp = NULL;
struct stat finfo;
* rdlar.h - definitions of new RDOFF library/archive format.
*/
-#ifndef _RDLAR_H
-#define _RDLAR_H
+#ifndef RDOFF_RDLAR_H
+#define RDOFF_RDLAR_H 1
-#ifndef _POSIX_SOURCE
-/* For some MS-DOS C compilers */
-#define getuid() 0
-#define getgid() 0
+#include <inttypes.h>
+
+/* For non-POSIX operating systems */
+#ifndef HAVE_GETUID
+# define getuid() 0
+#endif
+#ifndef HAVE_GETGID
+# define getgid() 0
#endif
#define RDLAMAG 0x414C4452 /* Archive magic */
* rdlib.h Functions for manipulating libraries of RDOFF object files.
*/
+#ifndef RDOFF_RDLIB_H
+#define RDOFF_RDLIB_H 1
+
struct librarynode {
- int8_t *name;
+ char *name;
FILE *fp; /* initialised to NULL - always check */
int referenced; /* & open if required. Close afterwards */
struct librarynode *next; /* if ! referenced. */
int rdl_openmodule(struct librarynode *lib, int module, rdffile * f);
void rdl_perror(const int8_t *apname, const int8_t *filename);
+
+#endif
void membufwrite(memorybuffer * const b, void *data, int bytes)
{
- uint16 w;
+ uint16_t w;
int32_t l;
if (b->next) { /* memory buffer full - use next buffer */
break;
case -2:
- w = *(uint16 *) data;
+ w = *(uint16_t *) data;
b->buffer[b->length++] = w & 0xFF;
w >>= 8;
b->buffer[b->length++] = w & 0xFF;
return r;
}
-uint16 translateint16_t(uint16 in)
+uint16_t translateint16_t(uint16_t in)
{
- uint16 r;
+ uint16_t r;
uint8_t *i;
i = (uint8_t *)∈
};
/* Get a textual string describing the segment type */
-int8_t *translatesegmenttype(uint16 type)
+int8_t *translatesegmenttype(uint16_t type)
{
if (type < 8)
return knownsegtypes[type];
int8_t buf[8];
int32_t initpos;
int32_t l;
- uint16 s;
+ uint16_t s;
if (translateint32_t(0x01020304) != 0x01020304) {
/* fix this to be portable! */
case RDOFF_HEADER:
fpos = f->header_ofs;
slen = f->header_len;
- f->header_loc = (byte *) buffer;
+ f->header_loc = (uint8_t *) buffer;
f->header_fp = 0;
break;
default:
if (segment < f->nsegs) {
fpos = f->seg[segment].offset;
slen = f->seg[segment].length;
- f->seg[segment].data = (byte *) buffer;
+ f->seg[segment].data = (uint8_t *) buffer;
} else {
return rdf_errno = RDF_ERR_SEGMENT;
}
* with instructions of how to obtain a copy via ftp.
*/
-#ifndef _RDOFF_H
-#define _RDOFF_H
+#ifndef RDOFF_RDOFF_H
+#define RDOFF_RDOFF_H 1
+
+#include <inttypes.h>
/*
* RDOFF definitions. They are used by RDOFF utilities and by NASM's
* 'outrdf2.c' output module.
*/
-/* Type definitions */
-typedef uint32_t uint32;
-typedef uint16_t uint16;
-typedef uint8_t byte;
-typedef unsigned int bool;
-
/* RDOFF format revision (currently used only when printing the version) */
#define RDOFF2_REVISION "0.6.1"
/*
* Generic record - contains the type and length field, plus a 128 byte
- * int8_t array 'data'
+ * array 'data'
*/
struct GenericRec {
- byte type;
- byte reclen;
+ uint8_t type;
+ uint8_t reclen;
int8_t data[128];
};
* Relocation record
*/
struct RelocRec {
- byte type; /* must be 1 */
- byte reclen; /* content length */
- byte segment; /* only 0 for code, or 1 for data supported,
+ uint8_t type; /* must be 1 */
+ uint8_t reclen; /* content length */
+ uint8_t 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 */
- byte length; /* 1 2 or 4 bytes */
- uint16 refseg; /* segment to which reference refers to */
+ uint8_t length; /* 1 2 or 4 bytes */
+ uint16_t refseg; /* segment to which reference refers to */
};
/*
* Extern/import record
*/
struct ImportRec {
- byte type; /* must be 2 */
- byte reclen; /* content length */
- byte flags; /* SYM_* flags (see below) */
- uint16 segment; /* segment number allocated to the label for reloc
+ uint8_t type; /* must be 2 */
+ uint8_t reclen; /* content length */
+ uint8_t flags; /* SYM_* flags (see below) */
+ uint16_t 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 */
* Public/export record
*/
struct ExportRec {
- byte type; /* must be 3 */
- byte reclen; /* content length */
- byte flags; /* SYM_* flags (see below) */
- byte segment; /* segment referred to (0/1/2) */
+ uint8_t type; /* must be 3 */
+ uint8_t reclen; /* content length */
+ 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 */
};
* DLL record
*/
struct DLLRec {
- byte type; /* must be 4 */
- byte reclen; /* content length */
+ 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 */
};
* BSS record
*/
struct BSSRec {
- byte type; /* must be 5 */
- byte reclen; /* content length */
+ uint8_t type; /* must be 5 */
+ uint8_t reclen; /* content length */
int32_t amount; /* number of bytes BSS to reserve */
};
* Module name record
*/
struct ModRec {
- byte type; /* must be 8 */
- byte reclen; /* content length */
+ uint8_t type; /* must be 8 */
+ uint8_t reclen; /* content length */
int8_t modname[MODLIB_NAME_MAX]; /* module name */
};
* Common variable record
*/
struct CommonRec {
- byte type; /* must be 10 */
- byte reclen; /* equals 7+label length */
- uint16 segment; /* segment number */
+ uint8_t type; /* must be 10 */
+ uint8_t reclen; /* equals 7+label length */
+ uint16_t segment; /* segment number */
int32_t size; /* size of common variable */
- uint16 align; /* alignment (power of two) */
+ uint16_t align; /* alignment (power of two) */
int8_t label[EXIM_LABEL_MAX]; /* zero terminated as in import */
};
struct SegmentHeaderRec {
/* information from file */
- uint16 type;
- uint16 number;
- uint16 reserved;
+ uint16_t type;
+ uint16_t number;
+ uint16_t reserved;
int32_t length;
/* information built up here */
int32_t offset;
- byte *data; /* pointer to segment data if it exists in memory */
+ uint8_t *data; /* pointer to segment data if it exists in memory */
};
typedef struct RDFFileInfo {
int32_t header_len;
int32_t header_ofs;
- byte *header_loc; /* keep location of header */
+ uint8_t *header_loc; /* keep location of header */
int32_t header_fp; /* current location within header for reading */
struct SegmentHeaderRec seg[RDF_MAXSEGS];
int nsegs;
- int32_t eof_offset; /* offset of the first byte beyond the end of this
+ int32_t eof_offset; /* offset of the first uint8_t beyond the end of this
module */
int8_t *name; /* name of module in libraries */
* on 80x86 machines for efficiency */
typedef struct memorybuffer {
int length;
- byte buffer[BUF_BLOCK_LEN];
+ uint8_t buffer[BUF_BLOCK_LEN];
struct memorybuffer *next;
} memorybuffer;
/* utility functions */
int32_t translateint32_t(int32_t in);
-uint16 translateint16_t(uint16 in);
-int8_t *translatesegmenttype(uint16 type);
+uint16_t translateint16_t(uint16_t in);
+int8_t *translatesegmenttype(uint16_t type);
/* RDOFF file manipulation functions */
int rdfopen(rdffile * f, const int8_t *name);
#endif /* RDOFF_UTILS */
-#endif /* _RDOFF_H */
+#endif /* RDOFF_RDOFF_H */
#include "rdfload.h"
#include "symtab.h"
-typedef int (*main_fn) (int, int8_t **); /* Main function prototype */
+typedef int (*main_fn) (int, char **); /* Main function prototype */
-int main(int argc, int8_t **argv)
+int main(int argc, char **argv)
{
rdfmodule *m;
main_fn code;
+#ifndef RDOFF_SEGTAB_H
+#define RDOFF_SEGTAB_H 1
+
+#include <inttypes.h>
+
typedef void *segtab;
void init_seglocations(segtab * r);
void add_seglocation(segtab * r, int localseg, int destseg, int32_t offset);
int get_seglocation(segtab * r, int localseg, int *destseg, int32_t *offset);
void done_seglocations(segtab * r);
+
+#endif
* distributed in the NASM archive.
*/
+#ifndef RDOFF_SYMTAB_H
+#define RDOFF_SYMTAB_H 1
+
+#include <inttypes.h>
+
typedef struct {
int8_t *name;
int segment;
void symtabInsert(void *symtab, symtabEnt * ent);
symtabEnt *symtabFind(void *symtab, const int8_t *name);
void symtabDump(void *symtab, FILE * of);
+
+#endif