PRIVATE int outfd; /* output file descriptor */
PRIVATE mode_t outputperms; /* permissions of output file */
PRIVATE char *outputname; /* name of output file */
-PRIVATE char *refname; /* name of program for error reference */
+PRIVATE const char *refname; /* name of program for error reference */
#ifdef REL_OUTPUT
PRIVATE char *trelbuf; /* extra output buffer for text relocations */
PRIVATE char *trelbufptr; /* text relocation output buffer ptr */
FORWARD void outhexdigs P((bin_off_t num));
FORWARD void outputerror P((char *message));
FORWARD void put04x P((unsigned num));
-FORWARD void putstrn P((char *message));
+FORWARD void putstrn P((const char *message));
FORWARD void refer P((void));
FORWARD void stderr_out P((void));
-PUBLIC void ioinit(progname)
-char *progname;
+PUBLIC void ioinit(char *progname)
{
infd = ERR;
if (*progname)
#endif
}
-PUBLIC void closein()
+PUBLIC void closein(void)
{
if (infd != ERR && close(infd) < 0)
inputerror("cannot close");
#endif
}
-PUBLIC void errtrace(name, level)
-char *name;
-int level;
+PUBLIC void errtrace(char *name, int level)
{
while (level-- > 0)
putbyte(' ');
putstrn(name);
}
-PUBLIC void executable()
+PUBLIC void executable(void)
{
if (errcount)
unlink(outputname);
#endif
}
-PUBLIC void flusherr()
+PUBLIC void flusherr(void)
{
if( errbufptr != errbuf )
write(errfil, errbuf, (unsigned) (errbufptr - errbuf));
errbufptr = errbuf;
}
-PRIVATE void stderr_out()
+PRIVATE void stderr_out(void)
{
if( errfil != STDERR_FILENO )
{
}
}
-PRIVATE void flushout()
+PRIVATE void flushout(void)
{
unsigned nbytes;
}
#ifdef REL_OUTPUT
-PRIVATE void flushtrel()
+PRIVATE void flushtrel(void)
{
unsigned nbytes;
}
#endif
-PUBLIC void openin(filename)
-char *filename;
+PUBLIC void openin(char *filename)
{
#if 0 /* XXX - this probably won't work with constructed lib names? */
if (infd == ERR || strcmp(inputname, filename) != 0)
}
}
-PUBLIC void openout(filename)
-char *filename;
+PUBLIC void openout(char *filename)
{
mode_t oldmask;
#endif
}
-PRIVATE void outhexdigs(num)
-register bin_off_t num;
+PRIVATE void outhexdigs(bin_off_t num)
{
if (num >= 0x10)
{
putbyte(hexdigit[num]);
}
-PRIVATE void put04x(num)
-register unsigned num;
+PRIVATE void put04x(unsigned num)
{
putbyte(hexdigit[num / 0x1000]);
putbyte(hexdigit[(num / 0x100) & 0x0F]);
#ifdef LONG_OFFSETS
-PUBLIC void put08lx(num)
-register bin_off_t num;
+PUBLIC void put08lx(bin_off_t num)
{
put04x(num / 0x10000);
put04x(num % 0x10000);
#else /* not LONG_OFFSETS */
-PUBLIC void put08x(num)
-register bin_off_t num;
+PUBLIC void put08x(bin_off_t num)
{
putstr("0000");
put04x(num);
#endif /* not LONG_OFFSETS */
-PUBLIC void putbstr(width, str)
-unsigned width;
-char *str;
+PUBLIC void putbstr(unsigned width, char *str)
{
unsigned length;
putstr(str);
}
-PUBLIC void putbyte(ch)
-int ch;
+PUBLIC void putbyte(int ch)
{
register char *ebuf;
errbufptr = ebuf;
}
-PUBLIC void putstr(message)
-char *message;
+PUBLIC void putstr(const char *message)
{
while (*message != 0)
putbyte(*message++);
}
-PRIVATE void putstrn(message)
-char *message;
+PRIVATE void putstrn(char *message)
{
putstr(message);
putbyte('\n');
flusherr(); errfil = STDOUT_FILENO;
}
-PUBLIC int readchar()
+PUBLIC int readchar(void)
{
int ch;
return ch;
}
-PUBLIC void readin(buf, count)
-char *buf;
-unsigned count;
+PUBLIC void readin(char *buf, unsigned count)
{
int ch;
}
}
-PUBLIC bool_pt readineofok(buf, count)
-char *buf;
-unsigned count;
+PUBLIC bool_pt readineofok(char *buf, unsigned count)
{
int ch;
return FALSE;
}
-PUBLIC void seekin(offset)
-unsigned long offset;
+PUBLIC void seekin(unsigned long offset)
{
inbufptr = inbufend = inbuf;
if (lseek(infd, (off_t) offset, SEEK_SET) != offset)
prematureeof();
}
-PUBLIC void seekout(offset)
-unsigned long offset;
+PUBLIC void seekout(unsigned long offset)
{
flushout();
if (lseek(outfd, (off_t) offset, SEEK_SET) != offset)
}
#ifdef REL_OUTPUT
-PUBLIC void seektrel(offset)
-unsigned long offset;
+PUBLIC void seektrel(unsigned long offset)
{
flushtrel();
if (lseek(trelfd, (off_t) offset, SEEK_SET) != offset)
}
#endif
-PUBLIC void writechar(ch)
-int ch;
+PUBLIC void writechar(int ch)
{
register char *obuf;
}
#ifdef REL_OUTPUT
-PUBLIC void writedrel(buf, count)
-register char *buf;
-unsigned count;
+PUBLIC void writedrel(char *buf, unsigned count)
{
register char *rbuf;
}
#endif
-PUBLIC void writeout(buf, count)
-register char *buf;
-unsigned count;
+PUBLIC void writeout(char *buf, unsigned count)
{
register char *obuf;
}
#ifdef REL_OUTPUT
-PUBLIC void writetrel(buf, count)
-register char *buf;
-unsigned count;
+PUBLIC void writetrel(char *buf, unsigned count)
{
register char *rbuf;
/* error module */
-PRIVATE void errexit(message)
-char *message;
+PRIVATE void errexit(char *message)
{
putstrn(message);
exit(2);
}
-PUBLIC void fatalerror(message)
-char *message;
+PUBLIC void fatalerror(char *message)
{
refer();
errexit(message);
}
-PUBLIC void inputerror(message)
-char *message;
+PUBLIC void inputerror(char *message)
{
refer();
putstr(message);
errexit(inputname);
}
-PUBLIC void input1error(message)
-char *message;
+PUBLIC void input1error(char *message)
{
refer();
putstr(inputname);
errexit(message);
}
-PRIVATE void outputerror(message)
-char *message;
+PRIVATE void outputerror(char *message)
{
refer();
putstr(message);
errexit(outputname);
}
-PUBLIC void outofmemory()
+PUBLIC void outofmemory(void)
{
inputerror("out of memory while processing");
}
-PUBLIC void prematureeof()
+PUBLIC void prematureeof(void)
{
inputerror("premature end of");
}
-PUBLIC void redefined(name, message, archentry, deffilename, defarchentry)
-char *name;
-char *message;
-char *archentry;
-char *deffilename;
-char *defarchentry;
+PUBLIC void redefined(char *name, char *message, char *archentry,
+ char *deffilename, char *defarchentry)
{
++warncount;
refer();
putstrn("");
}
-PUBLIC void interseg(fname, aname, name)
-char *fname, *aname, *name;
+PUBLIC void interseg(char *fname, char *aname, char *name)
{
++errcount;
refer();
putstrn("");
}
-PRIVATE void refer()
+PRIVATE void refer(void)
{
stderr_out();
putstr(refname);
putstr(": ");
}
-PUBLIC void reserved(name)
-char *name;
+PUBLIC void reserved(char *name)
{
++errcount;
stderr_out();
putstrn(name);
}
-PUBLIC void size_error(seg, count, size)
-int seg;
-bin_off_t count;
-bin_off_t size;
+PUBLIC void size_error(int seg, bin_off_t count, bin_off_t size)
{
refer();
putstr("seg ");
errexit("");
}
-PUBLIC void undefined(name)
-char *name;
+PUBLIC void undefined(char *name)
{
++errcount;
stderr_out();
putstrn(name);
}
-PUBLIC void usage()
+PUBLIC void usage(void)
{
stderr_out();
putstr("usage: ");
#endif
}
-PUBLIC void version_msg()
+PUBLIC void version_msg(void)
{
stderr_out();
#ifdef VERSION
#endif
}
-PUBLIC void use_error(message)
-char *message;
+PUBLIC void use_error(char *message)
{
refer();
putstrn(message);
FORWARD char *buildname P((char *pre, char *mid, char *suf));
FORWARD char *expandlib P((char *fn));
-PRIVATE char *buildname(pre, mid, suf)
-char *pre;
-char *mid;
-char *suf;
+PRIVATE char *buildname(char *pre, char *mid, char *suf)
{
char *name;
return name;
}
-PRIVATE char *expandlib(fn)
-char *fn;
+PRIVATE char *expandlib(char *fn)
{
char *path, *s;
int i;
return NUL_PTR;
}
-PUBLIC int main(argc, argv)
-int argc;
-char **argv;
+PUBLIC int main(int argc, char **argv)
{
register char *arg;
int argn;
/* link all symbols connected to entry symbols */
-PUBLIC void linksyms(argreloc_output)
-bool_pt argreloc_output;
+PUBLIC void linksyms(bool_pt argreloc_output)
{
char needlink;
struct entrylist *elptr;
while (needlink);
}
-PRIVATE void linkrefs(modptr)
-struct modstruct *modptr;
+PRIVATE void linkrefs(struct modstruct *modptr)
{
register struct symstruct **symparray;
register struct symstruct *symptr;
#ifndef __OUT_OK
-main()
+int main(int argc, char *argv[])
{
fprintf(stderr, "Compile error: struct exec invalid\n");
exit(1);
FILE * ifd;
struct exec header;
-main(argc, argv)
-int argc;
-char ** argv;
+void fatal(const char * str)
+{
+ fprintf(stderr, "objchop: %s\n", str);
+ exit(2);
+}
+
+int write_file(char *fname, long bsize)
+{
+ char buffer[1024];
+ int ssize;
+ FILE * ofd;
+
+ ofd = fopen(fname, "w");
+ if( ofd == 0 ) fatal("Cannot open output file");
+
+ while(bsize>0)
+ {
+ if( bsize > sizeof(buffer) ) ssize = sizeof(buffer);
+ else ssize = bsize;
+
+ if( (ssize=fread(buffer, 1, ssize, ifd)) <= 0 )
+ fatal("Error reading segment from executable");
+ if( fwrite(buffer, 1, ssize, ofd) != ssize )
+ fatal("Error writing output file");
+ bsize -= ssize;
+ }
+ fclose(ofd);
+}
+
+int main(int argc, char **argv)
{
FILE * ofd;
if( argc != 5 ) fatal("Usage: objchop a.out text.bin data.bin sizes.asm");
exit(0);
}
-write_file(fname, bsize)
-char * fname;
-long bsize;
-{
- char buffer[1024];
- int ssize;
- FILE * ofd;
-
- ofd = fopen(fname, "w");
- if( ofd == 0 ) fatal("Cannot open output file");
-
- while(bsize>0)
- {
- if( bsize > sizeof(buffer) ) ssize = sizeof(buffer);
- else ssize = bsize;
-
- if( (ssize=fread(buffer, 1, ssize, ifd)) <= 0 )
- fatal("Error reading segment from executable");
- if( fwrite(buffer, 1, ssize, ofd) != ssize )
- fatal("Error writing output file");
- bsize -= ssize;
- }
- fclose(ofd);
-}
-
-fatal(str)
-char * str;
-{
- fprintf(stderr, "objchop: %s\n", str);
- exit(2);
-}
-
#endif
/* initialise object file handler */
-PUBLIC void objinit()
+PUBLIC void objinit(void)
{
modfirst = modlast = NUL_PTR;
entryfirst = entrylast = NUL_PTR;
/* read all symbol definitions in an object file */
-PUBLIC void readsyms(filename, trace)
-char *filename;
-bool_pt trace;
+PUBLIC void readsyms(char *filename, bool_pt trace)
{
char *archentry;
long filelength;
/* read archive header and return length */
-PRIVATE long readarheader(parchentry)
-char **parchentry;
+PRIVATE long readarheader(char **parchentry)
{
struct ar_hdr arheader;
char *endptr;
/* read and check file header of the object file just opened */
-PRIVATE unsigned readfileheader()
+PRIVATE unsigned readfileheader(void)
{
struct
{
/* read the next module */
-PRIVATE void readmodule(filename, archentry)
-char *filename;
-char *archentry;
+PRIVATE void readmodule(char *filename, char *archentry)
{
struct symdstruct /* to save parts of symbol before name known */
{
/* put symbol on entry symbol list if it is not already */
-PUBLIC void entrysym(symptr)
-struct symstruct *symptr;
+PUBLIC void entrysym(struct symstruct *symptr)
{
register struct entrylist *elptr;
/* read the header of the next module */
-PRIVATE void reedmodheader()
+PRIVATE void reedmodheader(void)
{
struct
{
modlast = modptr;
}
-PRIVATE bool_pt redsym(symptr, value)
-register struct symstruct *symptr;
-bin_off_t value;
+PRIVATE bool_pt redsym(struct symstruct *symptr, bin_off_t value)
{
register struct redlist *rlptr;
char class;
return TRUE;
}
-PRIVATE unsigned checksum(string, length)
-char *string;
-unsigned length;
+PRIVATE unsigned checksum(char *string, unsigned length)
{
unsigned char sum; /* this is a 1-byte checksum */
return sum;
}
-PUBLIC bin_off_t readconvsize(countindex)
-unsigned countindex;
+PUBLIC bin_off_t readconvsize(unsigned countindex)
{
return readsize(convertsize[countindex]);
}
-PUBLIC bin_off_t readsize(count)
-unsigned count;
+PUBLIC bin_off_t readsize(unsigned count)
{
char buf[MAX_OFFSET_SIZE];
return cntooffset(buf, count);
}
-PRIVATE unsigned segbits(seg, sizedesc)
-unsigned seg;
-char *sizedesc;
+PRIVATE unsigned segbits(unsigned seg, char *sizedesc)
{
return 3 & ((unsigned) sizedesc[((NSEG - 1) - seg) / 4] >> (2 * (seg % 4)));
/* unsigned to give logical shift */
}
-PUBLIC unsigned segsizecount(seg, modptr)
-unsigned seg;
-struct modstruct *modptr;
+PUBLIC unsigned segsizecount(unsigned seg, struct modstruct *modptr)
{
return convertsize[segbits(seg, modptr->segsizedesc)];
}
/* initialise symbol table */
-PUBLIC void syminit()
+PUBLIC void syminit(void)
{
unsigned i;
/* add named symbol to end of table - initialise only name and next fields */
/* caller must not duplicate names of externals for findsym() to work */
-PUBLIC struct symstruct *addsym(name)
-char *name;
+PUBLIC struct symstruct *addsym(char *name)
{
struct symstruct **hashptr;
struct symstruct *oldsymptr = 0;
/* lookup named symbol */
-PUBLIC struct symstruct *findsym(name)
-char *name;
+PUBLIC struct symstruct *findsym(char *name)
{
struct symstruct *symptr;
/* convert name to a hash table ptr */
-PRIVATE struct symstruct **gethashptr(name)
-register char *name;
+PRIVATE struct symstruct **gethashptr(char *name)
{
register unsigned hashval;
/* move symbol descriptor entries to top of table (no error checking) */
-PUBLIC char *moveup(nbytes)
-unsigned nbytes;
+PUBLIC char *moveup(unsigned nbytes)
{
register char *source;
register char *target;
/* our version of malloc */
-PUBLIC char *ourmalloc(nbytes)
-unsigned nbytes;
+PUBLIC char *ourmalloc(unsigned nbytes)
{
char *allocptr;
/* our version of free (release from bottom of table) */
-PUBLIC void ourfree(cptr)
-char *cptr;
+PUBLIC void ourfree(char *cptr)
{
check_used();
tableptr = cptr;
/* read string from file into table at offset suitable for next symbol */
-PUBLIC char *readstring()
+PUBLIC char *readstring(void)
{
int c;
char *s;
/* release from top of table */
-PUBLIC void release(cptr)
-char *cptr;
+PUBLIC void release(char *cptr)
{
check_used();
mainavail += cptr - tableend;
tableend = cptr;
}
-PRIVATE void check_used()
+PRIVATE void check_used(void)
{
int used;
if (used > maxused) maxused = used;
}
-PUBLIC int memory_used()
+PUBLIC int memory_used(void)
{
check_used();
return maxused;
/* allocate space for string */
-PUBLIC char *stralloc(s)
-char *s;
+PUBLIC char *stralloc(char *s)
{
return strcpy(ourmalloc((unsigned) strlen(s) + 1), s);
}
#include "type.h"
#include "globvar.h"
-void xxerr P((char *));
-void xxerr(x) char * x; { write(2, x, strlen(x)); }
+void xxerr(char *x)
+{
+ write(2, x, strlen(x));
+}
static int no_swap = 1;
static int long_off[4] = {0,1,2,3};
static int int_off[2] = {0,1};
-PUBLIC bool_pt typeconv_init(big_endian, long_big_endian)
-bool_pt big_endian;
-bool_pt long_big_endian;
+PUBLIC bool_pt typeconv_init(bool_pt big_endian, bool_pt long_big_endian)
{
int i;
no_swap = (!big_endian && !long_big_endian);
return 1;
}
-PUBLIC void u2c2(buf, offset)
-char *buf;
-u2_pt offset;
+PUBLIC void u2c2(char *buf, u2_pt offset)
{
#ifdef __AS386_16__
if( no_swap )
buf[int_off[1]] = (offset>>8);
}
-PUBLIC void u4c4(buf, offset)
-char *buf;
-u4_t offset;
+PUBLIC void u4c4(char *buf, u4_t offset)
{
int i;
#ifdef __AS386_16__
}
}
-PUBLIC void u4cn(buf, offset, count)
-char *buf;
-u4_t offset;
-unsigned count;
+PUBLIC void u4cn(char *buf, u4_t offset, unsigned count)
{
switch(count)
{
}
}
-PUBLIC void u2cn(buf, offset, count)
-char *buf;
-u2_pt offset;
-unsigned count;
+PUBLIC void u2cn(char *buf, u2_pt offset, unsigned count)
{
switch(count)
{
}
}
-PUBLIC u2_pt c2u2(buf)
-char *buf;
+PUBLIC u2_pt c2u2(char *buf)
{
u2_pt res;
#ifdef __AS386_16__
return res;
}
-PUBLIC u4_t c4u4(buf)
-char *buf;
+PUBLIC u4_t c4u4(char *buf)
{
u4_t res;
int i;
return res;
}
-PUBLIC u4_t cnu4(buf, count)
-char *buf;
-unsigned count;
+PUBLIC u4_t cnu4(char *buf, unsigned count)
{
switch (count)
{
}
}
-PUBLIC u2_pt cnu2(buf, count)
-char *buf;
-unsigned count;
+PUBLIC u2_pt cnu2(char *buf, unsigned count)
{
switch (count)
{
#define FUNCNAME writebin
#endif
-PUBLIC void FUNCNAME(outfilename, argsepid, argbits32, argstripflag, arguzp)
-char *outfilename;
-bool_pt argsepid;
-bool_pt argbits32;
-bool_pt argstripflag;
-bool_pt arguzp;
+PUBLIC void FUNCNAME(char *outfilename, bool_pt argsepid, bool_pt argbits32,
+ bool_pt argstripflag, bool_pt arguzp)
{
char buf4[4];
#ifdef EDOS
#ifdef EDOS
-PRIVATE unsigned binheaderlength(commandname)
-char *commandname;
+PRIVATE unsigned binheaderlength(char *commandname)
{
unsigned count;
char *name;
/* the special name _main is converted to the command name first */
/* copy upper case and numerals, convert lower case to upper, ignore rest */
-PRIVATE char *idconvert(elptr, commandname)
-struct entrylist *elptr;
-char *commandname;
+PRIVATE char *idconvert(struct entrylist *elptr, char *commandname)
{
char *name;
char *newname;
#endif /* EDOS */
-PRIVATE void linkmod(modptr)
-struct modstruct *modptr;
+PRIVATE void linkmod(struct modstruct *modptr)
{
char buf[ABS_TEXT_MAX];
int command;
}
}
-PRIVATE void padmod(modptr)
-struct modstruct *modptr;
+PRIVATE void padmod(struct modstruct *modptr)
{
bin_off_t count;
fastin_t seg;
}
}
-PRIVATE void setsym(name, value)
-char *name;
-bin_off_t value;
+PRIVATE void setsym(char *name, bin_off_t value)
{
struct symstruct *symptr;
symptr->value = value;
}
-PRIVATE void symres(name)
-register char *name;
+PRIVATE void symres(char *name)
{
register struct symstruct *symptr;
/* set new segment */
-PRIVATE void setseg(newseg)
-fastin_pt newseg;
+PRIVATE void setseg(fastin_pt newseg)
{
if (newseg != curseg)
{
}
}
-PRIVATE void skip(countsize)
-unsigned countsize;
+PRIVATE void skip(unsigned countsize)
{
writenulls((bin_off_t) readsize(countsize));
}
#ifdef EDOS
-PRIVATE void writeheader(commandname)
-char *commandname;
+PRIVATE void writeheader(char *commandname)
{
char buf[MAX_OFFSET_SIZE];
bin_off_t offset;
#ifdef MINIX
-PRIVATE void writeheader()
+PRIVATE void writeheader(void)
{
struct exec header;
#endif /* MINIX */
-PRIVATE void writenulls(count)
-bin_off_t count;
+PRIVATE void writenulls(bin_off_t count)
{
long lcount = count;
if( lcount < 0 )
#define FUNCNAME writebin
#endif
-PUBLIC void FUNCNAME(outfilename, argsepid, argbits32, argstripflag, arguzp)
-char *outfilename;
-bool_pt argsepid;
-bool_pt argbits32;
-bool_pt argstripflag;
-bool_pt arguzp;
+PUBLIC void FUNCNAME(char *outfilename, bool_pt argsepid, bool_pt argbits32,
+ bool_pt argstripflag, bool_pt arguzp)
{
char * s = "WARNING: Native a.out generation not included, sorry\n";
write(2, s, strlen(s));