diff -Nurd linux86.old/Changes linux86/Changes --- linux86.old/Changes Sun Nov 2 08:16:51 2003 +++ linux86/Changes Sat Jan 24 14:41:13 2004 @@ -1,5 +1,32 @@ For version 0.16.*. +> WARNING to distributions: I've altered the install scripts and paths + you will want to check them. Altered paths for bcc.c and normal + installs, defaults should now be good for distributions where bcc is a + cross compiler. If you set the PREFIX to / it'll install to suggested + Native paths. As86_encap moved to LIBDIR. + +> I've altered 'perror' and 'strerror' to be normal when compiled for + everything except libc_f.a. Only that library it look for the + liberror.txt file and it now looks in "/lib/liberror.txt". + This means there's no need to install it anywhere except ELKS itself. + +> Change -Mg option to use uclibc as glibc2 seems to have stopped working. + +> ar.c switch to usnig strerror. + +> Move elksemu, it's used like a shared library but is best treated like + an emulator so it's now installed in DISTBIN. Also on Linux-386 it's + compiled using the system compiler. + +> Use the POSIX -R argument to cp rather than the normal standard -r because + some new systems have decided to stop supporting their '-r' option. + +> Oops, the constant error strings in the assembler were char pointers not + char arrays, small waste of space. + +> Allow for Linux-2.6 32bit dev_t. + > More changes so it compiles better on 'other' machines. Removed some GNU-Make'isms in the top header file. diff -Nurd linux86.old/Makefile linux86/Makefile --- linux86.old/Makefile Sat Sep 20 18:47:54 2003 +++ linux86/Makefile Sat Jan 24 12:12:14 2004 @@ -2,20 +2,22 @@ # This file is part of the Linux-8086 Development environment and is # distributed under the GNU General Public License. -VERSION=0.16.14 +VERSION=0.16.15 -TARGETS= \ - clean bcc unproto copt as86 ld86 elksemu \ - install install-all install-bcc install-emu install-lib \ +TARGETS=install clean other \ + bcc unproto copt as86 ld86 elksemu \ + install-all install-bcc install-emu install-lib \ install-lib2 install-ln install-man install-other \ all-libs alt-libs library lib-386 lib-bsd lib-dos lib-fast lib-stand \ - config other tests dis88 doselks bootblocks ld86r + config tests dis88 doselks bootblocks ld86r ELKSSRC= /usr/src/elks PREFIX= /usr -LIBPRE= $(PREFIX)/bcc BINDIR= $(PREFIX)/bin -LIBDIR= $(LIBPRE)/lib/bcc +LIBDIR= $(PREFIX)/lib/bcc +INCLDIR= $(PREFIX)/lib/bcc +ASLDDIR= $(BINDIR) +MANDIR= $(PREFIX)/man CFLAGS= -O # Some makes take the last of a list as the default ... @@ -36,18 +38,25 @@ make.fil: ifdef makefile.in ./ifdef -MU makefile.in >tmp.mak - sed \ - -e "s:%PREFIX%:$(PREFIX):" \ - -e "s:%LIBPRE%:$(LIBPRE):" \ - -e "s:%BINDIR%:$(BINDIR):" \ - -e "s:%LIBDIR%:$(LIBDIR):" \ - -e "s:%ELKSSRC%:$(ELKSSRC):" \ - -e "s:%CC%:$(CC):" \ - -e "s:%CFLAGS%:$(CFLAGS):" \ - -e "s:%LDFLAGS%:$(LDFLAGS):" \ - < tmp.mak > make.tmp + echo > tmp.sed + [ "$(BINDIR)" != "//bin" ] || echo >> tmp.sed "s:%BINDIR%:/bin:" + [ "$(LIBDIR)" != "//lib/bcc" ] || echo >> tmp.sed "s:%LIBDIR%:/lib:" + [ "$(INCLDIR)" != "//lib/bcc" ] || echo >> tmp.sed "s:%INCLDIR%:/usr:" + [ "$(ASLDDIR)" != "//bin" ] || echo >> tmp.sed "s:%ASLDDIR%:/bin:" + [ "$(MANDIR)" != "//man" ] || echo >> tmp.sed "s:%MANDIR%:/usr/man:" + echo >> tmp.sed "s:%PREFIX%:$(PREFIX):" + echo >> tmp.sed "s:%BINDIR%:$(BINDIR):" + echo >> tmp.sed "s:%INCLDIR%:$(INCLDIR):" + echo >> tmp.sed "s:%LIBDIR%:$(LIBDIR):" + echo >> tmp.sed "s:%ASLDDIR%:$(ASLDDIR):" + echo >> tmp.sed "s:%MANDIR%:$(MANDIR):" + echo >> tmp.sed "s:%ELKSSRC%:$(ELKSSRC):" + echo >> tmp.sed "s:%CC%:$(CC):" + echo >> tmp.sed "s:%CFLAGS%:$(CFLAGS):" + echo >> tmp.sed "s:%LDFLAGS%:$(LDFLAGS):" + sed -f tmp.sed < tmp.mak > make.tmp mv -f make.tmp make.fil - @rm -f tmp.mak + @rm -f tmp.mak tmp.sed ifdef: ifdef.o $(CC) $(LDFLAGS) -o ifdef ifdef.o @@ -55,22 +64,9 @@ ifdef.o: ifdef.c $(CC) $(CFLAGS) $(IFDEFFLAGS) -c ifdef.c -Uninstall: - @# CHECK FROM HERE - @make -n Uninstall - @echo 'Are you really sure... have you checked this...' - @echo "I haven't used this in _years_ ... ^C to interrupt" - @read line - rm -rf /usr/bcc - rm -f $(BINDIR)/bcc $(BINDIR)/as86_encap $(BINDIR)/dis86 - rm -f $(BINDIR)/as86 $(BINDIR)/ld86 - rm -f $(BINDIR)/objdump86 $(BINDIR)/nm86 $(BINDIR)/size86 - rm -f /lib/elksemu - rm -f /usr/lib/liberror.txt - rm -f /usr/man/man1/elks.1* /usr/man/man1/elksemu.1* - rm -f /usr/man/man1/dis86.1* /usr/man/man1/bcc.1* - rm -f /usr/man/man1/as86.1* /usr/man/man1/ld86.1* - @# TO HERE +uninstall: + @echo 'Sorry, no go; it was just wrong.' + false distribution: @[ `id -u` -eq 0 ] || fakeroot -- sh ./Mk_dist $(VERSION) diff -Nurd linux86.old/Mk_dist linux86/Mk_dist --- linux86.old/Mk_dist Sun Aug 31 14:48:32 2003 +++ linux86/Mk_dist Sat Jan 24 14:33:15 2004 @@ -62,7 +62,7 @@ ( cd ${TMPDIST}/doselks ; tar xzf /tmp/doselks.tar.gz ) [ "`id -un`" = "root" ] && { - chown -R root:root ${TMPDIST} + chown -R root:0 ${TMPDIST} chmod -R og=u-w ${TMPDIST} } @@ -193,7 +193,9 @@ cd ${TMPDIR} || exit 1 mkdir -p ${TMPDIST}.ins -make -C ${TMPDIST} install ARFLAGS=q DIST=${TMPDIST}.ins ELKSSRC=/dev/null || +make -C ${TMPDIST} install install-other \ + ARFLAGS=q ELKSSRC=/dev/null \ + DIST=${TMPDIST}.ins 'ASLDDIR=$(BINDIR)' || exit make -C ${TMPDIST} other || exit tar cf ${ARCDIR}/Dev86bin-$VERSION.tar -C ${TMPDIST}.ins . diff -Nurd linux86.old/README linux86/README --- linux86.old/README Tue Jul 23 08:46:14 2002 +++ linux86/README Sat Jan 24 12:44:51 2004 @@ -18,22 +18,41 @@ there are also some hints for using as86 well. The tests and bootblocks directories give some example code. -The bcc command defaults to using /usr/bcc/include and /usr/bcc/lib/bcc +The bcc command defaults to using /usr/lib/bcc/include and /usr/lib/bcc the libraries _and_ include files are copied to these locations by -install. This can be changed by overriding 'PREFIX=/usr' or -'LIBDIR=/usr/bcc/lib/bcc' on the initial make. Also available in the -same way the 'ELKSSRC=/usr/src/elks' variable can be altered if you -have ELKS on a different path. +install. This can be changed by overriding 'PREFIX=/usr/...' or +'LIBDIR=/usr/...' on the initial make. Also available in the +same way are the BINDIR, INCLDIR, ASLDDIR, MANDIR and ELSESRC. +The 'ELKSSRC=/usr/src/elks' variable can be altered if you have ELKS on +path different from the default or ELKSSRC=/dev/null uses the supplied +ELKS headers. The ASLDDIR variable can be used to move as86 and ld86 +into the LIBDIR with 'ASLDDIR=$(LIBDIR)'. The final '/include' is added +to the end of INCLDIR. In the unlikely event you're makeing a non-cross development environment -you can, on the initial make, do "make LIBPRE=/usr' to have the libraries -and include files directly under /usr rather than /usr/bcc. +you can, on the initial make, do "make PREFIX=/' to have the libraries +and include files in 'Native' locations. Note: These prefix options only effect the 'bcc.c' driver program and the install scripts, all the others get their paths from bcc.c. The ELKSSRC location can, however, greatly effect how the ELKS libraries are built. +If you don't want to install in the locations specified above there +is also a DIST= argument to make install that is used to specify the +distribution root to install to. + +The last option is not to install at all. All the executables in the +bin directory can be moved to whereever you wish except for bcc and ncc. +To use bcc at any other location you can create a symlink from your +new location to the 'ncc' executable and it will be able to find +the libraries in the build directory: + +eg: + cp ar86 elksemu objdump86 $HOME/bin/. + cp as86 as86_encap ld86 $HOME/bin/. # Optional. + ln -s `pwd`/ncc $HOME/bin/bcc + All the versions of the library are built by make; 'normal', 'fast', 'MSDOS', 'standalone' and Linux-i386. @@ -76,10 +95,10 @@ a post 2.1.43 or 2.0.36 kernel the only module you need is the binfmt_misc driver configured like this: -echo ':i86-elks:M::\x01\x03\x20\x00:\xff\xff\xff\x83:/lib/elksemu:' \ +echo ':i86-elks:M::\x01\x03\x20\x00:\xff\xff\xff\x83:/usr/bin/elksemu:' \ > /proc/sys/fs/binfmt_misc/register -The elksemu executable must be stored in /lib/elksemu or the above +The elksemu executable must be stored in /usr/bin/elksemu or the above line adjusted. Previous versions need a special module or patch described in elksemu/README diff -Nurd linux86.old/ar/ar.c linux86/ar/ar.c --- linux86.old/ar/ar.c Tue Oct 7 22:31:59 2003 +++ linux86/ar/ar.c Wed Jan 21 15:09:51 2004 @@ -37,8 +37,6 @@ #define HAVE_RENAME #undef HAVE_FSYNC #define SHORT_FILENAME -extern char **sys_errlist; -extern int sys_nerr; #else #define HAVE_FCHMOD #define HAVE_RENAME @@ -46,8 +44,6 @@ #endif #define HAVE_TRAILING_SLASH_IN_NAME -extern int errno; - #ifdef __GNUC__ # ifndef alloca # define alloca __builtin_alloca @@ -66,9 +62,6 @@ /* Locking is normally disabled because fcntl hangs on the Sun and it isn't supported properly across NFS anyway. */ -#ifdef LOCKS -#include -#endif /* This structure is used internally to represent the info on a member of an archive. This is to make it easier to change format. */ @@ -2055,26 +2048,14 @@ perror_with_name (name) char *name; { - char *s; - - if (errno < sys_nerr) - s = concat ("", sys_errlist[errno], " for %s"); - else - s = "unknown error for %s"; - error (s, name); + error (concat ("", strerror(errno), " for %s"), name); } void pfatal_with_name (name) char *name; { - char *s; - - if (errno < sys_nerr) - s = concat ("", sys_errlist[errno], " for %s"); - else - s = "cannot open %s"; - fatal (s, name); + fatal (concat ("", strerror(errno), " for %s"), name); } /* Return a newly-allocated string whose contents diff -Nurd linux86.old/as/Makefile linux86/as/Makefile --- linux86.old/as/Makefile Sun Aug 31 15:15:29 2003 +++ linux86/as/Makefile Wed Dec 31 11:36:39 2003 @@ -33,6 +33,8 @@ .c.o: $(CC) $(CFLAGS) -c $< +$(OBJS): const.h errors.h + as.o: const.h type.h byteord.h macro.h file.h flag.h globvar.h assemble.o: const.h type.h address.h globvar.h opcode.h scan.h error.o: const.h type.h diff -Nurd linux86.old/as/as.c linux86/as/as.c --- linux86.old/as/as.c Sun Aug 31 14:24:58 2003 +++ linux86/as/as.c Fri Jan 2 21:49:35 2004 @@ -28,6 +28,7 @@ PRIVATE char * binfilename = 0; PRIVATE char * objfilename = 0; +PRIVATE int keep_bad_output = 0; FORWARD void initp1 P((void)); FORWARD int my_creat P((char *name, char *message)); @@ -85,7 +86,7 @@ /* If an output binary is in error remove it */ close(binfil); binfil=0; close(objfil); objfil=0; - if (toterr != 0) + if (toterr != 0 && !keep_bad_output) { if(binfilename) unlink(binfilename); if(objfilename) unlink(objfilename); @@ -279,6 +280,9 @@ case 'w': if( flag_state ) as_warn.semaphore = -1; else as_warn.semaphore = 0; + break; + case 'k': + keep_bad_output = 1; break; default: usage(); /* bad option */ diff -Nurd linux86.old/as/chk linux86/as/chk --- linux86.old/as/chk Wed Sep 27 22:34:45 2000 +++ linux86/as/chk Fri Jan 2 21:49:35 2004 @@ -1,8 +1,8 @@ compile() { - # /lib/elksemu ./as86 -3 "$@" - ./as86 -3 "$@" + # /lib/elksemu ./as86 -3 -k "$@" + ./as86 -3 -k "$@" } for i in `ls asm/*.asm` diff -Nurd linux86.old/as/errors.c linux86/as/errors.c --- linux86.old/as/errors.c Sun Jun 24 08:40:02 2001 +++ linux86/as/errors.c Wed Dec 31 11:36:39 2003 @@ -1,107 +1,108 @@ #include "syshead.h" #include "const.h" +#include "errors.h" /* Error codes. */ /* Syntax errors. */ -PUBLIC char * COMEXP = "comma expected"; -PUBLIC char * DELEXP = "delimiter expected"; -PUBLIC char * FACEXP = "factor expected"; -PUBLIC char * IREGEXP = "index register expected"; -PUBLIC char * LABEXP = "label expected"; -PUBLIC char * LPEXP = "left parentheses expected"; -PUBLIC char * OPEXP = "opcode expected"; -PUBLIC char * RBEXP = "right bracket expected"; -PUBLIC char * REGEXP = "register expected"; -PUBLIC char * RPEXP = "right parentheses expected"; -PUBLIC char * SPEXP = "space expected"; +PUBLIC char COMEXP[] = "comma expected"; +PUBLIC char DELEXP[] = "delimiter expected"; +PUBLIC char FACEXP[] = "factor expected"; +PUBLIC char IREGEXP[] = "index register expected"; +PUBLIC char LABEXP[] = "label expected"; +PUBLIC char LPEXP[] = "left parentheses expected"; +PUBLIC char OPEXP[] = "opcode expected"; +PUBLIC char RBEXP[] = "right bracket expected"; +PUBLIC char REGEXP[] = "register expected"; +PUBLIC char RPEXP[] = "right parentheses expected"; +PUBLIC char SPEXP[] = "space expected"; /* Expression errors. */ -PUBLIC char * ABSREQ = "absolute expression required"; -PUBLIC char * NONIMPREQ = "non-imported expression required"; -PUBLIC char * RELBAD = "relocation impossible"; +PUBLIC char ABSREQ[] = "absolute expression required"; +PUBLIC char NONIMPREQ[] = "non-imported expression required"; +PUBLIC char RELBAD[] = "relocation impossible"; /* Label errors. */ -PUBLIC char * ILLAB = "illegal label"; -PUBLIC char * MACUID = "MACRO used as identifier"; -PUBLIC char * MISLAB = "missing label"; -PUBLIC char * MNUID = "opcode used as identifier"; -PUBLIC char * REGUID = "register used as identifier"; -PUBLIC char * RELAB = "redefined label"; -PUBLIC char * UNBLAB = "unbound label"; -PUBLIC char * UNLAB = "undefined label"; -PUBLIC char * VARLAB = "variable used as label"; +PUBLIC char ILLAB[] = "illegal label"; +PUBLIC char MACUID[] = "MACRO used as identifier"; +PUBLIC char MISLAB[] = "missing label"; +PUBLIC char MNUID[] = "opcode used as identifier"; +PUBLIC char REGUID[] = "register used as identifier"; +PUBLIC char RELAB[] = "redefined label"; +PUBLIC char UNBLAB[] = "unbound label"; +PUBLIC char UNLAB[] = "undefined label"; +PUBLIC char VARLAB[] = "variable used as label"; /* Addressing errors. */ -PUBLIC char * ABOUNDS = "address out of bounds"; -PUBLIC char * DBOUNDS = "data out of bounds"; -PUBLIC char * ILLMOD = "illegal address mode"; -PUBLIC char * ILLREG = "illegal register"; +PUBLIC char ABOUNDS[] = "address out of bounds"; +PUBLIC char DBOUNDS[] = "data out of bounds"; +PUBLIC char ILLMOD[] = "illegal address mode"; +PUBLIC char ILLREG[] = "illegal register"; /* Control structure errors. */ -PUBLIC char * ELSEBAD = "no matching IF"; -PUBLIC char * ENDBBAD = "no matching BLOCK"; -PUBLIC char * EOFBLOCK = "end of file in BLOCK"; -PUBLIC char * EOFIF = "end of file in IF"; -PUBLIC char * EOFLC = "location counter was undefined at end"; -PUBLIC char * EOFMAC = "end of file in MACRO"; -PUBLIC char * FAILERR = "user-generated error"; +PUBLIC char ELSEBAD[] = "no matching IF"; +PUBLIC char ENDBBAD[] = "no matching BLOCK"; +PUBLIC char EOFBLOCK[] = "end of file in BLOCK"; +PUBLIC char EOFIF[] = "end of file in IF"; +PUBLIC char EOFLC[] = "location counter was undefined at end"; +PUBLIC char EOFMAC[] = "end of file in MACRO"; +PUBLIC char FAILERR[] = "user-generated error"; /* Overflow errors. */ -PUBLIC char * BLOCKOV = "BLOCK stack overflow"; -PUBLIC char * BWRAP = "binary file wrap-around"; -PUBLIC char * COUNTOV = "counter overflow"; -PUBLIC char * COUNTUN = "counter underflow"; -PUBLIC char * GETOV = "GET stack overflow"; -PUBLIC char * IFOV = "IF stack overflow"; +PUBLIC char BLOCKOV[] = "BLOCK stack overflow"; +PUBLIC char BWRAP[] = "binary file wrap-around"; +PUBLIC char COUNTOV[] = "counter overflow"; +PUBLIC char COUNTUN[] = "counter underflow"; +PUBLIC char GETOV[] = "GET stack overflow"; +PUBLIC char IFOV[] = "IF stack overflow"; -PUBLIC char * LINLONG = "line too long"; -PUBLIC char * MACOV = "MACRO stack overflow"; -PUBLIC char * OBJSYMOV = "object symbol table overflow"; -PUBLIC char * OWRITE = "program overwrite"; -PUBLIC char * PAROV = "parameter table overflow"; -PUBLIC char * SYMOV = "symbol table overflow"; -PUBLIC char * SYMOUTOV = "output symbol table overflow"; +PUBLIC char LINLONG[] = "line too long"; +PUBLIC char MACOV[] = "MACRO stack overflow"; +PUBLIC char OBJSYMOV[] = "object symbol table overflow"; +PUBLIC char OWRITE[] = "program overwrite"; +PUBLIC char PAROV[] = "parameter table overflow"; +PUBLIC char SYMOV[] = "symbol table overflow"; +PUBLIC char SYMOUTOV[] = "output symbol table overflow"; /* I/O errors. */ -PUBLIC char * OBJOUT = "error writing object file"; +PUBLIC char OBJOUT[] = "error writing object file"; /* Miscellaneous errors. */ -PUBLIC char * AL_AX_EAX_EXP = "al ax or eax expected"; -PUBLIC char * CTLINS = "control character in string"; -PUBLIC char * FURTHER = "futher errors suppressed"; -PUBLIC char * ILL_IMM_MODE = "illegal immediate mode"; -PUBLIC char * ILL_IND_TO_IND = "illegal indirect to indirect"; -PUBLIC char * ILL_IND = "illegal indirection"; -PUBLIC char * ILL_IND_PTR = "illegal indirection from previous 'ptr'"; -PUBLIC char * ILL_SCALE = "illegal scale"; -PUBLIC char * ILL_SECTION = "illegal section"; -PUBLIC char * ILL_SEG_REG = "illegal segment register"; -PUBLIC char * ILL_SOURCE_EA = "illegal source effective address"; -PUBLIC char * ILL_SIZE = "illegal size"; -PUBLIC char * IMM_REQ = "immediate expression expected"; -PUBLIC char * INDEX_REG_EXP = "index register expected"; -PUBLIC char * IND_REQ = "indirect expression required"; -PUBLIC char * MISMATCHED_SIZE = "mismatched size"; -PUBLIC char * NOIMPORT = "no imports with binary file output"; -PUBLIC char * REENTER = "multiple ENTER pseudo-ops"; -PUBLIC char * REL_REQ = "relative expression required"; -PUBLIC char * REPEATED_DISPL = "repeated displacement"; -PUBLIC char * SEGREL = "segment or relocatability redefined"; -PUBLIC char * SEG_REG_REQ = "segment register required"; -PUBLIC char * SIZE_UNK = "size unknown"; -PUBLIC char * UNKNOWN_ESCAPE_SEQUENCE = "unknown escape sequence"; +PUBLIC char AL_AX_EAX_EXP[] = "al ax or eax expected"; +PUBLIC char CTLINS[] = "control character in string"; +PUBLIC char FURTHER[] = "futher errors suppressed"; +PUBLIC char ILL_IMM_MODE[] = "illegal immediate mode"; +PUBLIC char ILL_IND_TO_IND[] = "illegal indirect to indirect"; +PUBLIC char ILL_IND[] = "illegal indirection"; +PUBLIC char ILL_IND_PTR[] = "illegal indirection from previous 'ptr'"; +PUBLIC char ILL_SCALE[] = "illegal scale"; +PUBLIC char ILL_SECTION[] = "illegal section"; +PUBLIC char ILL_SEG_REG[] = "illegal segment register"; +PUBLIC char ILL_SOURCE_EA[] = "illegal source effective address"; +PUBLIC char ILL_SIZE[] = "illegal size"; +PUBLIC char IMM_REQ[] = "immediate expression expected"; +PUBLIC char INDEX_REG_EXP[] = "index register expected"; +PUBLIC char IND_REQ[] = "indirect expression required"; +PUBLIC char MISMATCHED_SIZE[] = "mismatched size"; +PUBLIC char NOIMPORT[] = "no imports with binary file output"; +PUBLIC char REENTER[] = "multiple ENTER pseudo-ops"; +PUBLIC char REL_REQ[] = "relative expression required"; +PUBLIC char REPEATED_DISPL[] = "repeated displacement"; +PUBLIC char SEGREL[] = "segment or relocatability redefined"; +PUBLIC char SEG_REG_REQ[] = "segment register required"; +PUBLIC char SIZE_UNK[] = "size unknown"; +PUBLIC char UNKNOWN_ESCAPE_SEQUENCE[] = "unknown escape sequence"; -PUBLIC char * FP_REG_REQ = "FP register required"; -PUBLIC char * FP_REG_NOT_ALLOWED = "FP register not allowed"; -PUBLIC char * ILL_FP_REG = "illegal FP register"; -PUBLIC char * ILL_FP_REG_PAIR = "illegal FP register pair"; -PUBLIC char * JUNK_AFTER_OPERANDS = "junk after operands"; +PUBLIC char FP_REG_REQ[] = "FP register required"; +PUBLIC char FP_REG_NOT_ALLOWED[] = "FP register not allowed"; +PUBLIC char ILL_FP_REG[] = "illegal FP register"; +PUBLIC char ILL_FP_REG_PAIR[] = "illegal FP register pair"; +PUBLIC char JUNK_AFTER_OPERANDS[] = "junk after operands"; -PUBLIC char * ALREADY = "already defined"; -PUBLIC char * UNSTABLE_LABEL = "label moved in last pass add -O?"; +PUBLIC char ALREADY[] = "already defined"; +PUBLIC char UNSTABLE_LABEL[] = "label moved in last pass add -O?"; /* Warnings. */ -PUBLIC char * CPUCLASH = "instruction illegal for current cpu"; -PUBLIC char * SHORTB = "short branch would do"; +PUBLIC char CPUCLASH[] = "instruction illegal for current cpu"; +PUBLIC char SHORTB[] = "short branch would do"; diff -Nurd linux86.old/as/errors.h linux86/as/errors.h --- linux86.old/as/errors.h Sat Jun 23 20:58:50 2001 +++ linux86/as/errors.h Wed Dec 31 11:36:39 2003 @@ -1,105 +1,105 @@ /* Error codes. */ /* Syntax errors. */ -EXTERN char * COMEXP; /* "comma expected" */ -EXTERN char * DELEXP; /* "delimiter expected" */ -EXTERN char * FACEXP; /* "factor expected" */ -EXTERN char * IREGEXP; /* "index register expected" */ -EXTERN char * LABEXP; /* "label expected" */ -EXTERN char * LPEXP; /* "left parentheses expected" */ -EXTERN char * OPEXP; /* "opcode expected" */ -EXTERN char * RBEXP; /* "right bracket expected" */ -EXTERN char * REGEXP; /* "register expected" */ -EXTERN char * RPEXP; /* "right parentheses expected" */ -EXTERN char * SPEXP; /* "space expected" */ +EXTERN char COMEXP[]; /* "comma expected" */ +EXTERN char DELEXP[]; /* "delimiter expected" */ +EXTERN char FACEXP[]; /* "factor expected" */ +EXTERN char IREGEXP[]; /* "index register expected" */ +EXTERN char LABEXP[]; /* "label expected" */ +EXTERN char LPEXP[]; /* "left parentheses expected" */ +EXTERN char OPEXP[]; /* "opcode expected" */ +EXTERN char RBEXP[]; /* "right bracket expected" */ +EXTERN char REGEXP[]; /* "register expected" */ +EXTERN char RPEXP[]; /* "right parentheses expected" */ +EXTERN char SPEXP[]; /* "space expected" */ /* Expression errors. */ -EXTERN char * ABSREQ; /* "absolute expression required" */ -EXTERN char * NONIMPREQ; /* "non-imported expression required" */ -EXTERN char * RELBAD; /* "relocation impossible" */ +EXTERN char ABSREQ[]; /* "absolute expression required" */ +EXTERN char NONIMPREQ[]; /* "non-imported expression required" */ +EXTERN char RELBAD[]; /* "relocation impossible" */ /* Label errors. */ -EXTERN char * ILLAB; /* "illegal label" */ -EXTERN char * MACUID; /* "MACRO used as identifier" */ -EXTERN char * MISLAB; /* "missing label" */ -EXTERN char * MNUID; /* "opcode used as identifier" */ -EXTERN char * REGUID; /* "register used as identifier" */ -EXTERN char * RELAB; /* "redefined label" */ -EXTERN char * UNBLAB; /* "unbound label" */ -EXTERN char * UNLAB; /* "undefined label" */ -EXTERN char * VARLAB; /* "variable used as label" */ +EXTERN char ILLAB[]; /* "illegal label" */ +EXTERN char MACUID[]; /* "MACRO used as identifier" */ +EXTERN char MISLAB[]; /* "missing label" */ +EXTERN char MNUID[]; /* "opcode used as identifier" */ +EXTERN char REGUID[]; /* "register used as identifier" */ +EXTERN char RELAB[]; /* "redefined label" */ +EXTERN char UNBLAB[]; /* "unbound label" */ +EXTERN char UNLAB[]; /* "undefined label" */ +EXTERN char VARLAB[]; /* "variable used as label" */ /* Addressing errors. */ -EXTERN char * ABOUNDS; /* "address out of bounds" */ -EXTERN char * DBOUNDS; /* "data out of bounds" */ -EXTERN char * ILLMOD; /* "illegal address mode" */ -EXTERN char * ILLREG; /* "illegal register" */ +EXTERN char ABOUNDS[]; /* "address out of bounds" */ +EXTERN char DBOUNDS[]; /* "data out of bounds" */ +EXTERN char ILLMOD[]; /* "illegal address mode" */ +EXTERN char ILLREG[]; /* "illegal register" */ /* Control structure errors. */ -EXTERN char * ELSEBAD; /* "no matching IF" */ +EXTERN char ELSEBAD[]; /* "no matching IF" */ #define ELSEIFBAD ELSEBAD -EXTERN char * ENDBBAD; /* "no matching BLOCK" */ +EXTERN char ENDBBAD[]; /* "no matching BLOCK" */ #define ENDIFBAD ELSEBAD -EXTERN char * EOFBLOCK; /* "end of file in BLOCK" */ -EXTERN char * EOFIF; /* "end of file in IF" */ -EXTERN char * EOFLC; /* "location counter was undefined at end" */ -EXTERN char * EOFMAC; /* "end of file in MACRO" */ -EXTERN char * FAILERR; /* "user-generated error" */ +EXTERN char EOFBLOCK[]; /* "end of file in BLOCK" */ +EXTERN char EOFIF[]; /* "end of file in IF" */ +EXTERN char EOFLC[]; /* "location counter was undefined at end" */ +EXTERN char EOFMAC[]; /* "end of file in MACRO" */ +EXTERN char FAILERR[]; /* "user-generated error" */ /* Overflow errors. */ -EXTERN char * BLOCKOV; /* "BLOCK stack overflow" */ -EXTERN char * BWRAP; /* "binary file wrap-around" */ -EXTERN char * COUNTOV; /* "counter overflow" */ -EXTERN char * COUNTUN; /* "counter underflow" */ -EXTERN char * GETOV; /* "GET stack overflow" */ -EXTERN char * IFOV; /* "IF stack overflow" */ +EXTERN char BLOCKOV[]; /* "BLOCK stack overflow" */ +EXTERN char BWRAP[]; /* "binary file wrap-around" */ +EXTERN char COUNTOV[]; /* "counter overflow" */ +EXTERN char COUNTUN[]; /* "counter underflow" */ +EXTERN char GETOV[]; /* "GET stack overflow" */ +EXTERN char IFOV[]; /* "IF stack overflow" */ -EXTERN char * LINLONG; /* "line too long" */ -EXTERN char * MACOV; /* "MACRO stack overflow" */ -EXTERN char * OBJSYMOV; /* "object symbol table overflow" */ -EXTERN char * OWRITE; /* "program overwrite" */ -EXTERN char * PAROV; /* "parameter table overflow" */ -EXTERN char * SYMOV; /* "symbol table overflow" */ -EXTERN char * SYMOUTOV; /* "output symbol table overflow" */ +EXTERN char LINLONG[]; /* "line too long" */ +EXTERN char MACOV[]; /* "MACRO stack overflow" */ +EXTERN char OBJSYMOV[]; /* "object symbol table overflow" */ +EXTERN char OWRITE[]; /* "program overwrite" */ +EXTERN char PAROV[]; /* "parameter table overflow" */ +EXTERN char SYMOV[]; /* "symbol table overflow" */ +EXTERN char SYMOUTOV[]; /* "output symbol table overflow" */ /* I/O errors. */ -EXTERN char * OBJOUT; /* "error writing object file" */ +EXTERN char OBJOUT[]; /* "error writing object file" */ /* Miscellaneous errors. */ -EXTERN char * AL_AX_EAX_EXP; /* "al ax or eax expected" */ -EXTERN char * CTLINS; /* "control character in string" */ -EXTERN char * FURTHER; /* "futher errors suppressed" */ -EXTERN char * ILL_IMM_MODE; /* "illegal immediate mode" */ -EXTERN char * ILL_IND_TO_IND; /* "illegal indirect to indirect" */ -EXTERN char * ILL_IND; /* "illegal indirection" */ -EXTERN char * ILL_IND_PTR; /* "illegal indirection from previous 'ptr'" */ -EXTERN char * ILL_SCALE; /* "illegal scale" */ -EXTERN char * ILL_SECTION; /* "illegal section" */ -EXTERN char * ILL_SEG_REG; /* "illegal segment register" */ -EXTERN char * ILL_SOURCE_EA; /* "illegal source effective address" */ -EXTERN char * ILL_SIZE; /* "illegal size" */ -EXTERN char * IMM_REQ; /* "immediate expression expected" */ -EXTERN char * INDEX_REG_EXP; /* "index register expected" */ -EXTERN char * IND_REQ; /* "indirect expression required" */ -EXTERN char * MISMATCHED_SIZE; /* "mismatched size" */ -EXTERN char * NOIMPORT; /* "no imports with binary file output" */ -EXTERN char * REENTER; /* "multiple ENTER pseudo-ops" */ -EXTERN char * REL_REQ; /* "relative expression required" */ -EXTERN char * REPEATED_DISPL; /* "repeated displacement" */ -EXTERN char * SEGREL; /* "segment or relocatability redefined" */ -EXTERN char * SEG_REG_REQ; /* "segment register required" */ -EXTERN char * SIZE_UNK; /* "size unknown" */ -EXTERN char * UNKNOWN_ESCAPE_SEQUENCE; /* "unknown escape sequence" */ +EXTERN char AL_AX_EAX_EXP[]; /* "al ax or eax expected" */ +EXTERN char CTLINS[]; /* "control character in string" */ +EXTERN char FURTHER[]; /* "futher errors suppressed" */ +EXTERN char ILL_IMM_MODE[]; /* "illegal immediate mode" */ +EXTERN char ILL_IND_TO_IND[]; /* "illegal indirect to indirect" */ +EXTERN char ILL_IND[]; /* "illegal indirection" */ +EXTERN char ILL_IND_PTR[]; /* "illegal indirection from previous 'ptr'" */ +EXTERN char ILL_SCALE[]; /* "illegal scale" */ +EXTERN char ILL_SECTION[]; /* "illegal section" */ +EXTERN char ILL_SEG_REG[]; /* "illegal segment register" */ +EXTERN char ILL_SOURCE_EA[]; /* "illegal source effective address" */ +EXTERN char ILL_SIZE[]; /* "illegal size" */ +EXTERN char IMM_REQ[]; /* "immediate expression expected" */ +EXTERN char INDEX_REG_EXP[]; /* "index register expected" */ +EXTERN char IND_REQ[]; /* "indirect expression required" */ +EXTERN char MISMATCHED_SIZE[]; /* "mismatched size" */ +EXTERN char NOIMPORT[]; /* "no imports with binary file output" */ +EXTERN char REENTER[]; /* "multiple ENTER pseudo-ops" */ +EXTERN char REL_REQ[]; /* "relative expression required" */ +EXTERN char REPEATED_DISPL[]; /* "repeated displacement" */ +EXTERN char SEGREL[]; /* "segment or relocatability redefined" */ +EXTERN char SEG_REG_REQ[]; /* "segment register required" */ +EXTERN char SIZE_UNK[]; /* "size unknown" */ +EXTERN char UNKNOWN_ESCAPE_SEQUENCE[]; /* "unknown escape sequence" */ -EXTERN char * FP_REG_REQ; /* "FP register required" */ -EXTERN char * FP_REG_NOT_ALLOWED; /* "FP register not allowed" */ -EXTERN char * ILL_FP_REG; /* "illegal FP register" */ -EXTERN char * ILL_FP_REG_PAIR; /* "illegal FP register pair" */ -EXTERN char * JUNK_AFTER_OPERANDS; /* "junk after operands" */ +EXTERN char FP_REG_REQ[]; /* "FP register required" */ +EXTERN char FP_REG_NOT_ALLOWED[]; /* "FP register not allowed" */ +EXTERN char ILL_FP_REG[]; /* "illegal FP register" */ +EXTERN char ILL_FP_REG_PAIR[]; /* "illegal FP register pair" */ +EXTERN char JUNK_AFTER_OPERANDS[]; /* "junk after operands" */ -EXTERN char * ALREADY; /* "already defined" */ -EXTERN char * UNSTABLE_LABEL; /* "label moved in last pass add -O?" */ +EXTERN char ALREADY[]; /* "already defined" */ +EXTERN char UNSTABLE_LABEL[]; /* "label moved in last pass add -O?" */ /* Warnings. */ -EXTERN char * CPUCLASH; /* "instruction illegal for current cpu" */ -EXTERN char * SHORTB; /* "short branch would do" */ +EXTERN char CPUCLASH[]; /* "instruction illegal for current cpu" */ +EXTERN char SHORTB[]; /* "short branch would do" */ diff -Nurd linux86.old/bcc/Makefile linux86/bcc/Makefile --- linux86.old/bcc/Makefile Sun Aug 31 14:28:01 2003 +++ linux86/bcc/Makefile Sat Jan 24 12:27:21 2004 @@ -4,13 +4,12 @@ # PREFIX=/usr -LIBPRE=$(PREFIX) CFLAGS =-O LDFLAGS =-s BINDIR =$(PREFIX)/bin -LIBDIR =$(LIBPRE)/lib/bcc -BCCDEFS =-DLOCALPREFIX=$(LIBPRE) -DBINDIR=$(BINDIR) -DDEFARCH=0 +LIBDIR =$(PREFIX)/lib/bcc +BCCDEFS =-DLOCALPREFIX=$(PREFIX) -DBINDIR=$(BINDIR) -DDEFARCH=0 BCFLAGS=$(ANSI) $(CFLAGS) $(LDFLAGS) @@ -31,7 +30,7 @@ $(CC) $(BCFLAGS) $(BCCDEFS) bcc.c -o $@ ncc: bcc.c - $(CC) $(BCFLAGS) -DL_TREE -DDEFARCH=0 bcc.c -o $@ + $(CC) $(BCFLAGS) -DLOCALPREFIX= -DDEFARCH=0 bcc.c -o $@ bcc09: bcc.c $(CC) $(BCFLAGS) -DMC6809 $(BCCDEFS) bcc.c -o $@ diff -Nurd linux86.old/bcc/bcc-cc1.c linux86/bcc/bcc-cc1.c --- linux86.old/bcc/bcc-cc1.c Mon Jul 22 20:44:17 2002 +++ linux86/bcc/bcc-cc1.c Fri Jan 2 21:49:35 2004 @@ -11,8 +11,10 @@ growheap(0); /* init order is important */ syminit(); etreeinit(); +#ifdef BUILTIN_CPP ifinit(); predefine(); +#endif openio(argc, argv); codeinit(); typeinit(); diff -Nurd linux86.old/bcc/bcc.c linux86/bcc/bcc.c --- linux86.old/bcc/bcc.c Tue Oct 7 20:37:41 2003 +++ linux86/bcc/bcc.c Sat Jan 24 15:25:32 2004 @@ -42,7 +42,6 @@ #define W_OK 2 /* Test for write permission. */ #define X_OK 1 /* Test for execute permission. */ #define F_OK 0 /* Test for existence. */ -#define L_TREE 1 /* Use different tree style */ #define DEFARCH 0 /* Default to 8086 code */ #include "version.h" #else @@ -132,6 +131,7 @@ int main P((int argc, char **argv)); void getargs P((int argc, char **argv)); void add_prefix P((char * path)); +void build_prefix P((char * path1, char * path2, char * path3)); void run_aspreproc P((struct file_list * file)); void run_preproc P((struct file_list * file)); void run_unproto P((struct file_list * file)); @@ -149,45 +149,35 @@ void append_file P((char * filename, int ftype)); void append_option P((char * option, int otype)); void prepend_option P((char * option, int otype)); -char * expand_tilde P((char * str)); +char * build_libpath P((char * opt, char * str, char * suffix)); void * xalloc P((int size)); void Usage P((void)); void fatal P((char * why)); char * copystr P((char * str)); char * catstr P((char * str, char * str2)); -#ifdef L_TREE -void reset_localprefix P((void)); -#endif +void reset_prefix_path P((void)); void run_command P((struct file_list * file)); -#ifndef LOCALPREFIX -#define LOCALPREFIX /usr +char * prefix_path = ""; + +#ifdef LOCALPREFIX +char * localprefix = QUOT(LOCALPREFIX); +#else +char * localprefix = "/"; #endif -char * localprefix = QUOT(LOCALPREFIX); -#ifndef L_TREE -char * default_include = "-I~/include"; -char * default_libdir0 = "-L~/lib/bcc/i86/"; -char * default_libdir3 = "-L~/lib/bcc/i386/"; -char * optim_rules = "-d~/lib/bcc/i86"; + +/* These paths are NATIVE install paths, change others below */ +char * default_include = "/usr/include"; +char * optim_rules = "/lib"; +#ifdef LIBDIR +char * default_libdir = QUOT(LIBDIR); #else -char * default_include = "-I~/include"; -char * default_libdir0 = "-L~/lib/"; -char * default_libdir3 = "-L~/lib/i386/"; -char * optim_rules = "-d~/lib"; +char * default_libdir = "/lib"; #endif +char * libdir_suffix = ""; char devnull[] = "/dev/null"; -char * exec_prefixs[] = { - - /* Place fillers for dynamic fill */ - devnull, devnull, devnull, devnull, devnull, - - "~/lib/bcc/", -#ifdef BINDIR - QUOT(BINDIR) "/", -#endif - "~/lib/", - "~/bin/", +char * exec_prefixs[16] = { 0 /* Last chance is contents of $PATH */ }; @@ -199,18 +189,55 @@ char ** argv; { struct file_list * next_file; + char * temp; progname = argv[0]; -#ifdef L_TREE - reset_localprefix(); -#endif + if ((temp = getenv("BCC_PREFIX")) != 0 ) + localprefix = copystr(temp); + getargs(argc, argv); validate_link_opts(); - default_include = expand_tilde(default_include); - default_libdir0 = expand_tilde(default_libdir0); - default_libdir3 = expand_tilde(default_libdir3); - optim_rules = expand_tilde(optim_rules); + reset_prefix_path(); + + if (!*localprefix || !localprefix[1]) { + + if (*localprefix == '/') { + /* Paths for full NATIVE install "-M/" */ + build_prefix(default_libdir, libdir_suffix, ""); + build_prefix(default_libdir, "", ""); + + default_include = build_libpath("-I", "/usr/include", ""); + default_libdir = build_libpath("-L", default_libdir, libdir_suffix); + optim_rules = build_libpath("-d", optim_rules, libdir_suffix); +#if 0 + } else if (*localprefix == '+') { + /* Paths for a special */ +#endif + } else { + /* Relative paths to a build dir "-M-" */ + build_prefix("/lib", libdir_suffix, ""); + build_prefix("/lib", "", ""); + + default_include = build_libpath("-I", "/include", ""); + default_libdir = build_libpath("-L", "/lib", libdir_suffix); + optim_rules = build_libpath("-d", "/lib", libdir_suffix); + } + + } else { + /* Relative paths to normal PREFIX directory */ + default_include = build_libpath("-I", "/lib/bcc/include", ""); + default_libdir = build_libpath("-L", "/lib/bcc", libdir_suffix); + optim_rules = build_libpath("-d", "/lib/bcc", libdir_suffix); + + build_prefix("/lib/bcc", libdir_suffix, ""); + build_prefix("/lib/bcc", "", ""); + } + + build_prefix("/bin", "", ""); +#ifdef BINDIR + add_prefix(QUOT(BINDIR) "/"); +#endif if (opt_v>1) { command.cmd = ""; command_reset(); } @@ -260,7 +287,7 @@ run_aspreproc(file) struct file_list * file; { - static char * cc1bcc = CC1BCC; + static char cc1bcc[] = CC1BCC; if (opt_arch<5) { if (opt_e) @@ -290,7 +317,7 @@ { int last_stage = 0; int combined_cpp; - static char * cc1bcc = CC1BCC; + static char cc1bcc[] = CC1BCC; if (opt_arch<5) { if (opt_e) @@ -381,21 +408,32 @@ command_reset(); newfilename(file, !do_as, 's', 1); command_opt("-c!"); - if (opt_O) + if (opt_O && opt_arch == 0) { sprintf(buf, "-huse16 %c86", opt_O); command_opt(buf); } command_opt(optim_rules); - command_opts('o'); command_opt("rules.start"); - if (opt_O) - { - sprintf(buf, "rules.%c86", opt_O); + command_opts('o'); + + if (opt_O) { + if (opt_arch == 0) + sprintf(buf, "rules.%c86", opt_O); + else + sprintf(buf, "rules.lv_%c", opt_O); command_opt(buf); } - command_opt("rules.86"); + + switch(opt_arch) { + case 0: command_opt("rules.86"); break; + case 1: + case 2: command_opt("rules.i386"); break; + case 4: command_opt("rules.6809"); break; + default:command_opt("rules.mid"); break; + } + command_opt("rules.end"); run_command(file); @@ -436,9 +474,9 @@ { command.cmd = LD86; command_reset(); - newfilename(file, !do_link, 'o', 1); command_opt("-r"); command_opt("-N"); + newfilename(file, !do_link, 'o', 1); run_command(file); } } @@ -472,15 +510,14 @@ command_opt("-i"); if (!opt_L) - { - if (opt_arch==1) command_opt(default_libdir3); - else command_opt(default_libdir0); - } + command_opt(default_libdir); command_arch(); if (!opt_x) command_opt("-C0"); } + /* Current Debian compilers only work in with this: */ + else command_opt("--static"); for(next_file = files; next_file; next_file = next_file->next) command_opt(next_file->file); @@ -605,13 +642,13 @@ memcpy(buf, *prefix, p-*prefix); buf[p-*prefix] = 0; - strcat(buf, localprefix); + strcat(buf, prefix_path); strcat(buf, p+1); } strcat(buf, command.cmd); if (!*command.cmd) - fprintf(stderr, "PATH+=%s\n", buf); + fprintf(stderr, "PATH%d=%s\n", prefix-exec_prefixs, buf); else if (access(buf, X_OK) == 0) { command.fullpath = copystr(buf); @@ -832,7 +869,7 @@ case 'O': do_optim=1; - if (!opt_arg[1] && ( opt_arg[0] >= '1' && opt_arg[0] <= '3' )) + if (!opt_arg[1] && ( opt_arg[0] >= '1' && opt_arg[0] <= '9' )) opt_O = opt_arg[0]; else if (opt_arg[0] == '-') append_option(opt_arg, 'o'); @@ -866,7 +903,15 @@ break; case 'M': + if (opt_arg[0] == '/') { + localprefix = copystr(opt_arg); + break; + } if (opt_arg[1]) Usage(); + if (opt_arg[0] == '-') { + localprefix = ""; + break; + } opt_M = *opt_arg; break; @@ -1002,23 +1047,21 @@ opt_arch = 2; prepend_option("-D__unix__", 'p'); prepend_option("-D__linux__", 'p'); - /* This one works (in Debian potato), /usr/bin/gcc crashes. */ - add_prefix("/usr/bin/i486-linuxlibc1-"); + + /* This is a more traditional libc, it also gives a 20k executable + * for hello world vs. 400k with glibc2 and --static. + * NB: DLL libc no longer seems to work. + */ + add_prefix("/usr/bin/i386-uclibc-"); break; case '8': /* Use 'c386' program as compiler */ opt_arch = 3; + prepend_option("-D__unix__", 'p'); + prepend_option("-D__c386__", 'p'); break; case '9': /* 6809 compiler */ opt_arch = 4; -#ifndef L_TREE - default_libdir0 = "-L~/lib/bcc/m09/"; - optim_rules = "-d~/lib/bcc/m09"; - add_prefix("~/lib/bcc/m09/"); -#else - default_libdir0 = "-L~/lib/m09/"; - optim_rules = "-d~/lib/m09"; - add_prefix("~/lib/m09/"); -#endif + prepend_option("-D__6809__", 'p'); break; case '0': /* Plain old Unix V7 style */ opt_arch = 5; @@ -1036,6 +1079,29 @@ append_option("-O", 'C'); append_option("-O", 'a'); } + + if (opt_arch == 1) libdir_suffix = "/i386"; + if (opt_arch == 4) libdir_suffix = "/m09"; +} + +void +build_prefix(path1, path2, path3) +char * path1, * path2, * path3; +{ + char * newstr; + int l; + newstr = xalloc(strlen(path1)+strlen(path1)+strlen(path3) + + strlen(prefix_path)+2); + + strcpy(newstr, prefix_path); + strcat(newstr, path1); + strcat(newstr, path2); + strcat(newstr, path3); + l = strlen(newstr); + if (l>1 && newstr[l-1] != '/') + strcat(newstr, "/"); + + add_prefix(newstr); } void @@ -1045,14 +1111,18 @@ char ** p; if (!path || !*path) return; - for(p=exec_prefixs; *p; p++) { - if( *p == devnull ) + for( p=exec_prefixs; + p file.o for assembler output a.out for ld output --ansi Pass the source through '/usr/bin/unprotoize' first +-ansi Pass the source through 'unproto' first -0 8086 target (works even on 80386 host) -3 80386 target (works even on 8086 host) -A pass remainder of option to assembler (e.g. -A-l -Alistfile for a listing) diff -Nurd linux86.old/bcc/const.h linux86/bcc/const.h --- linux86.old/bcc/const.h Thu Jan 10 08:05:20 2002 +++ linux86/bcc/const.h Fri Jan 2 21:49:35 2004 @@ -26,6 +26,7 @@ #ifndef VERY_SMALL_MEMORY #define DEBUG /* generate compiler-debugging code */ #define OPTIMISE /* include optimisation code */ +#define BUILTIN_CPP #endif #ifdef I8088 diff -Nurd linux86.old/bcc/declare.c linux86/bcc/declare.c --- linux86.old/bcc/declare.c Sat Aug 3 21:09:43 2002 +++ linux86/bcc/declare.c Fri Jan 2 21:49:35 2004 @@ -1052,9 +1052,11 @@ PUBLIC void program() { +#ifdef BUILTIN_CPP if (orig_cppmode) cppscan(0); else +#endif { nextsym(); while (sym != EOFSYM) diff -Nurd linux86.old/bcc/input.c linux86/bcc/input.c --- linux86.old/bcc/input.c Thu Dec 5 08:04:58 2002 +++ linux86/bcc/input.c Fri Jan 2 21:49:35 2004 @@ -19,6 +19,10 @@ #define INBUFSIZE 2048 +#ifndef BUILTIN_CPP +#define NO_EOFHACK +#endif + struct fbufstruct /* file buffer structure */ { struct fcbstruct fcb; /* status after opening an include sub-file */ @@ -51,8 +55,10 @@ #endif NULL, }; +#ifdef BUILTIN_CPP PRIVATE fastin_t inclevel; /* nest level of include files */ /* depends on zero init */ +#endif PRIVATE struct fbufstruct *inputbuf; /* current input file buffer */ /* its fcb only to date in includes */ /* depends on zero (NULL) init */ @@ -63,8 +69,10 @@ #endif FORWARD void definefile P((char *fname)); FORWARD void inputinit P((char *fname, fd_t fd)); -FORWARD void leaveinclude P((void)); FORWARD void usage P((void)); +#ifdef BUILTIN_CPP +FORWARD void leaveinclude P((void)); +#endif #ifdef ARBITRARY_BACKSLASH_NEWLINES PRIVATE void backslash() @@ -138,10 +146,13 @@ #else close(input.fd); #endif +#ifdef BUILTIN_CPP while (inclevel != 0) leaveinclude(); +#endif } +#ifdef BUILTIN_CPP PRIVATE void definefile(fname) char *fname; { @@ -155,6 +166,7 @@ definestring(def); ourfree(def); } +#endif PUBLIC void errorloc() { @@ -170,6 +182,7 @@ { outudec(input.linenumber); outbyte('.'); +#ifdef BUILTIN_CPP if (maclevel == 0) outudec((unsigned) (lineptr - inputbuf->fbuf) - input.lineoffset); else @@ -180,6 +193,9 @@ outudec((unsigned) maclevel); outbyte(')'); } +#else + outudec((unsigned) (lineptr - inputbuf->fbuf) - input.lineoffset); +#endif } infbuf->fcb.includer = input.includer; while ((infbuf = infbuf->fcb.includer) != NULL) @@ -202,6 +218,7 @@ specialchar(); } +#ifdef BUILTIN_CPP /* process #include */ PUBLIC void include() @@ -217,10 +234,15 @@ while (blanksident()) { +#ifdef BUILTIN_CPP if ((gsymptr = findlorg(gsname)) == NULL || gsymptr->flags != DEFINITION) break; entermac(); +#else + if ((gsymptr = findlorg(gsname)) == NULL ) + break; +#endif } if ((terminator = ch) == '<') terminator = '>'; @@ -345,6 +367,7 @@ #endif charptr = fnameptr; } +#endif /* initialise current input file */ @@ -373,14 +396,18 @@ inputbuf = newinputbuf; newinputbuf->fname = fname; newinputbuf->fname_malloced = FALSE; +#ifdef BUILTIN_CPP undefinestring(filemacro); definefile(fname); if (orig_cppmode && !suppress_line_numbers) outcpplinenumber(1, fname, input.includer == NULL ? "" : " 1"); +#endif *(input.limit = newinputbuf->fbuf) = EOL; +#ifdef BUILTIN_CPP /* dummy line so #include processing can start with skipline() */ ch = *(lineptr = newinputbuf->fbuf - 1) = EOL; +#endif } PUBLIC void linecontol() @@ -412,11 +439,14 @@ inputbuf->fname = linename; ptr=lineptr; +#ifdef BUILTIN_CPP undefinestring(filemacro); definefile(inputbuf->fname); +#endif ch = *(lineptr = ptr); } +#ifdef BUILTIN_CPP /* switch from include file to file which included it */ PRIVATE void leaveinclude() @@ -442,13 +472,16 @@ #endif inputbuf = input.includer; input = inputbuf->fcb; +#ifdef BUILTIN_CPP undefinestring(filemacro); definefile(inputbuf->fname); +#endif ch = *(lineptr = input.lineptr); skipline(); if (orig_cppmode && !suppress_line_numbers) outcpplinenumber(input.linenumber, inputbuf->fname, " 2"); } +#endif /* open input and output files and get options */ @@ -499,7 +532,9 @@ #ifdef DEBUG case 'd': /* print debugging information in asm output */ #endif +#ifdef BUILTIN_CPP case 'E': /* acting as cpp */ +#endif case 'f': /* pass first argument in register */ #ifdef DYNAMIC_LONG_ORDER case 'l': /* long big-endian */ @@ -520,6 +555,7 @@ if (arg[1] == '0') /* flag 0 is negative logic flag 3 */ flag['3'] = TRUE + FALSE - flag['0']; break; +#ifdef BUILTIN_CPP case 'D': definestring(arg + 2); break; @@ -536,6 +572,7 @@ case 'U': undefinestring(arg + 2); break; +#endif case 'o': if (arg[2] != 0 || ++argn >= argc) usage(); @@ -546,6 +583,7 @@ break; } } +#ifdef BUILTIN_CPP #ifdef I8088 #ifdef I80386 if (flag['3']) @@ -607,6 +645,28 @@ #ifdef NOFLOAT definestring("__HAS_NO_FLOATS__"); #endif + +#else /* !BUILTIN_CPP */ + +#ifdef I80386 + if (flag['3']) i386_32 = TRUE; +#endif + if (flag['c']) callersaves = TRUE; +#ifdef DEBUG + debugon = flag['d']; +#endif + if (flag['f']) arg1inreg = TRUE; + arg1op = arg1inreg ? ROOTLISTOP : LISTOP; +#ifdef DYNAMIC_LONG_ORDER + if (flag['l']) long_big_endian = TRUE; +#endif + suppress_line_numbers = flag['P']; +#ifdef POSINDEPENDENT + if (flag['p']) posindependent = TRUE; +#endif + if (flag['O']) optimise = TRUE; + +#endif ctext = flag['t']; #ifdef DEBUG if (ctext) debugon = 1; @@ -642,6 +702,7 @@ outbyte(' '); outline(lineptr); } +#ifdef BUILTIN_CPP #ifndef ASM_BARE if (!virtual_nl && (orig_cppmode || asmmode)) #else @@ -651,6 +712,13 @@ if (!skip_printing_nl) #endif outbyte('\n'); +#else /* !BUILTIN_CPP */ + if (asmmode) +#ifdef INSERT_BACKSLASH_NEWLINES + if (!skip_printing_nl) +#endif + outbyte('\n'); +#endif #ifdef INSERT_BACKSLASH_NEWLINES if (bs_state == 1 && *(lineptr - 1) == EOL) @@ -715,6 +783,7 @@ ch = *lineptr; if (nread == 0) { +#ifdef BUILTIN_CPP if (inclevel == 0) { eofile = TRUE; @@ -725,6 +794,9 @@ leaveinclude(); skipeol(); } +#else + eofile = TRUE; +#endif return; } if (ctext && !asmmode) @@ -738,6 +810,7 @@ PUBLIC void specialchar() { +#ifdef BUILTIN_CPP if (maclevel != 0) { if (ch == EOL) /* it might also be backslash or COEOL */ @@ -745,6 +818,7 @@ if (ch != EOL) return; } +#endif more: #ifdef ARBITRARY_BACKSLASH_NEWLINES if (ch == '\\') diff -Nurd linux86.old/bcc/input.h linux86/bcc/input.h --- linux86.old/bcc/input.h Sat Nov 2 14:23:58 1996 +++ linux86/bcc/input.h Fri Jan 2 21:49:35 2004 @@ -26,13 +26,16 @@ EXTERN bool_t asmmode; /* nonzero when processing assembler code */ /* depends on zero init */ EXTERN char ch; /* current char */ -EXTERN bool_t cppmode; /* nonzero if acting as cpp not as compiler */ EXTERN bool_t eofile; /* nonzero after end of main file reached */ /* depends on zero init */ EXTERN struct fcbstruct input; /* current input file control block */ /* input.lineptr is not kept up to date */ EXTERN char *lineptr; /* ptr to current char */ + +#ifdef BUILTIN_CPP +EXTERN bool_t cppmode; /* nonzero if acting as cpp not as compiler */ EXTERN maclev_t maclevel; /* nest level of #defined identifiers */ /* depends on zero init */ EXTERN bool_t orig_cppmode; /* same as cppmode ex. not varied while in # */ EXTERN bool_t virtual_nl; /* For -C and asm, don't print first nl */ +#endif diff -Nurd linux86.old/bcc/output.c linux86/bcc/output.c --- linux86.old/bcc/output.c Tue Jul 30 08:31:39 2002 +++ linux86/bcc/output.c Fri Jan 2 21:49:35 2004 @@ -157,7 +157,9 @@ PUBLIC void finishup() { +#ifdef BUILTIN_CPP if (!orig_cppmode) +#endif { if (watchlc) { @@ -208,7 +210,9 @@ } if (nbytes != 0) { +#ifdef BUILTIN_CPP if (!orig_cppmode) +#endif clearlabels(outbufptr, outbufptr + nbytes); if (write(output, outbufptr, nbytes) != nbytes) { diff -Nurd linux86.old/bcc/preproc.c linux86/bcc/preproc.c --- linux86.old/bcc/preproc.c Sun Jul 28 12:11:05 2002 +++ linux86/bcc/preproc.c Fri Jan 2 21:49:35 2004 @@ -12,6 +12,16 @@ #include "table.h" #include "type.h" +/* blanksident() - return nonzero if at blanks followed by an identifier */ + +PUBLIC bool_pt blanksident() +{ + blanks(); + return isident(); +} + +#ifdef BUILTIN_CPP + #define MAX_IF 32 #define MAX__LINE__ 10 /* enough for 32-bit source unsigneds */ #define MAX_MACRO 32 @@ -138,14 +148,6 @@ outnstr("!BCC_ENDASM"); } -/* blanksident() - return nonzero if at blanks followed by an identifier */ - -PUBLIC bool_pt blanksident() -{ - blanks(); - return isident(); -} - PUBLIC void checknotinif() { while (iflevel != 0) @@ -1076,3 +1078,5 @@ { defineorundefinestring(str, FALSE); } + +#endif diff -Nurd linux86.old/bcc/scan.c linux86/bcc/scan.c --- linux86.old/bcc/scan.c Sat Jan 12 17:44:28 2002 +++ linux86/bcc/scan.c Fri Jan 2 21:49:35 2004 @@ -119,6 +119,7 @@ continue; reglineptr = lineptr; } +#ifdef BUILTIN_CPP if (*reglineptr != '/') return; if (SYMOFCHAR(*(reglineptr + 1)) == SPECIALCHAR) @@ -131,6 +132,9 @@ return; gch1(); skipcomment(); +#else + return; +#endif } } @@ -139,8 +143,10 @@ { int start_of_line = 1; #ifndef ASM_BARE +#ifdef BUILTIN_CPP virtual_nl = 1; #endif +#endif while (!asm_only || asmmode) { int sym = SYMOFCHAR(ch); @@ -172,6 +178,7 @@ outstr(constant.value.s); /* XXX - embedded null would kill it */ charptr = constant.value.s; break; +#ifdef BUILTIN_CPP case CONTROL: gch1(); if (maclevel != 0) @@ -196,6 +203,12 @@ } outbyte('/'); break; +#else /* !BUILTIN_CPP */ + case CONTROL: + gch1(); + docontrol(); + continue; +#endif case FLOATCONST: gch1(); if (SYMOFCHAR(ch) == INTCONST) @@ -211,6 +224,7 @@ break; case IDENT: getident(); +#ifdef BUILTIN_CPP if ((gsymptr = findlorg(gsname)) != NULL) { if (gsymptr->flags == DEFINITION) @@ -219,6 +233,7 @@ break; } } +#endif outstr(gsname); break; case INTCONST: @@ -253,7 +268,11 @@ /* must be '\\' */ default: /* Allow for multi-instruction lines in asm */ +#ifdef BUILTIN_CPP if( ch == '^' && !orig_cppmode && asmmode ) ch='\n'; +#else + if( ch == '^' && asmmode ) ch='\n'; +#endif OUTBYTE(ch); ch = *++lineptr; @@ -261,8 +280,10 @@ break; } #ifndef ASM_BARE +#ifdef BUILTIN_CPP virtual_nl = 0; #endif +#endif } } @@ -473,12 +494,14 @@ constant.type = itype; return; case CONTROL: +#ifdef BUILTIN_CPP if (maclevel != 0) { error("# in a macro: not preprocessed"); /* XXX? */ return; } else +#endif { int old_asmmode = asmmode; docontrol(); @@ -505,11 +528,13 @@ getident(); if ((gsymptr = findlorg(gsname)) != NULL) { +#ifdef BUILTIN_CPP if (gsymptr->flags == DEFINITION) { entermac(); break; } +#endif if (gsymptr->flags == KEYWORD) sym = gsymptr->offset.offsym; } @@ -609,11 +634,13 @@ } return; case SLASH: +#ifdef BUILTIN_CPP if (ch == '*') { skipcomment(); break; } +#endif if (ch == '=') { sym = DIVABOP; @@ -749,7 +776,9 @@ gch1(); if (ch == EOL) { +#ifdef BUILTIN_CPP if (!orig_cppmode) +#endif eofin("escape sequence"); break; } @@ -758,7 +787,9 @@ GCH1(); if (ch == EOL) { +#ifdef BUILTIN_CPP if (!orig_cppmode && ifcheck() ) +#endif error(terminator == '"' ? "end of line in string constant" : "end of line in character constant"); break; diff -Nurd linux86.old/bin86/Makefile linux86/bin86/Makefile --- linux86.old/bin86/Makefile Wed Mar 20 22:03:38 2002 +++ linux86/bin86/Makefile Wed Dec 31 11:36:40 2003 @@ -27,13 +27,11 @@ install: all install $(INSTALL_OPTS) as/as86 $(BINDIR)/as$(SUF) - install $(INSTALL_OPT) as/as86_encap $(BINDIR)/as$(SUF)_encap install $(INSTALL_OPTS) ld/ld86 $(BINDIR)/ld$(SUF) install $(INSTALL_OPTS) ld/objdump86 $(BINDIR)/objdump$(SUF) install $(MAN_OPTS) man/*.1 $(MANDIR) ln -sf objdump$(SUF) $(BINDIR)/nm$(SUF) ln -sf objdump$(SUF) $(BINDIR)/size$(SUF) - ln -sf as86.1 $(MANDIR)/as86_encap.1 depend clean clobber: set -e ; for d in $(DIRS); do \ diff -Nurd linux86.old/cpp/cpp.c linux86/cpp/cpp.c --- linux86.old/cpp/cpp.c Sun Nov 2 08:10:42 2003 +++ linux86/cpp/cpp.c Wed Jan 21 09:22:48 2004 @@ -134,8 +134,8 @@ if( ch == TK_WORD ) { - struct token_trans *p; - if( p=is_ckey(curword, strlen(curword)) ) + struct token_trans *p = is_ckey(curword, strlen(curword)) ; + if( p ) return p->token; } @@ -551,7 +551,7 @@ fprintf(stderr, "\b", ch); #endif if(ch == 0) return; /* Hummm */ - if(ch == EOF) ch=EOT; /* EOF is pushed back as ^Z */ + if(ch == EOF) ch=EOT; /* EOF is pushed back as a normal character. */ ch &= 0xFF; if(unputc&0xFF000000) diff -Nurd linux86.old/elksemu/Makefile linux86/elksemu/Makefile --- linux86.old/elksemu/Makefile Sat Jan 6 12:33:39 2001 +++ linux86/elksemu/Makefile Wed Jan 21 22:26:14 2004 @@ -26,13 +26,16 @@ elksemu: $(OBJ) $(CC) $(CFLAGS) -o $@ $^ -elks_sys.o: call_tab.v +elks_sys.o: call_tab.v efile.h $(OBJ): elks.h call_tab.v: dummy -cp -p ../libc/syscall/call_tab.v . 2>/dev/null -cp -p ../libc/syscall/defn_tab.v . 2>/dev/null +efile.h: ../libc/error/liberror.txt + sh mkefile ../libc/error/liberror.txt + dummy: # The kernel patch or module _requires_ this location but binfmt-misc is easy @@ -42,7 +45,7 @@ install -s -o root -g root -m 4555 elksemu $(DIST)/lib/elksemu clean realclean: - rm -f $(OBJ) binfmt_elks.o elksemu call_tab.v defn_tab.v + rm -f $(OBJ) binfmt_elks.o elksemu call_tab.v defn_tab.v efile.h module: binfmt_elks.o diff -Nurd linux86.old/elksemu/README linux86/elksemu/README --- linux86.old/elksemu/README Sun Jan 5 12:15:40 2003 +++ linux86/elksemu/README Sun Jan 18 12:43:48 2004 @@ -6,17 +6,11 @@ binfmt_misc driver is in the stock kernel and all you need to do is add the following line into the relevent /etc/rc* file. -echo ':i86-elks:M::\x01\x03\x20\x00:\xff\xff\xff\x83:/lib/elksemu:' \ +echo ':i86-elks:M::\x01\x03\x20\x00:\xff\xff\xff\x83:/usr/bin/elksemu:' \ > /proc/sys/fs/binfmt_misc/register Note, however, if binfmt_misc is compiled as a module it will not auto load so you will have to do this manually. - -Further by default the elksemu executable is compiled as an OMAGIC -executable and needs binfmt_aout. If binfmt_aout is a module and your -/etc/modules.conf is not correctly configured you may have to load this -module manually too. Alternativily you can compile elksemu using GCC -to produce an ELF executable. If your kernel version is 1.2.13 then apply the patch in the Kernel_patch file. diff -Nurd linux86.old/elksemu/Security linux86/elksemu/Security --- linux86.old/elksemu/Security Sat Apr 13 20:24:34 1996 +++ linux86/elksemu/Security Mon Jan 19 22:38:17 2004 @@ -1,4 +1,4 @@ -The install scripts now install /lib/elksemu as a suid-root executable. +Is is possible to install /usr/bin/elksemu as a suid-root executable. This gives two additional facilities when running elks executables. 1) It is now possible to run programs that are execute only, without diff -Nurd linux86.old/elksemu/elks.c linux86/elksemu/elks.c --- linux86.old/elksemu/elks.c Fri Feb 6 19:05:29 1998 +++ linux86/elksemu/elks.c Sat Jan 24 10:40:44 2004 @@ -223,7 +223,8 @@ *pip++ = 0; } -void main(int argc, char *argv[], char *envp[]) +int +main(int argc, char *argv[], char *envp[]) { int fd; struct stat st; @@ -258,7 +259,7 @@ setregid(rgid, egid); setreuid(ruid, euid); - dbprintf(("ELKSEMU 0.12.0\n")); + dbprintf(("ELKSEMU\n")); elks_init(); /* The Linux vm will deal with not allocating the unused pages */ diff -Nurd linux86.old/elksemu/elks.h linux86/elksemu/elks.h --- linux86.old/elksemu/elks.h Mon May 12 20:24:49 1997 +++ linux86/elksemu/elks.h Sun Jan 18 12:33:09 2004 @@ -24,17 +24,17 @@ struct elks_stat { - unsigned short st_dev; - unsigned short st_inode; - unsigned short st_mode; - unsigned short st_nlink; - unsigned short st_uid; - unsigned short st_gid; - unsigned short st_rdev; - int st_size; - int st_atime; - int st_mtime; - int st_ctime; + unsigned short est_dev; + unsigned short est_inode; + unsigned short est_mode; + unsigned short est_nlink; + unsigned short est_uid; + unsigned short est_gid; + unsigned short est_rdev; + int est_size; + int est_atime; + int est_mtime; + int est_ctime; }; diff -Nurd linux86.old/elksemu/elks_sys.c linux86/elksemu/elks_sys.c --- linux86.old/elksemu/elks_sys.c Sun May 26 09:18:29 2002 +++ linux86/elksemu/elks_sys.c Mon Jan 19 22:13:45 2004 @@ -24,6 +24,8 @@ #include #include "elks.h" +#include "efile.h" + #ifdef DEBUG #define dbprintf(x) db_printf x #else @@ -69,17 +71,17 @@ ELKS_POKE(long, bx+26, s->st_ctime); #else struct elks_stat * ms = ELKS_PTR(struct elks_stat, bx); - ms->st_dev=s->st_dev; - ms->st_inode=(unsigned short)s->st_ino; /* Bits lost */ - ms->st_mode=s->st_mode; - ms->st_nlink=s->st_nlink; - ms->st_uid=s->st_uid; - ms->st_gid=s->st_gid; - ms->st_rdev=s->st_rdev; - ms->st_size=s->st_size; - ms->st_atime=s->st_atime; - ms->st_mtime=s->st_mtime; - ms->st_ctime=s->st_ctime; + ms->est_dev=s->st_dev; + ms->est_inode=(unsigned short)s->st_ino; /* Bits lost */ + ms->est_mode=s->st_mode; + ms->est_nlink=s->st_nlink; + ms->est_uid=s->st_uid; + ms->est_gid=s->st_gid; + ms->est_rdev=s->st_rdev; + ms->est_size=s->st_size; + ms->est_atime=s->st_atime; + ms->est_mtime=s->st_mtime; + ms->est_ctime=s->st_ctime; #endif } @@ -142,6 +144,17 @@ dbprintf(("open(%s, %d, %d)\n", dp,cx,dx)); + /* Nasty hack so /lib/liberror.txt doesn't exist on the host. + */ + if (strcmp(dp, "/lib/liberror.txt") == 0 ) { + int fd = open("/tmp/liberror.txt", O_CREAT|O_EXCL|O_RDWR, 0666); + if (fd < 0) return fd; + unlink("/tmp/liberror.txt"); + write(fd, efile, sizeof(efile)); + lseek(fd, 0L, 0); + return fd; + } + if( cx == O_RDONLY ) { if(stat(dp,&s)==-1) @@ -451,7 +464,7 @@ ct=0; if( is_elks ) { - argp[0]="/lib/elksemu"; + argp[0]="/usr/bin/elksemu"; /* argp[1]=ELKS_PTR(char, bx); */ ct=1; } diff -Nurd linux86.old/elksemu/mkefile linux86/elksemu/mkefile --- linux86.old/elksemu/mkefile Thu Jan 1 01:00:00 1970 +++ linux86/elksemu/mkefile Mon Jan 19 21:53:14 2004 @@ -0,0 +1,11 @@ +#!/bin/sh - + +awk ' +BEGIN { + printf "char efile[] =\n" +} +{ printf " \"%s\\n\"\n", $0 } +END{ + printf ";\n"; +} +' < "$1" > efile.h diff -Nurd linux86.old/ld/ld.c linux86/ld/ld.c --- linux86.old/ld/ld.c Tue Oct 7 07:53:36 2003 +++ linux86/ld/ld.c Wed Jan 21 21:17:09 2004 @@ -53,13 +53,15 @@ PRIVATE char *expandlib(fn) char *fn; { - char *path; + char *path, *s; int i; for (i = lastlib - 1; i >= 0; --i) { - path = ourmalloc(strlen(libs[i]) + strlen(fn) + 1); + path = ourmalloc(strlen(libs[i]) + strlen(fn) + 2); strcpy(path, libs[i]); + s = path + strlen(path); + if (s!=path && s[-1] != '/') strcat(path, "/"); strcat(path, fn); if (access(path, R_OK) == 0) return path; diff -Nurd linux86.old/ld/objdump86.c linux86/ld/objdump86.c --- linux86.old/ld/objdump86.c Tue Oct 7 20:49:05 2003 +++ linux86/ld/objdump86.c Fri Jan 2 21:49:37 2004 @@ -79,6 +79,7 @@ int byte_order = 0; long size_text, size_data, size_bss; +long tot_size_text=0, tot_size_data=0, tot_size_bss=0; int main(argc, argv) @@ -118,6 +119,12 @@ for(ar=1; ar +Copyright (C) 1996,2004 Robert de Bath This file is part of the Linux-8086 C library and is distributed under the GNU Library General Public License. -These routines assume the existance of a file /usr/lib/liberror.txt, -this file contains the actual error messages. One useful feature, -the language of the error messages can be easily changed. +The file "liberror.txt" is the master list of errors for ELKS only. +WARNING: + If you use the -Mf compile style this file must be in the filessystem + as "/lib/liberror.txt" unless you're using elksemu. -Robert diff -Nurd linux86.old/libc/error/error.c linux86/libc/error/error.c --- linux86.old/libc/error/error.c Thu Feb 15 20:16:24 1996 +++ linux86/libc/error/error.c Mon Jan 19 21:10:31 2004 @@ -24,7 +24,7 @@ } if( err <= 0 ) goto unknown; /* NB the <= allows comments in the file */ - fd = open("/usr/lib/liberror.txt", 0); + fd = open("/lib/liberror.txt", 0); if( fd < 0 ) goto unknown; while( (cc=read(fd, inbuf, sizeof(inbuf))) > 0 ) diff -Nurd linux86.old/libc/error/error2.c linux86/libc/error/error2.c --- linux86.old/libc/error/error2.c Thu Jan 1 01:00:00 1970 +++ linux86/libc/error/error2.c Mon Jan 19 21:30:58 2004 @@ -0,0 +1,21 @@ +/* Copyright (C) 1996,2004 Robert de Bath + * This file is part of the Linux-8086 C library and is distributed + * under the GNU Library General Public License. + */ +#include + +#include "error_list.h" + +char * +strerror(err) +int err; +{ + static char retbuf[20]; + + if( err > 0 && err <= sys_nerr ) + return sys_errlist[err]; + + strcpy(retbuf, "Error "); + strcpy(retbuf+6, itoa(err)); + return retbuf; +} diff -Nurd linux86.old/libc/error/mktab.sh linux86/libc/error/mktab.sh --- linux86.old/libc/error/mktab.sh Thu Jan 1 01:00:00 1970 +++ linux86/libc/error/mktab.sh Mon Jan 19 20:57:55 2004 @@ -0,0 +1,25 @@ +#!/bin/sh - + +awk '{ + e=$0; + sub("^[^ ]* ", "", e); + sub(" [^ ]*$", "", e); + n=0+$1; + if (!(n in errlist)) + errlist[n] = e; + if(n > maxerr) maxerr=n; +} +END{ + printf ("#define NR_ERRORS\t%d\n", maxerr+1); + printf ("int sys_nerr = NR_ERRORS;\n"); + printf ("char *sys_errlist[NR_ERRORS] = {\n"); + + for(i=0; i<=maxerr; i++) { + if (errlist[i] == "") + printf(" \"Error %d\"", i); + else + printf(" \"%s\"", errlist[i]); + if (i != maxerr) printf(",\n"); else printf("\n"); + } + printf ("};\n"); +}' < liberror.txt > error_list.h diff -Nurd linux86.old/libc/error/sys_errlist.c linux86/libc/error/sys_errlist.c --- linux86.old/libc/error/sys_errlist.c Sun Oct 19 22:55:46 1997 +++ linux86/libc/error/sys_errlist.c Mon Jan 19 21:10:40 2004 @@ -42,7 +42,7 @@ int i, cc, fd, err, len, bufoff=0; char * ptr; - fd = open("/usr/lib/liberror.txt", 0); + fd = open("/lib/liberror.txt", 0); if( fd < 0 ) return; for(i=0; i1 ) { @@ -721,6 +722,14 @@ if( (cur_file_stat.st_mode&07777) != (last_mode&07777) ) printf(":%03o", cur_file_stat.st_mode & 07777); + major = (cur_file_stat.st_rdev >> 8); + minor = (cur_file_stat.st_rdev&0xFF); +#ifdef __linux__ + major &= 0xFFF; + minor |= ((cur_file_stat.st_rdev&0xFF000000)>>12); +#else + major &= 0xFF; +#endif switch(cur_file_stat.st_mode & S_IFMT) { case S_IFDIR: printf("\td"); break; @@ -728,11 +737,9 @@ #ifdef __HAS_SOCKETS case S_IFSOCK: printf("\ts"); break; #endif - case S_IFBLK: printf("\tb,%d,%d", cur_file_stat.st_rdev>>8, - cur_file_stat.st_rdev&0xFF); + case S_IFBLK: printf("\tb,%d,%d", major, minor); break; - case S_IFCHR: printf("\tc,%d,%d", cur_file_stat.st_rdev>>8, - cur_file_stat.st_rdev&0xFF); + case S_IFCHR: printf("\tc,%d,%d", major, minor); break; } last_mode = ((cur_file_stat.st_mode&07777)|S_IFREG); @@ -987,8 +994,8 @@ /* Try to preserve ownership. For non-root it might fail, but that's ok. But root probably wants to know, e.g. if NFS disallows it. */ - user = cur_file_stat.st_uid; if(set_user>=0) user = set_user; - group = cur_file_stat.st_gid; if(set_group>=0) group = set_group; + user = cur_file_stat.st_uid; if(set_user != -1) user = set_user; + group = cur_file_stat.st_gid; if(set_group != -1) group = set_group; if (chown (file, user, group) && (errno != EPERM || geteuid() == 0 || (flg_preserve==0 && flg_force==0))) @@ -1157,7 +1164,7 @@ } if( retv>=0 && cmd_tok == CMD_MKDIR ) { - if( set_user > 0 || set_group > 0 ) + if( set_user != -1 || set_group != -1 ) { if( chown(dirname, set_user, set_group) < 0) warning(errno, "Cannot change directory owner ", dirname); @@ -1173,12 +1180,19 @@ int cmd_mknod() { - int device; + int device, major, minor; int rv = -1; int mode=0666; if( set_mode >= 0 ) mode=set_mode; - device = (atoi(flist[2])<<8) + atoi(flist[3]); + major = atoi(flist[2]); + minor = atoi(flist[3]); +#ifdef __linux__ + /* Linux 2.6+ uses an odd arrangment. */ + device = (major<<8) + (minor & 0xFF) + ((minor & 0xFFF00) << 12); +#else + device = (major<<8) + (minor & 0xFF); +#endif if(flist[1][0] == 'b') rv = mknod(flist[0], S_IFBLK|mode, device); diff -Nurd linux86.old/bootblocks/Makefile linux86/bootblocks/Makefile --- linux86.old/bootblocks/Makefile Thu Jul 31 20:28:53 2003 +++ linux86/bootblocks/Makefile Sat Jan 24 10:55:38 2004 @@ -37,7 +37,8 @@ EXTRAS=minix.h zimage.s minix_elks.c lsys.c boot_win.c -install: +install: makeboot + install -m 755 -s makeboot $(DIST)$(PREFIX)/bin/makeboot monitor.com: $(MOBJ) $(CC) $(CFLAGS) $(LDFLAGS) $(MONDEFS) -d $(MOBJ) -o monitor.com -M > monitor.sym diff -Nurd linux86.old/bootblocks/boot_win.c linux86/bootblocks/boot_win.c --- linux86.old/bootblocks/boot_win.c Sun Sep 14 12:42:22 2003 +++ linux86/bootblocks/boot_win.c Mon Jan 19 17:00:23 2004 @@ -35,6 +35,7 @@ { int i, rv; int floppy_only = 0; + int c,h,s,os; reset_screen(); cprintf("...\n"); @@ -52,12 +53,29 @@ if (!floppy_only) { for(rv=-1, i=0x1BE; i<0x1FE; i+= 16) { - if (bs_buf[i] == (char)0x80) + if (bs_buf[i] == (char)0x80) { rv = 0; + s = (bs_buf[i+2] & 63) ; + h = (bs_buf[i+1] & 255) ; + c = (bs_buf[i+3] & 255) + ((bs_buf[i+2] & 0xC0) << 2); + + os = (bs_buf[i+4] & 255) ; + break; + } } if (rv) { cprintf("Hard disk has no active partition.\n"); + floppy_only = 1; + } + } + + if (!floppy_only && (os==4 || os==6 || os==11 || os==12 || os==13)) { + for(i=0; i<6; i++) + if (!(rv = _bios_disk_read(0x80, c, h, s, 1, bs_buf))) break; + + if (rv != 0 || bs_buf[510] != 0x55 || bs_buf[511] != (char)0xAA) { + cprintf("DOS Partition not bootable.\n"); floppy_only = 1; } }