summaryrefslogtreecommitdiff
path: root/rdoff
diff options
context:
space:
mode:
authorKeith Kanios <spook@dynatos.net>2007-04-12 02:40:54 +0000
committerKeith Kanios <spook@dynatos.net>2007-04-12 02:40:54 +0000
commitb7a89544d09455d7b2f4621c80b21ca457563f4a (patch)
tree6c89a3318c19c2bf364cbd95859e78fbc2d4e306 /rdoff
parentaa348dec7d6c5366efd10513ae4ff6fa2bbbd6ed (diff)
downloadnasm-b7a89544d09455d7b2f4621c80b21ca457563f4a.tar.gz
nasm-b7a89544d09455d7b2f4621c80b21ca457563f4a.tar.bz2
nasm-b7a89544d09455d7b2f4621c80b21ca457563f4a.zip
General push for x86-64 support, dubbed 0.99.00.
Diffstat (limited to 'rdoff')
-rw-r--r--rdoff/collectn.h2
-rw-r--r--rdoff/hash.c4
-rw-r--r--rdoff/hash.h2
-rw-r--r--rdoff/ldrdf.c72
-rw-r--r--rdoff/ldsegs.h4
-rw-r--r--rdoff/rdf2bin.c12
-rw-r--r--rdoff/rdf2ihx.c12
-rw-r--r--rdoff/rdfdump.c60
-rw-r--r--rdoff/rdflib.c56
-rw-r--r--rdoff/rdfload.c22
-rw-r--r--rdoff/rdfload.h10
-rw-r--r--rdoff/rdlar.c50
-rw-r--r--rdoff/rdlar.h14
-rw-r--r--rdoff/rdlib.c28
-rw-r--r--rdoff/rdlib.h10
-rw-r--r--rdoff/rdoff.c64
-rw-r--r--rdoff/rdoff.h66
-rw-r--r--rdoff/rdx.c4
-rw-r--r--rdoff/segtab.c8
-rw-r--r--rdoff/segtab.h4
-rw-r--r--rdoff/symtab.c4
-rw-r--r--rdoff/symtab.h8
22 files changed, 258 insertions, 258 deletions
diff --git a/rdoff/collectn.h b/rdoff/collectn.h
index 52647d1..9cb229b 100644
--- a/rdoff/collectn.h
+++ b/rdoff/collectn.h
@@ -2,7 +2,7 @@
* collectn.h - header file for 'collection' abstract data type.
*
* This file is public domain, and does not come under the NASM license.
- * It, along with 'collectn.c' implements what is basically a variable
+ * It, aint32_t with 'collectn.c' implements what is basically a variable
* length array (of pointers).
*/
diff --git a/rdoff/hash.c b/rdoff/hash.c
index 933754a..9f80002 100644
--- a/rdoff/hash.c
+++ b/rdoff/hash.c
@@ -79,9 +79,9 @@ const crc32 consttab[] = {
0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, 0x2D02EF8D
};
-unsigned hash(const char *name)
+unsigned hash(const int8_t *name)
{
- register const char *n;
+ register const int8_t *n;
register crc32 hashval = 0xffffffff;
for (n = name; *n; n++)
diff --git a/rdoff/hash.h b/rdoff/hash.h
index cda4f61..ac9af98 100644
--- a/rdoff/hash.h
+++ b/rdoff/hash.h
@@ -8,4 +8,4 @@
* distributed in the NASM archive.
*/
-unsigned hash(const char *name);
+unsigned hash(const int8_t *name);
diff --git a/rdoff/ldrdf.c b/rdoff/ldrdf.c
index 977aeb8..ad1cc7f 100644
--- a/rdoff/ldrdf.c
+++ b/rdoff/ldrdf.c
@@ -47,7 +47,7 @@
struct segment_infonode {
int dest_seg; /* output segment to be placed into, -1 to
skip linking this segment */
- long reloc; /* segment's relocation factor */
+ int32_t reloc; /* segment's relocation factor */
};
struct modulenode {
@@ -55,9 +55,9 @@ struct modulenode {
struct segment_infonode seginfo[RDF_MAXSEGS]; /* what are we doing
with each segment? */
void *header;
- char *name;
+ int8_t *name;
struct modulenode *next;
- long bss_reloc;
+ int32_t bss_reloc;
};
#include "ldsegs.h"
@@ -69,11 +69,11 @@ struct modulenode {
* Function prototypes of private utility functions
*/
-void processmodule(const char *filename, struct modulenode *mod);
+void processmodule(const int8_t *filename, struct modulenode *mod);
int allocnewseg(uint16 type, uint16 reserved);
int findsegment(uint16 type, uint16 reserved);
-void symtab_add(const char *symbol, int segment, long offset);
-int symtab_get(const char *symbol, int *segment, long *offset);
+void symtab_add(const int8_t *symbol, int segment, int32_t offset);
+int symtab_get(const int8_t *symbol, int *segment, int32_t *offset);
/* =========================================================================
* Global data structures.
@@ -91,13 +91,13 @@ struct librarynode *lastlib = NULL;
void *symtab = NULL;
/* objects search path */
-char *objpath = NULL;
+int8_t *objpath = NULL;
/* libraries search path */
-char *libpath = NULL;
+int8_t *libpath = NULL;
/* file to embed as a generic record */
-char *generic_rec_file = NULL;
+int8_t *generic_rec_file = NULL;
/* error file */
static FILE *error_file;
@@ -111,7 +111,7 @@ rdf_headerbuf *newheader = NULL;
*/
struct SegmentHeaderRec outputseg[RDF_MAXSEGS];
int nsegs = 0;
-long bss_length;
+int32_t bss_length;
/* global options which affect how the program behaves */
struct ldrdfoptions {
@@ -157,11 +157,11 @@ void initsegments()
/*
* loadmodule
*
- * Determine the characteristics of a module, and decide what to do with
+ * Determine the int8_tacteristics 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 char *filename)
+void loadmodule(const int8_t *filename)
{
if (options.verbose)
printf("loading `%s'\n", filename);
@@ -207,13 +207,13 @@ void loadmodule(const char *filename)
* (b) is fairly easy, because we're now keeping track of how big each
* segment in our output file is...
*/
-void processmodule(const char *filename, struct modulenode *mod)
+void processmodule(const int8_t *filename, struct modulenode *mod)
{
struct segconfig sconf;
int seg, outseg;
void *header;
rdfheaderrec *hr;
- long bssamount = 0;
+ int32_t bssamount = 0;
int bss_was_referenced = 0;
for (seg = 0; seg < mod->f.nsegs; seg++) {
@@ -311,7 +311,7 @@ void processmodule(const char *filename, struct modulenode *mod)
case RDFREC_GLOBAL:{ /* exported symbol */
int destseg;
- long destreloc;
+ int32_t destreloc;
if (hr->e.segment == 2) {
bss_was_referenced = 1;
@@ -395,7 +395,7 @@ void processmodule(const char *filename, struct modulenode *mod)
/*
* Return 1 if a given module is in the list, 0 otherwise.
*/
-int lookformodule(const char *name)
+int lookformodule(const int8_t *name)
{
struct modulenode *curr = modules;
@@ -457,7 +457,7 @@ int findsegment(uint16 type, uint16 reserved)
* 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 char *symbol, int segment, long offset)
+void symtab_add(const int8_t *symbol, int segment, int32_t offset)
{
symtabEnt *ste;
@@ -509,7 +509,7 @@ void symtab_add(const char *symbol, int segment, long offset)
* are assumed to have -1:0 associated. Returns 1 if the symbol was
* successfully located.
*/
-int symtab_get(const char *symbol, int *segment, long *offset)
+int symtab_get(const int8_t *symbol, int *segment, int32_t *offset)
{
symtabEnt *ste = symtabFind(symtab, symbol);
if (!ste) {
@@ -529,7 +529,7 @@ int symtab_get(const char *symbol, int *segment, long *offset)
* 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 char *name)
+void add_library(const int8_t *name)
{
if (rdl_verify(name)) {
rdl_perror("ldrdf", name);
@@ -575,7 +575,7 @@ int search_libraries()
int i;
void *header;
int segment;
- long offset;
+ int32_t offset;
int doneanything = 0, pass = 1, keepfile;
rdfheaderrec *hr;
@@ -675,7 +675,7 @@ int search_libraries()
* all the modules into a single output module, and then writes this to a
* file.
*/
-void write_output(const char *filename)
+void write_output(const int8_t *filename)
{
FILE *f;
rdf_headerbuf *rdfheader;
@@ -685,7 +685,7 @@ void write_output(const char *filename)
rdfheaderrec *hr, newrec;
symtabEnt *se;
segtab segs;
- long offset;
+ int32_t offset;
byte *data;
if ((f = fopen(filename, "wb")) == NULL) {
@@ -885,19 +885,19 @@ void write_output(const char *filename)
"warning: relocation out of range "
"at %s(%02x:%08lx)\n", cur->name,
(int)hr->r.segment, hr->r.offset);
- *data = (char)offset;
+ *data = (int8_t)offset;
break;
case 2:
- offset += *(short *)data;
+ offset += *(int16_t *)data;
if (offset < -32767 || offset > 32768)
fprintf(error_file,
"warning: relocation out of range "
"at %s(%02x:%08lx)\n", cur->name,
(int)hr->r.segment, hr->r.offset);
- *(short *)data = (short)offset;
+ *(int16_t *)data = (int16_t)offset;
break;
case 4:
- *(long *)data += offset;
+ *(int32_t *)data += offset;
/* we can't easily detect overflow on this one */
break;
}
@@ -1097,18 +1097,18 @@ void write_output(const char *filename)
*/
for (i = 0; i < nsegs; i++) {
uint16 s;
- long l;
+ int32_t l;
if (i == 2)
continue;
- s = translateshort(outputseg[i].type);
+ s = translateint16_t(outputseg[i].type);
fwrite(&s, 2, 1, f);
- s = translateshort(outputseg[i].number);
+ s = translateint16_t(outputseg[i].number);
fwrite(&s, 2, 1, f);
- s = translateshort(outputseg[i].reserved);
+ s = translateint16_t(outputseg[i].reserved);
fwrite(&s, 2, 1, f);
- l = translatelong(outputseg[i].length);
+ l = translateint32_t(outputseg[i].length);
fwrite(&l, 4, 1, f);
fwrite(outputseg[i].data, outputseg[i].length, 1, f);
@@ -1138,11 +1138,11 @@ void usage()
exit(0);
}
-int main(int argc, char **argv)
+int main(int argc, int8_t **argv)
{
- char *outname = "aout.rdf";
+ int8_t *outname = "aout.rdf";
int moduleloaded = 0;
- char *respstrings[128] = { 0, };
+ int8_t *respstrings[128] = { 0, };
options.verbose = 0;
options.align = 16;
@@ -1217,7 +1217,7 @@ int main(int argc, char **argv)
}
case '@':{
int i = 0;
- char buf[256];
+ int8_t buf[256];
FILE *f;
options.respfile = 1;
@@ -1237,7 +1237,7 @@ int main(int argc, char **argv)
argv++, argc--;
while (fgets(buf, sizeof(buf), f) != NULL) {
- char *p;
+ int8_t *p;
if (buf[0] == '\n')
continue;
if ((p = strchr(buf, '\n')) != NULL)
diff --git a/rdoff/ldsegs.h b/rdoff/ldsegs.h
index 2a8ae88..038bb39 100644
--- a/rdoff/ldsegs.h
+++ b/rdoff/ldsegs.h
@@ -4,12 +4,12 @@
*/
#ifndef UI16
-#define UI16 unsigned short
+#define UI16 uint16_t
#endif
struct segconfig {
UI16 typelow, typehi; /* range of seg nos for which this is valid */
- char *typedesc; /* a description of the segment type */
+ 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?
0 -> same type of segment. This type is also
diff --git a/rdoff/rdf2bin.c b/rdoff/rdf2bin.c
index ac51c0e..2858cd5 100644
--- a/rdoff/rdf2bin.c
+++ b/rdoff/rdf2bin.c
@@ -9,13 +9,13 @@
#include "rdfload.h"
#include "nasmlib.h"
-long origin = 0;
+int32_t origin = 0;
int align = 16;
-char *getfilename(char *pathname)
+int8_t *getfilename(int8_t *pathname)
{
- char *lastslash = pathname - 1;
- char *i = pathname;
+ int8_t *lastslash = pathname - 1;
+ int8_t *i = pathname;
while (*i) {
if (*i == '/')
@@ -25,12 +25,12 @@ char *getfilename(char *pathname)
return lastslash + 1;
}
-int main(int argc, char **argv)
+int main(int argc, int8_t **argv)
{
rdfmodule *m;
int tmp;
FILE *of;
- char *padding;
+ int8_t *padding;
int codepad, datapad, bsspad = 0;
if (argc < 2) {
diff --git a/rdoff/rdf2ihx.c b/rdoff/rdf2ihx.c
index 512af55..d7cd2cd 100644
--- a/rdoff/rdf2ihx.c
+++ b/rdoff/rdf2ihx.c
@@ -12,13 +12,13 @@
#include "nasmlib.h"
#include "symtab.h"
-long origin = 0;
+int32_t origin = 0;
int align = 16;
/* This function writes a single n-byte data record to of. Maximum value
for n is 255. */
static int write_data_record(FILE * of, int ofs, int nbytes,
- unsigned char *data)
+ uint8_t *data)
{
int i, iofs;
unsigned int checksum;
@@ -40,15 +40,15 @@ static int write_data_record(FILE * of, int ofs, int nbytes,
return (ofs);
}
-int main(int argc, char **argv)
+int main(int argc, int8_t **argv)
{
rdfmodule *m;
int tmp;
FILE *of;
- char *padding;
- unsigned char *segbin[2];
+ int8_t *padding;
+ uint8_t *segbin[2];
int pad[2], segn, ofs, i;
- long segaddr;
+ int32_t segaddr;
unsigned int checksum;
symtabEnt *s;
diff --git a/rdoff/rdfdump.c b/rdoff/rdfdump.c
index de2bb59..1244b2f 100644
--- a/rdoff/rdfdump.c
+++ b/rdoff/rdfdump.c
@@ -14,11 +14,11 @@
FILE *infile;
-void print_header(long length, int rdf_version)
+void print_header(int32_t length, int rdf_version)
{
- char buf[129], t, l, s, flags;
- unsigned char reclen;
- long o, ll;
+ int8_t buf[129], t, l, s, flags;
+ uint8_t reclen;
+ int32_t o, ll;
uint16 rs;
while (length > 0) {
@@ -41,7 +41,7 @@ void print_header(long length, int rdf_version)
printf(" %s: location (%04x:%08lx), length %d, "
"referred seg %04x\n",
t == 1 ? "relocation" : "seg relocation", (int)s,
- translatelong(o), (int)l, translateshort(rs));
+ translateint32_t(o), (int)l, translateint16_t(rs));
if (rdf_version >= 2 && reclen != 8)
printf(" warning: reclen != 8\n");
if (rdf_version == 1)
@@ -73,7 +73,7 @@ void print_header(long length, int rdf_version)
printf(" proc");
if (flags & SYM_DATA)
printf(" data");
- printf(": segment %04x = %s\n", translateshort(rs), buf);
+ printf(": segment %04x = %s\n", translateint16_t(rs), buf);
if (rdf_version == 1)
length -= ll + 3;
if (rdf_version == 1 && t == 7)
@@ -100,7 +100,7 @@ void print_header(long length, int rdf_version)
printf(" proc");
if (flags & SYM_DATA)
printf(" data");
- printf(": (%04x:%08lx) = %s\n", (int)s, translatelong(o), buf);
+ printf(": (%04x:%08lx) = %s\n", (int)s, translateint32_t(o), buf);
if (rdf_version == 1)
length -= ll + 6;
break;
@@ -126,7 +126,7 @@ void print_header(long length, int rdf_version)
case RDFREC_BSS: /* BSS reservation */
fread(&ll, 4, 1, infile);
- printf(" bss reservation: %08lx bytes\n", translatelong(ll));
+ printf(" bss reservation: %08lx bytes\n", translateint32_t(ll));
if (rdf_version == 1)
length -= 5;
if (rdf_version > 1 && reclen != 4)
@@ -134,8 +134,8 @@ void print_header(long length, int rdf_version)
break;
case RDFREC_COMMON:{
- unsigned short seg, align;
- unsigned long size;
+ uint16_t seg, align;
+ uint32_t size;
fread(&seg, 2, 1, infile);
fread(&size, 4, 1, infile);
@@ -143,8 +143,8 @@ void print_header(long length, int rdf_version)
for (ll = 0; ll < reclen - 8; ll++)
fread(buf + ll, 1, 1, infile);
printf(" common: segment %04x = %s, %ld:%d\n",
- translateshort(seg), buf, translatelong(size),
- translateshort(align));
+ translateint16_t(seg), buf, translateint32_t(size),
+ translateint16_t(align));
break;
}
@@ -162,19 +162,19 @@ void print_header(long length, int rdf_version)
}
}
-int main(int argc, char **argv)
+int main(int argc, int8_t **argv)
{
- char id[7];
- long l;
+ int8_t id[7];
+ int32_t l;
uint16 s;
int verbose = 0;
- long offset;
+ int32_t offset;
int foundnullsegment = 0;
int version;
- long segmentcontentlength = 0;
+ int32_t segmentcontentlength = 0;
int nsegments = 0;
- long headerlength = 0;
- long objectlength = 0;
+ int32_t headerlength = 0;
+ int32_t objectlength = 0;
printf("RDOFF dump utility, version %s\n", PROGRAM_VERSION);
printf("RDOFF2 revision %s\n", RDOFF2_REVISION);
@@ -217,18 +217,18 @@ int main(int argc, char **argv)
if (version > 1) {
fread(&l, 4, 1, infile);
- objectlength = translatelong(l);
+ objectlength = translateint32_t(l);
printf("Object content size: %ld bytes\n", objectlength);
}
fread(&l, 4, 1, infile);
- headerlength = translatelong(l);
+ headerlength = translateint32_t(l);
printf("Header (%ld bytes):\n", headerlength);
print_header(headerlength, version);
if (version == 1) {
fread(&l, 4, 1, infile);
- l = translatelong(l);
+ l = translateint32_t(l);
printf("\nText segment length = %ld bytes\n", l);
offset = 0;
while (l--) {
@@ -236,7 +236,7 @@ int main(int argc, char **argv)
if (verbose) {
if (offset % 16 == 0)
printf("\n%08lx ", offset);
- printf(" %02x", (int)(unsigned char)id[0]);
+ printf(" %02x", (int)(uint8_t)id[0]);
offset++;
}
}
@@ -244,7 +244,7 @@ int main(int argc, char **argv)
printf("\n\n");
fread(&l, 4, 1, infile);
- l = translatelong(l);
+ l = translateint32_t(l);
printf("Data segment length = %ld bytes\n", l);
if (verbose) {
@@ -253,7 +253,7 @@ int main(int argc, char **argv)
fread(id, 1, 1, infile);
if (offset % 16 == 0)
printf("\n%08lx ", offset);
- printf(" %02x", (int)(unsigned char)id[0]);
+ printf(" %02x", (int)(uint8_t)id[0]);
offset++;
}
printf("\n");
@@ -261,7 +261,7 @@ int main(int argc, char **argv)
} else {
do {
fread(&s, 2, 1, infile);
- s = translateshort(s);
+ s = translateint16_t(s);
if (!s) {
printf("\nNULL segment\n");
foundnullsegment = 1;
@@ -272,11 +272,11 @@ int main(int argc, char **argv)
nsegments++;
fread(&s, 2, 1, infile);
- printf(" Number = %04X\n", (int)translateshort(s));
+ printf(" Number = %04X\n", (int)translateint16_t(s));
fread(&s, 2, 1, infile);
- printf(" Resrvd = %04X\n", (int)translateshort(s));
+ printf(" Resrvd = %04X\n", (int)translateint16_t(s));
fread(&l, 4, 1, infile);
- l = translatelong(l);
+ l = translateint32_t(l);
printf(" Length = %ld bytes\n", l);
segmentcontentlength += l;
@@ -286,7 +286,7 @@ int main(int argc, char **argv)
if (verbose) {
if (offset % 16 == 0)
printf("\n%08lx ", offset);
- printf(" %02x", (int)(unsigned char)id[0]);
+ printf(" %02x", (int)(uint8_t)id[0]);
offset++;
}
}
diff --git a/rdoff/rdflib.c b/rdoff/rdflib.c
index cd5861c..aa6e6f6 100644
--- a/rdoff/rdflib.c
+++ b/rdoff/rdflib.c
@@ -3,11 +3,11 @@
/*
* 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
- * characters, terminated by a zero.
+ * int8_tacters, 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
- * version number, then long content size and a long time stamp.
+ * version number, then int32_t content size and a int32_t time stamp.
* The module name of the signature block is '.sig'.
*
*
@@ -19,7 +19,7 @@
*
* 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 long
+ * the format of a six byte type & version identifier followed by int32_t
* content size, followed by data.
*/
@@ -39,7 +39,7 @@
* list modules
*/
-const char *usage =
+const int8_t *usage =
"usage:\n"
" rdflib x libname [extra operands]\n\n"
" where x is one of:\n"
@@ -50,17 +50,17 @@ const char *usage =
" d - delete (module-name)\n" " t - list\n";
/* Library signature */
-const char *rdl_signature = "RDLIB2", *sig_modname = ".sig";
+const int8_t *rdl_signature = "RDLIB2", *sig_modname = ".sig";
-char **_argv;
+int8_t **_argv;
#define _ENDIANNESS 0 /* 0 for little, 1 for big */
-static void longtolocal(long *l)
+static void int32_ttolocal(int32_t *l)
{
#if _ENDIANNESS
- unsigned char t;
- unsigned char *p = (unsigned char *)l;
+ uint8_t t;
+ uint8_t *p = (uint8_t *)l;
t = p[0];
p[0] = p[3];
@@ -71,7 +71,7 @@ static void longtolocal(long *l)
#endif
}
-char copybytes(FILE * fp, FILE * fp2, int n)
+int8_t copybytes(FILE * fp, FILE * fp2, int n)
{
int i, t = 0;
@@ -88,14 +88,14 @@ char copybytes(FILE * fp, FILE * fp2, int n)
exit(1);
}
}
- return (char)t; /* return last char read */
+ return (int8_t)t; /* return last int8_t read */
}
-long copylong(FILE * fp, FILE * fp2)
+int32_t copyint32_t(FILE * fp, FILE * fp2)
{
- long l;
+ int32_t l;
int i, t;
- unsigned char *p = (unsigned char *)&l;
+ uint8_t *p = (uint8_t *)&l;
for (i = 0; i < 4; i++) { /* skip magic no */
t = fgetc(fp);
@@ -111,18 +111,18 @@ long copylong(FILE * fp, FILE * fp2)
}
*p++ = t;
}
- longtolocal(&l);
+ int32_ttolocal(&l);
return l;
}
-int main(int argc, char **argv)
+int main(int argc, int8_t **argv)
{
FILE *fp, *fp2 = NULL, *fptmp;
- char *p, buf[256], c;
+ int8_t *p, buf[256], c;
int i;
- long l;
+ int32_t l;
time_t t;
- char rdbuf[10];
+ int8_t rdbuf[10];
_argv = argv;
@@ -207,7 +207,7 @@ int main(int argc, char **argv)
while (!feof(fp)) {
/* read name */
p = buf;
- while ((*(p++) = (char)fgetc(fp)))
+ while ((*(p++) = (int8_t)fgetc(fp)))
if (feof(fp))
break;
@@ -240,14 +240,14 @@ int main(int argc, char **argv)
else
copybytes(fp, fp2, 6);
- l = copylong(fp, fp2);
+ l = copyint32_t(fp, fp2);
if (argv[1][0] == 't')
printf(" %ld bytes content\n", l);
copybytes(fp, fp2, l);
} else if ((c = copybytes(fp, fp2, 6)) >= '2') { /* version 2 or above */
- l = copylong(fp, fp2);
+ l = copyint32_t(fp, fp2);
if (argv[1][0] == 't')
printf("RDOFF%c %ld bytes content\n", c, l);
@@ -259,9 +259,9 @@ int main(int argc, char **argv)
* version 1 object, so we don't have an object content
* length field.
*/
- copybytes(fp, fp2, copylong(fp, fp2)); /* header */
- copybytes(fp, fp2, copylong(fp, fp2)); /* text */
- copybytes(fp, fp2, copylong(fp, fp2)); /* data */
+ copybytes(fp, fp2, copyint32_t(fp, fp2)); /* header */
+ copybytes(fp, fp2, copyint32_t(fp, fp2)); /* text */
+ copybytes(fp, fp2, copyint32_t(fp, fp2)); /* data */
}
if (fp2)
@@ -319,7 +319,7 @@ int main(int argc, char **argv)
while (!feof(fptmp)) {
/* read name */
p = buf;
- while ((*(p++) = (char)fgetc(fptmp)))
+ while ((*(p++) = (int8_t)fgetc(fptmp)))
if (feof(fptmp))
break;
@@ -329,13 +329,13 @@ int main(int argc, char **argv)
/* check against desired name */
if (!strcmp(buf, argv[3])) {
fread(p = rdbuf, 1, sizeof(rdbuf), fptmp);
- l = *(long *)(p + 6);
+ l = *(int32_t *)(p + 6);
fseek(fptmp, l, SEEK_CUR);
break;
} else {
fwrite(buf, 1, strlen(buf) + 1, fp); /* module name */
if ((c = copybytes(fptmp, fp, 6)) >= '2') {
- l = copylong(fptmp, fp); /* version 2 or above */
+ l = copyint32_t(fptmp, fp); /* version 2 or above */
copybytes(fptmp, fp, l); /* entire object */
}
}
diff --git a/rdoff/rdfload.c b/rdoff/rdfload.c
index e5da423..09e3636 100644
--- a/rdoff/rdfload.c
+++ b/rdoff/rdfload.c
@@ -5,7 +5,7 @@
* redistributable under the licence given in the file "Licence"
* distributed in the NASM archive.
*
- * Permission to use this file in your own projects is granted, as long
+ * Permission to use this file in your own projects is granted, as int32_t
* as acknowledgement is given in an appropriate manner to its authors,
* with instructions of how to obtain a copy via ftp.
*/
@@ -27,11 +27,11 @@
extern int rdf_errno;
-rdfmodule *rdfload(const char *filename)
+rdfmodule *rdfload(const int8_t *filename)
{
rdfmodule *f;
- long bsslength = 0;
- char *hdr;
+ int32_t bsslength = 0;
+ int8_t *hdr;
rdfheaderrec *r;
f = malloc(sizeof(rdfmodule));
@@ -102,9 +102,9 @@ rdfmodule *rdfload(const char *filename)
rdfheaderrewind(&f->f);
- f->textrel = (long)f->t;
- f->datarel = (long)f->d;
- f->bssrel = (long)f->b;
+ f->textrel = (int32_t)f->t;
+ f->datarel = (int32_t)f->d;
+ f->bssrel = (int32_t)f->b;
return f;
}
@@ -114,8 +114,8 @@ int rdf_relocate(rdfmodule * m)
rdfheaderrec *r;
Collection imports;
symtabEnt e;
- long rel;
- unsigned char *seg;
+ int32_t rel;
+ uint8_t *seg;
rdfheaderrewind(&m->f);
collection_init(&imports);
@@ -150,13 +150,13 @@ int rdf_relocate(rdfmodule * m)
non-portable */
switch (r->r.length) {
case 1:
- seg[r->r.offset] += (char)rel;
+ seg[r->r.offset] += (int8_t)rel;
break;
case 2:
*(uint16 *) (seg + r->r.offset) += (uint16) rel;
break;
case 4:
- *(long *)(seg + r->r.offset) += rel;
+ *(int32_t *)(seg + r->r.offset) += rel;
break;
}
break;
diff --git a/rdoff/rdfload.h b/rdoff/rdfload.h
index 34446b6..11c34f3 100644
--- a/rdoff/rdfload.h
+++ b/rdoff/rdfload.h
@@ -18,14 +18,14 @@
typedef struct RDFModuleStruct {
rdffile f; /* file structure */
- unsigned char *t, *d, *b; /* text, data, and bss segments */
- long textrel;
- long datarel;
- long bssrel;
+ uint8_t *t, *d, *b; /* text, data, and bss segments */
+ int32_t textrel;
+ int32_t datarel;
+ int32_t bssrel;
void *symtab;
} rdfmodule;
-rdfmodule *rdfload(const char *filename);
+rdfmodule *rdfload(const int8_t *filename);
int rdf_relocate(rdfmodule * m);
#endif
diff --git a/rdoff/rdlar.c b/rdoff/rdlar.c
index 53c12c8..dc79368 100644
--- a/rdoff/rdlar.c
+++ b/rdoff/rdlar.c
@@ -22,12 +22,12 @@
typedef enum { FALSE, TRUE } bool;
/** Constants **/
-const char commands[] = "adnrtx";
-const char modifiers[] = "cflouvV";
+const int8_t commands[] = "adnrtx";
+const int8_t modifiers[] = "cflouvV";
/** Global variables **/
-char *progname = "rdlar";
-char **_argv = NULL;
+int8_t *progname = "rdlar";
+int8_t **_argv = NULL;
struct {
bool createok;
bool usefname;
@@ -41,13 +41,13 @@ struct {
#define _ENDIANNESS 0 /* 0 for little, 1 for big */
/*
- * Convert long to little endian (if we were compiled on big-endian machine)
+ * Convert int32_t to little endian (if we were compiled on big-endian machine)
*/
-static void longtolocal(long *l)
+static void int32_ttolocal(int32_t *l)
{
#if _ENDIANNESS
- unsigned char t;
- unsigned char *p = (unsigned char *)l;
+ uint8_t t;
+ uint8_t *p = (uint8_t *)l;
t = p[0];
p[0] = p[3];
@@ -96,7 +96,7 @@ void usage(void)
/*
* Print an error message and exit
*/
-void error_exit(int errcode, bool useperror, const char *fmt, ...)
+void error_exit(int errcode, bool useperror, const int8_t *fmt, ...)
{
va_list ap;
@@ -113,7 +113,7 @@ void error_exit(int errcode, bool useperror, const char *fmt, ...)
/*
* Fill in and write a header
*/
-void put_header(struct rdlm_hdr *hdr, FILE * libfp, char *modname)
+void put_header(struct rdlm_hdr *hdr, FILE * libfp, int8_t *modname)
{
int n = 0;
@@ -128,9 +128,9 @@ void put_header(struct rdlm_hdr *hdr, FILE * libfp, char *modname)
}
/*
- * Copy n bytes from one file to another and return last character read.
+ * Copy n bytes from one file to another and return last int8_tacter read.
*/
-char copybytes(FILE * fp, FILE * fp2, int n)
+int8_t copybytes(FILE * fp, FILE * fp2, int n)
{
int i, t = 0;
@@ -143,18 +143,18 @@ char copybytes(FILE * fp, FILE * fp2, int n)
if (fputc(t, fp2) == EOF)
error_exit(1, FALSE, "write error");
}
- return (char)t;
+ return (int8_t)t;
}
/*
- * Copy unsigned long from one file to another.
- * Return local presentation of long.
+ * Copy uint32_t from one file to another.
+ * Return local presentation of int32_t.
*/
-long copylong(FILE * fp, FILE * fp2)
+int32_t copyint32_t(FILE * fp, FILE * fp2)
{
- long l;
+ int32_t l;
int i, t;
- unsigned char *p = (unsigned char *)&l;
+ uint8_t *p = (uint8_t *)&l;
for (i = 0; i < 4; i++) {
t = fgetc(fp);
@@ -166,14 +166,14 @@ long copylong(FILE * fp, FILE * fp2)
error_exit(1, FALSE, "write error");
*p++ = t;
}
- longtolocal(&l);
+ int32_ttolocal(&l);
return l;
}
/*
* Create a new library
*/
-int create_library(char *libname)
+int create_library(int8_t *libname)
{
FILE *libfp;
struct rdlm_hdr hdr;
@@ -200,7 +200,7 @@ int create_library(char *libname)
/*
* Add a module to the library
*/
-int add_module(FILE * libfp, const char *fname, char *modname)
+int add_module(FILE * libfp, const int8_t *fname, int8_t *modname)
{
FILE *modfp;
struct rdlm_hdr hdr = { RDLMMAG, 0, 0, 0, 0, 0, 0 };
@@ -241,13 +241,13 @@ int add_module(FILE * libfp, const char *fname, char *modname)
/*
* Main
*/
-int main(int argc, char *argv[])
+int main(int argc, int8_t *argv[])
{
FILE *libfp, *tmpfp, *modfp = NULL;
struct stat finfo;
struct rdlm_hdr hdr;
- char buf[MAXMODNAMELEN], *p = NULL;
- char c;
+ int8_t buf[MAXMODNAMELEN], *p = NULL;
+ int8_t c;
int i;
progname = argv[0];
@@ -368,7 +368,7 @@ int main(int argc, char *argv[])
if (options.verbose) {
printf("%ld bytes", hdr.size);
}
- putchar('\n');
+ putint8_t('\n');
}
copybytes(libfp, modfp, hdr.size);
diff --git a/rdoff/rdlar.h b/rdoff/rdlar.h
index bf9e84f..48e3293 100644
--- a/rdoff/rdlar.h
+++ b/rdoff/rdlar.h
@@ -17,13 +17,13 @@
#define MAXMODNAMELEN 256 /* Maximum length of module name */
struct rdlm_hdr {
- unsigned long magic; /* Must be RDLAMAG */
- unsigned long hdrsize; /* Header size + sizeof(module_name) */
- unsigned long date; /* Creation date */
- unsigned long owner; /* UID */
- unsigned long group; /* GID */
- unsigned long mode; /* File mode */
- unsigned long size; /* File size */
+ uint32_t magic; /* Must be RDLAMAG */
+ uint32_t hdrsize; /* Header size + sizeof(module_name) */
+ uint32_t date; /* Creation date */
+ uint32_t owner; /* UID */
+ uint32_t group; /* GID */
+ uint32_t mode; /* File mode */
+ uint32_t size; /* File size */
/* NULL-terminated module name immediately follows */
};
diff --git a/rdoff/rdlib.c b/rdoff/rdlib.c
index 28a2bdf..8f13d1d 100644
--- a/rdoff/rdlib.c
+++ b/rdoff/rdlib.c
@@ -16,19 +16,19 @@
int rdl_error = 0;
-char *rdl_errors[5] = {
+int8_t *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 char *filename)
+int rdl_verify(const int8_t *filename)
{
FILE *fp = fopen(filename, "rb");
- char buf[257];
+ int8_t buf[257];
int i;
- long length;
- static char lastverified[256];
+ int32_t length;
+ static int8_t lastverified[256];
static int lastresult = -1;
if (lastresult != -1 && !strcmp(filename, lastverified))
@@ -51,8 +51,8 @@ int rdl_verify(const char *filename)
/*
* A special module, eg a signature block or a directory.
* Format of such a module is defined to be:
- * six char type identifier
- * long count bytes content
+ * six int8_t type identifier
+ * int32_t count bytes content
* content
* so we can handle it uniformaly with RDOFF2 modules.
*/
@@ -75,7 +75,7 @@ int rdl_verify(const char *filename)
return lastresult = 0; /* library in correct format */
}
-int rdl_open(struct librarynode *lib, const char *name)
+int rdl_open(struct librarynode *lib, const int8_t *name)
{
int i = rdl_verify(name);
if (i)
@@ -95,13 +95,13 @@ void rdl_close(struct librarynode *lib)
free(lib->name);
}
-int rdl_searchlib(struct librarynode *lib, const char *label, rdffile * f)
+int rdl_searchlib(struct librarynode *lib, const int8_t *label, rdffile * f)
{
- char buf[512];
+ int8_t buf[512];
int i, t;
void *hdr;
rdfheaderrec *r;
- long l;
+ int32_t l;
rdl_error = 0;
lib->referenced++;
@@ -182,9 +182,9 @@ int rdl_searchlib(struct librarynode *lib, const char *label, rdffile * f)
int rdl_openmodule(struct librarynode *lib, int moduleno, rdffile * f)
{
- char buf[512];
+ int8_t buf[512];
int i, cmod, t;
- long length;
+ int32_t length;
lib->referenced++;
@@ -251,7 +251,7 @@ int rdl_openmodule(struct librarynode *lib, int moduleno, rdffile * f)
return rdl_error = 4; /* module not found */
}
-void rdl_perror(const char *apname, const char *filename)
+void rdl_perror(const int8_t *apname, const int8_t *filename)
{
if (rdl_error >= 16)
rdfperror(apname, filename);
diff --git a/rdoff/rdlib.h b/rdoff/rdlib.h
index 36438bd..0ca34ae 100644
--- a/rdoff/rdlib.h
+++ b/rdoff/rdlib.h
@@ -3,7 +3,7 @@
*/
struct librarynode {
- char *name;
+ int8_t *name;
FILE *fp; /* initialised to NULL - always check */
int referenced; /* & open if required. Close afterwards */
struct librarynode *next; /* if ! referenced. */
@@ -16,9 +16,9 @@ extern int rdl_error;
#define RDL_EVERSION 3
#define RDL_ENOTFOUND 4
-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_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_openmodule(struct librarynode *lib, int module, rdffile * f);
-void rdl_perror(const char *apname, const char *filename);
+void rdl_perror(const int8_t *apname, const int8_t *filename);
diff --git a/rdoff/rdoff.c b/rdoff/rdoff.c
index 8f19702..9c48278 100644
--- a/rdoff/rdoff.c
+++ b/rdoff/rdoff.c
@@ -5,7 +5,7 @@
* redistributable under the licence given in the file "Licence"
* distributed in the NASM archive.
*
- * Permission to use this file in your own projects is granted, as long
+ * Permission to use this file in your own projects is granted, as int32_t
* as acknowledgement is given in an appropriate manner to its authors,
* with instructions of how to obtain a copy via ftp.
*/
@@ -38,7 +38,7 @@
/* ========================================================================
* Code for memory buffers (for delayed writing of header until we know
- * how long it is).
+ * how int32_t it is).
* ======================================================================== */
memorybuffer *newmembuf()
@@ -57,7 +57,7 @@ memorybuffer *newmembuf()
void membufwrite(memorybuffer * const b, void *data, int bytes)
{
uint16 w;
- long l;
+ int32_t l;
if (b->next) { /* memory buffer full - use next buffer */
membufwrite(b->next, data, bytes);
@@ -76,7 +76,7 @@ void membufwrite(memorybuffer * const b, void *data, int bytes)
switch (bytes) {
case -4: /* convert to little-endian */
- l = *(long *)data;
+ l = *(int32_t *)data;
b->buffer[b->length++] = l & 0xFF;
l >>= 8;
b->buffer[b->length++] = l & 0xFF;
@@ -95,9 +95,9 @@ void membufwrite(memorybuffer * const b, void *data, int bytes)
default:
while (bytes--) {
- b->buffer[b->length++] = *(*(unsigned char **)&data);
+ b->buffer[b->length++] = *(*(uint8_t **)&data);
- (*(unsigned char **)&data)++;
+ (*(uint8_t **)&data)++;
}
break;
}
@@ -133,16 +133,16 @@ void freemembuf(memorybuffer * b)
========================================================================= */
/*
- * translatelong() and translateshort()
+ * translateint32_t() and translateint16_t()
*
* translate from little endian to local representation
*/
-long translatelong(long in)
+int32_t translateint32_t(int32_t in)
{
- long r;
- unsigned char *i;
+ int32_t r;
+ uint8_t *i;
- i = (unsigned char *)&in;
+ i = (uint8_t *)&in;
r = i[3];
r = (r << 8) + i[2];
r = (r << 8) + i[1];
@@ -151,26 +151,26 @@ long translatelong(long in)
return r;
}
-uint16 translateshort(uint16 in)
+uint16 translateint16_t(uint16 in)
{
uint16 r;
- unsigned char *i;
+ uint8_t *i;
- i = (unsigned char *)&in;
+ i = (uint8_t *)&in;
r = (i[1] << 8) + i[0];
return r;
}
/* Segment types */
-static char *knownsegtypes[8] = {
+static int8_t *knownsegtypes[8] = {
"NULL", "text", "data", "object comment",
"linked comment", "loader comment",
"symbolic debug", "line number debug"
};
/* Get a textual string describing the segment type */
-char *translatesegmenttype(uint16 type)
+int8_t *translatesegmenttype(uint16 type)
{
if (type < 8)
return knownsegtypes[type];
@@ -188,10 +188,10 @@ char *translatesegmenttype(uint16 type)
}
/* This signature is written to the start of RDOFF files */
-const char *RDOFFId = RDOFF2_SIGNATURE;
+const int8_t *RDOFFId = RDOFF2_SIGNATURE;
/* Error messages. Must correspond to the codes defined in rdoff.h */
-const char *rdf_errors[11] = {
+const int8_t *rdf_errors[11] = {
/* 0 */ "no error occurred",
/* 1 */ "could not open file",
/* 2 */ "invalid file format",
@@ -211,7 +211,7 @@ int rdf_errno = 0;
The library functions
======================================================================== */
-int rdfopen(rdffile * f, const char *name)
+int rdfopen(rdffile * f, const int8_t *name)
{
FILE *fp;
@@ -222,18 +222,18 @@ int rdfopen(rdffile * f, const char *name)
return rdfopenhere(f, fp, NULL, name);
}
-int rdfopenhere(rdffile * f, FILE * fp, int *refcount, const char *name)
+int rdfopenhere(rdffile * f, FILE * fp, int *refcount, const int8_t *name)
{
- char buf[8];
- long initpos;
- long l;
+ int8_t buf[8];
+ int32_t initpos;
+ int32_t l;
uint16 s;
- if (translatelong(0x01020304) != 0x01020304) {
+ if (translateint32_t(0x01020304) != 0x01020304) {
/* fix this to be portable! */
fputs("*** this program requires a little endian machine\n",
stderr);
- fprintf(stderr, "01020304h = %08lxh\n", translatelong(0x01020304));
+ fprintf(stderr, "01020304h = %08lxh\n", translateint32_t(0x01020304));
exit(3);
}
@@ -257,7 +257,7 @@ int rdfopenhere(rdffile * f, FILE * fp, int *refcount, const char *name)
}
f->header_ofs = ftell(f->fp);
- f->eof_offset = f->header_ofs + translatelong(l) - 4;
+ f->eof_offset = f->header_ofs + translateint32_t(l) - 4;
if (fseek(f->fp, f->header_len, SEEK_CUR)) {
fclose(f->fp);
@@ -321,7 +321,7 @@ int rdfclose(rdffile * f)
/*
* Print the message for last error (from rdf_errno)
*/
-void rdfperror(const char *app, const char *name)
+void rdfperror(const int8_t *app, const int8_t *name)
{
fprintf(stderr, "%s:%s: %s\n", app, name, rdf_errors[rdf_errno]);
if (rdf_errno == RDF_ERR_OPEN || rdf_errno == RDF_ERR_READ) {
@@ -347,7 +347,7 @@ int rdffindsegment(rdffile * f, int segno)
*/
int rdfloadseg(rdffile * f, int segment, void *buffer)
{
- long fpos, slen;
+ int32_t fpos, slen;
switch (segment) {
case RDOFF_HEADER:
@@ -551,7 +551,7 @@ int rdfaddheader(rdf_headerbuf * h, rdfheaderrec * r)
return 0;
}
-int rdfaddsegment(rdf_headerbuf * h, long seglength)
+int rdfaddsegment(rdf_headerbuf * h, int32_t seglength)
{
h->nsegments++;
h->seglength += seglength;
@@ -560,14 +560,14 @@ int rdfaddsegment(rdf_headerbuf * h, long seglength)
int rdfwriteheader(FILE * fp, rdf_headerbuf * h)
{
- long l, l2;
+ int32_t l, l2;
fwrite(RDOFFId, 1, strlen(RDOFFId), fp);
l = membuflength(h->buf);
l2 = l + 14 + 10 * h->nsegments + h->seglength;
- l = translatelong(l);
- l2 = translatelong(l2);
+ l = translateint32_t(l);
+ l2 = translateint32_t(l2);
fwrite(&l2, 4, 1, fp); /* object length */
fwrite(&l, 4, 1, fp); /* header length */
diff --git a/rdoff/rdoff.h b/rdoff/rdoff.h
index 68f156b..248c614 100644
--- a/rdoff/rdoff.h
+++ b/rdoff/rdoff.h
@@ -6,7 +6,7 @@
* redistributable under the licence given in the file "Licence"
* distributed in the NASM archive.
*
- * Permission to use this file in your own projects is granted, as long
+ * Permission to use this file in your own projects is granted, as int32_t
* as acknowledgement is given in an appropriate manner to its authors,
* with instructions of how to obtain a copy via ftp.
*/
@@ -20,9 +20,9 @@
*/
/* Type definitions */
-typedef unsigned long uint32;
-typedef unsigned short uint16;
-typedef unsigned char byte;
+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) */
@@ -54,12 +54,12 @@ typedef unsigned int bool;
/*
* Generic record - contains the type and length field, plus a 128 byte
- * char array 'data'
+ * int8_t array 'data'
*/
struct GenericRec {
byte type;
byte reclen;
- char data[128];
+ int8_t data[128];
};
/*
@@ -71,7 +71,7 @@ struct RelocRec {
byte segment; /* only 0 for code, or 1 for data supported,
but add 64 for relative refs (ie do not require
reloc @ loadtime, only linkage) */
- long offset; /* from start of segment in which reference is loc'd */
+ 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 */
};
@@ -87,7 +87,7 @@ struct ImportRec {
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 */
- char label[EXIM_LABEL_MAX]; /* zero terminated, should be written to file
+ int8_t label[EXIM_LABEL_MAX]; /* zero terminated, should be written to file
until the zero, but not after it */
};
@@ -99,8 +99,8 @@ struct ExportRec {
byte reclen; /* content length */
byte flags; /* SYM_* flags (see below) */
byte segment; /* segment referred to (0/1/2) */
- long offset; /* offset within segment */
- char label[EXIM_LABEL_MAX]; /* zero terminated as in import */
+ int32_t offset; /* offset within segment */
+ int8_t label[EXIM_LABEL_MAX]; /* zero terminated as in import */
};
/*
@@ -109,7 +109,7 @@ struct ExportRec {
struct DLLRec {
byte type; /* must be 4 */
byte reclen; /* content length */
- char libname[MODLIB_NAME_MAX]; /* name of library to link with at load time */
+ int8_t libname[MODLIB_NAME_MAX]; /* name of library to link with at load time */
};
/*
@@ -118,7 +118,7 @@ struct DLLRec {
struct BSSRec {
byte type; /* must be 5 */
byte reclen; /* content length */
- long amount; /* number of bytes BSS to reserve */
+ int32_t amount; /* number of bytes BSS to reserve */
};
/*
@@ -127,7 +127,7 @@ struct BSSRec {
struct ModRec {
byte type; /* must be 8 */
byte reclen; /* content length */
- char modname[MODLIB_NAME_MAX]; /* module name */
+ int8_t modname[MODLIB_NAME_MAX]; /* module name */
};
/*
@@ -137,9 +137,9 @@ struct CommonRec {
byte type; /* must be 10 */
byte reclen; /* equals 7+label length */
uint16 segment; /* segment number */
- long size; /* size of common variable */
+ int32_t size; /* size of common variable */
uint16 align; /* alignment (power of two) */
- char label[EXIM_LABEL_MAX]; /* zero terminated as in import */
+ int8_t label[EXIM_LABEL_MAX]; /* zero terminated as in import */
};
/* Flags for ExportRec */
@@ -154,11 +154,11 @@ struct CommonRec {
/* Some systems don't define this automatically */
#if !defined(strdup)
-extern char *strdup(const char *);
+extern int8_t *strdup(const int8_t *);
#endif
typedef union RDFHeaderRec {
- char type; /* invariant throughout all below */
+ int8_t type; /* invariant throughout all below */
struct GenericRec g; /* type 0 */
struct RelocRec r; /* type == 1 / 6 */
struct ImportRec i; /* type == 2 / 7 */
@@ -174,29 +174,29 @@ struct SegmentHeaderRec {
uint16 type;
uint16 number;
uint16 reserved;
- long length;
+ int32_t length;
/* information built up here */
- long offset;
+ int32_t offset;
byte *data; /* pointer to segment data if it exists in memory */
};
typedef struct RDFFileInfo {
FILE *fp; /* file descriptor; must be open to use this struct */
int rdoff_ver; /* should be 1; any higher => not guaranteed to work */
- long header_len;
- long header_ofs;
+ int32_t header_len;
+ int32_t header_ofs;
byte *header_loc; /* keep location of header */
- long header_fp; /* current location within header for reading */
+ int32_t header_fp; /* current location within header for reading */
struct SegmentHeaderRec seg[RDF_MAXSEGS];
int nsegs;
- long eof_offset; /* offset of the first byte beyond the end of this
+ int32_t eof_offset; /* offset of the first byte beyond the end of this
module */
- char *name; /* name of module in libraries */
+ int8_t *name; /* name of module in libraries */
int *refcount; /* pointer to reference count on file, or NULL */
} rdffile;
@@ -211,7 +211,7 @@ typedef struct memorybuffer {
typedef struct {
memorybuffer *buf; /* buffer containing header records */
int nsegments; /* number of segments to be written */
- long seglength; /* total length of all the segments */
+ int32_t seglength; /* total length of all the segments */
} rdf_headerbuf;
/* segments used by RDOFF, understood by rdoffloadseg */
@@ -241,30 +241,30 @@ enum {
};
/* utility functions */
-long translatelong(long in);
-uint16 translateshort(uint16 in);
-char *translatesegmenttype(uint16 type);
+int32_t translateint32_t(int32_t in);
+uint16 translateint16_t(uint16 in);
+int8_t *translatesegmenttype(uint16 type);
/* RDOFF file manipulation functions */
-int rdfopen(rdffile * f, const char *name);
-int rdfopenhere(rdffile * f, FILE * fp, int *refcount, const char *name);
+int rdfopen(rdffile * f, const int8_t *name);
+int rdfopenhere(rdffile * f, FILE * fp, int *refcount, const int8_t *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 char *app, const char *name);
+void rdfperror(const int8_t *app, const int8_t *name);
/* functions to write a new RDOFF header to a file -
use rdfnewheader to allocate a header, rdfaddheader to add records to it,
rdfaddsegment to notify the header routines that a segment exists, and
- to tell it how long the segment will be.
+ to tell it how int32_t the segment will be.
rdfwriteheader to write the file id, object length, and header
to a file, and then rdfdoneheader to dispose of the header */
rdf_headerbuf *rdfnewheader(void);
int rdfaddheader(rdf_headerbuf * h, rdfheaderrec * r);
-int rdfaddsegment(rdf_headerbuf * h, long seglength);
+int rdfaddsegment(rdf_headerbuf * h, int32_t seglength);
int rdfwriteheader(FILE * fp, rdf_headerbuf * h);
void rdfdoneheader(rdf_headerbuf * h);
diff --git a/rdoff/rdx.c b/rdoff/rdx.c
index 82210a6..0a23941 100644
--- a/rdoff/rdx.c
+++ b/rdoff/rdx.c
@@ -18,9 +18,9 @@
#include "rdfload.h"
#include "symtab.h"
-typedef int (*main_fn) (int, char **); /* Main function prototype */
+typedef int (*main_fn) (int, int8_t **); /* Main function prototype */
-int main(int argc, char **argv)
+int main(int argc, int8_t **argv)
{
rdfmodule *m;
main_fn code;
diff --git a/rdoff/segtab.c b/rdoff/segtab.c
index ed26aea..8ee1b7b 100644
--- a/rdoff/segtab.c
+++ b/rdoff/segtab.c
@@ -5,7 +5,7 @@
struct segtabnode {
int localseg;
int destseg;
- long offset;
+ int32_t offset;
struct segtabnode *left;
struct segtabnode *right;
@@ -36,7 +36,7 @@ void init_seglocations(segtab * root)
}
void descend_tree_add(struct segtabnode **node,
- int localseg, int destseg, long offset)
+ int localseg, int destseg, int32_t offset)
{
struct segtabnode *n;
@@ -83,14 +83,14 @@ void descend_tree_add(struct segtabnode **node,
}
}
-void add_seglocation(segtab * root, int localseg, int destseg, long offset)
+void add_seglocation(segtab * root, int localseg, int destseg, int32_t offset)
{
descend_tree_add((struct segtabnode **)root, localseg, destseg,
offset);
}
int get_seglocation(segtab * root, int localseg, int *destseg,
- long *offset)
+ int32_t *offset)
{
struct segtabnode *n = (struct segtabnode *)*root;
diff --git a/rdoff/segtab.h b/rdoff/segtab.h
index bd29357..14cb600 100644
--- a/rdoff/segtab.h
+++ b/rdoff/segtab.h
@@ -1,6 +1,6 @@
typedef void *segtab;
void init_seglocations(segtab * r);
-void add_seglocation(segtab * r, int localseg, int destseg, long offset);
-int get_seglocation(segtab * r, int localseg, int *destseg, long *offset);
+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);
diff --git a/rdoff/symtab.c b/rdoff/symtab.c
index 8d8ac62..d05cf18 100644
--- a/rdoff/symtab.c
+++ b/rdoff/symtab.c
@@ -82,7 +82,7 @@ void symtabInsert(void *stab, symtabEnt * ent)
}
/* ------------------------------------- */
-symtabEnt *symtabFind(void *stab, const char *name)
+symtabEnt *symtabFind(void *stab, const int8_t *name)
{
symtab mytab = (symtab) stab;
int slot = slotnum(name);
@@ -103,7 +103,7 @@ void symtabDump(void *stab, FILE * of)
{
symtab mytab = (symtab) stab;
int i;
- char *SegNames[3] = { "code", "data", "bss" };
+ int8_t *SegNames[3] = { "code", "data", "bss" };
fprintf(of, "Symbol table is ...\n");
for (i = 0; i < SYMTABSIZE; ++i) {
diff --git a/rdoff/symtab.h b/rdoff/symtab.h
index 5bd9bcb..170f328 100644
--- a/rdoff/symtab.h
+++ b/rdoff/symtab.h
@@ -7,14 +7,14 @@
*/
typedef struct {
- char *name;
+ int8_t *name;
int segment;
- long offset;
- long flags;
+ int32_t offset;
+ int32_t flags;
} symtabEnt;
void *symtabNew(void);
void symtabDone(void *symtab);
void symtabInsert(void *symtab, symtabEnt * ent);
-symtabEnt *symtabFind(void *symtab, const char *name);
+symtabEnt *symtabFind(void *symtab, const int8_t *name);
void symtabDump(void *symtab, FILE * of);