diff -Nurd linux-86.old/Changes linux-86/Changes --- linux-86.old/Changes Tue Feb 25 19:25:28 1997 +++ linux-86/Changes Fri May 9 18:34:21 1997 @@ -1,3 +1,46 @@ +For version 0.12.0. + +> Notice the change in the version numbers, as long as I'm releasing the + upto the minute patches I thought I'd better give everyone a way of + keeping track. So now the 0.X.0 are the main releases, the 0.X.Y are + interim patches. + +> I've added a new output binary for ld86, it can now do the broken + relocatable a.out that bin86 produces. I don't like this but it + does let me move ld86 back to /usr/bin without breaking DOSEMU. + Note! If you've installed vsn 0.0.11 or earlier you will need to + uninstall it before installing this one. + +> Altered makefiles for GNU-make 3.74, GNU-make no longer generates + automatic 'rm' commands so I have to do it manually. + +> Altered makefiles again, starting to get non GNU makefile working. + +> Added some cleanups to ifdef.c. (voids etc) + +> Assembler now understands monadic '-' and '+' operations (for copt). + +> Improved the type conversion functions, they should now work on most + machines. There may still be some problems with sizeof(long) == 8 tho, + added some warnings/traps. + +> Improved the auto-detection and auto-rejection of ld is more + likely to compile even if a.out.h is completely incompatible (leaving + out native support). + +> Fix for stdio, there was a problem if the OS only did a partial write. + +> Alter align() macros to use ssize_t iff both __STDC__ and _POSIX_SOURCE + are defined. + +> Add some changes for compiling under AIX. Assember and BCC appear to work, + ld has problems with AIX's 'ar' command - problem: AIX's make and gmake + won't like the smell of a standard following ar86 command ... hmmm. + +> Changes in bootblocks, minix.c can now be compiled for a hard disk (works + on dosemu, dunno about the real thing tho), fixes for mbr.s re preboot + facility. Addition to minix.c to fix number of sectors in bpb for floppy. + For version 0.0.11. > New, most recent, version of unproto inserted. diff -Nurd linux-86.old/GNUmakefile linux-86/GNUmakefile --- linux-86.old/GNUmakefile Thu Jan 1 01:00:00 1970 +++ linux-86/GNUmakefile Thu Apr 24 20:21:14 1997 @@ -0,0 +1,13 @@ +# +# Flag that we're using GNU make. +# + +all: phony + @$(MAKE) -f Makefile IFDEFFLAGS=-DGNUMAKE $@ + +%: phony + @$(MAKE) -f Makefile IFDEFFLAGS=-DGNUMAKE $@ + +phony: ; + +GNUmakefile: ; diff -Nurd linux-86.old/Libc_version linux-86/Libc_version --- linux-86.old/Libc_version Tue Feb 25 19:41:51 1997 +++ linux-86/Libc_version Fri May 9 18:34:26 1997 @@ -1 +1 @@ -0.0.11 +0.12.0 diff -Nurd linux-86.old/Makefile linux-86/Makefile --- linux-86.old/Makefile Sat Feb 22 09:33:10 1997 +++ linux-86/Makefile Thu Apr 24 22:12:43 1997 @@ -2,10 +2,14 @@ # This file is part of the Linux-8086 Development environment and is # distributed under the GNU General Public License. -TARGETS=all bcc unproto copt as86 ld86 \ +TARGETS=bcc unproto copt as86 ld86 \ install install-all install-lib install-lib2 install-other \ clean tests alt-libs library config other +# Some makes take the last of a list as the default ... +all: make.fil + PATH="`pwd`/bin:$$PATH" $(MAKE) -f make.fil TOPDIR=`pwd` $@ + $(TARGETS): make.fil PATH="`pwd`/bin:$$PATH" $(MAKE) -f make.fil TOPDIR=`pwd` $@ @@ -14,7 +18,7 @@ realclean: [ ! -f make.fil ] || $(MAKE) -f make.fil TOPDIR=`pwd` $@ - rm -f make.fil ifdef + rm -f make.fil ifdef ifdef.o make.fil: ifdef makefile.in ./ifdef -MU makefile.in >tmp.mak @@ -23,11 +27,15 @@ ifdef: ifdef.o $(CC) -o ifdef ifdef.o +ifdef.o: ifdef.c + $(CC) $(CFLAGS) $(IFDEFFLAGS) -c ifdef.c + Uninstall: phony @echo 'Are you really sure... have you checked this... ^C to interrupt' @read line rm -rf /usr/bcc rm -f /usr/bin/bcc /usr/bin/as86_encap /usr/bin/dis88 + rm -f /usr/bin/as86 /usr/bin/ld86 rm -f /lib/elksemu rm -f /usr/lib/liberror.txt rm -f /usr/man/man1/elks.1* /usr/man/man1/elksemu.1* diff -Nurd linux-86.old/README linux-86/README --- linux-86.old/README Tue Feb 25 19:38:52 1997 +++ linux-86/README Sun Mar 23 11:15:54 1997 @@ -45,16 +45,6 @@ linux-i386 kernel but can replace them, the kernel-i386 ones _will_ _not_ work correctly here! -Unfortunatly, the DOSEMU folks have been using the '-r' option of ld86 -This version does accept '-r' (with -N) but it generates _LINUX_ a.out -object files. I think they should really be using 'as86_encap' but in -the short term DOSEMU is being changed to be able to use the new ld86. - -Neverthless this ld86 will call a program called /usr/bin/ld86r if it's -given -r without -N, this can be the old ld86 renamed. For simplicity -Dev86 doesn't yet overwrite /usr/bin/ld86 but stores the linker in -/usr/bcc/lib. - I _strongly_ suggest you install the kernel patch or load the module in the elksemu directory in your Linux-i386 kernel, it makes things _much_ easier. (They both need the elksemu executable installed correctly) diff -Nurd linux-86.old/as/Makefile linux-86/as/Makefile --- linux-86.old/as/Makefile Sun Jan 19 10:16:29 1997 +++ linux-86/as/Makefile Thu Apr 24 06:32:02 1997 @@ -23,7 +23,7 @@ install -d $(LIBDIR) install -m 755 as86 $(LIBDIR) install -d $(BINDIR) - install -m 755 tmp $(BINDIR)/as86_encap + install -m 755 as86_encap $(BINDIR)/as86_encap -@rm -f tmp clean realclean: diff -Nurd linux-86.old/as/align.h linux-86/as/align.h --- linux-86.old/as/align.h Thu Jan 1 01:00:00 1970 +++ linux-86/as/align.h Thu Apr 24 21:22:20 1997 @@ -0,0 +1,23 @@ +/* align.h - memory alignment requirements for linker */ + +/* Copyright (C) 1994 Bruce Evans */ + +#ifndef S_ALIGNMENT +# define align(x) +#else + +#if defined(__STDC__) && defined(_POSIX_SOURCE) +# define align(x) ((x)=(void *) \ + (((ssize_t)(x) + (S_ALIGNMENT-1)) & ~(S_ALIGNMENT-1))) +#else +# define align(x) ((x)=(void *) \ + ((char *)(x) + ((S_ALIGNMENT-(char)(x)) & (S_ALIGNMENT-1)))) +#endif +#endif + + + + + + + diff -Nurd linux-86.old/as/as.c linux-86/as/as.c --- linux-86.old/as/as.c Sat Jan 25 22:25:42 1997 +++ linux-86/as/as.c Sun Apr 13 12:33:32 1997 @@ -62,7 +62,7 @@ initbin(); initobj(); initsource(); /* only nec to init for unsupported mem file */ - typeconv_init(BIG_ENDIAN, LONG_BIG_ENDIAN); + typeconv_init(INT_BIG_ENDIAN, LONG_BIG_ENDIAN); as_warn.global = TRUE; /* constant */ last_pass=1; process_args(argc, argv); diff -Nurd linux-86.old/as/as86_encap.sh linux-86/as/as86_encap.sh --- linux-86.old/as/as86_encap.sh Sun Jan 19 10:47:10 1997 +++ linux-86/as/as86_encap.sh Thu Apr 24 06:46:30 1997 @@ -21,6 +21,7 @@ LIBDIR='%%LIBDIR%%' # Set by make install # If the one set by install fails then try a couple of others. +[ -x "$LIBDIR/as86" ] || LIBDIR="`dirname $0`" [ -x "$LIBDIR/as86" ] || LIBDIR="`dirname $0`/../lib" [ -x "$LIBDIR/as86" ] || LIBDIR=/usr/bin diff -Nurd linux-86.old/as/byteord.h linux-86/as/byteord.h --- linux-86.old/as/byteord.h Thu Aug 3 00:25:18 1989 +++ linux-86/as/byteord.h Sun Apr 13 12:33:14 1997 @@ -3,16 +3,16 @@ /* These are for the targets of everything and for linker source too. */ #ifdef I8086 -# define BIG_ENDIAN 0 +# define INT_BIG_ENDIAN 0 # define LONG_BIG_ENDIAN 0 /* except longs are back to front for Xenix */ #endif #ifdef I80386 -# define BIG_ENDIAN 0 +# define INT_BIG_ENDIAN 0 # define LONG_BIG_ENDIAN 0 #endif #ifdef MC6809 -# define BIG_ENDIAN 1 /* byte order in words is high-low */ +# define INT_BIG_ENDIAN 1 /* byte order in words is high-low */ # define LONG_BIG_ENDIAN 1 /* byte order in longs is high-low */ #endif diff -Nurd linux-86.old/as/const.h linux-86/as/const.h --- linux-86.old/as/const.h Sun Dec 1 07:09:07 1996 +++ linux-86/as/const.h Thu Apr 24 21:25:10 1997 @@ -2,20 +2,12 @@ /* Speed and space hacks for BCC */ #ifdef __AS386_16__ #define LOW_BYTE 0 /* must be changed for big-endian */ -#define align(x) /* Don't bother */ - -#endif - -#ifndef align -#ifdef MSDOS -#define align(x) -#endif -#endif +#else -#ifndef align /* Normal ... */ -#define align(x) ((x) = (void*)(((long) (x) + (4-1)) & ~(4-1))) +#define S_ALIGNMENT sizeof(long) #endif +#include "align.h" /* const.h - constants for assembler */ diff -Nurd linux-86.old/as/express.c linux-86/as/express.c --- linux-86.old/as/express.c Tue Jan 21 19:15:23 1997 +++ linux-86/as/express.c Mon Mar 10 19:19:44 1997 @@ -330,6 +330,16 @@ chkabs(); lastexp.offset = ~lastexp.offset; return; + case ADDOP: + getsym(); + factor(); + return; + case SUBOP: + getsym(); + factor(); + chkabs(); + lastexp.offset = -lastexp.offset; + return; case STAR: /* context-sensitive, STAR means location counter here */ lastexp.offset = lc; diff -Nurd linux-86.old/as/table.c linux-86/as/table.c --- linux-86.old/as/table.c Mon Jul 22 00:33:45 1996 +++ linux-86/as/table.c Sun Apr 13 12:52:52 1997 @@ -180,7 +180,7 @@ symptr->type = 0; symptr->data = inidata; symptr->length = length; - symptr->value_reg_or_op.value = (unsigned) (symptr->next = NUL_PTR); + symptr->value_reg_or_op.value = (offset_t) (symptr->next = NUL_PTR); heapptr = symptr->name; do *heapptr++ = *nameptr++; diff -Nurd linux-86.old/as/typeconv.c linux-86/as/typeconv.c --- linux-86.old/as/typeconv.c Sat Feb 1 09:47:34 1997 +++ linux-86/as/typeconv.c Fri Apr 25 21:02:43 1997 @@ -1,537 +1,187 @@ -/* typeconv.c - convert between char arrays and unsigneds */ - -/* Copyright (C) 1994 Bruce Evans */ /* - c2u2(): 2 byte array to 2 byte unsigned - c4u4(): 4 byte array to 4 byte unsigned - cnu2(): n byte array to 2 byte unsigned - cnu4(): n byte array to 4 byte unsigned - u2c2(): 2 byte unsigned to 2 byte array - u2cn(): 2 byte unsigned to n byte array - u4c4(): 4 byte unsigned to 4 byte array - u4cn(): 4 byte unsigned to n byte array - typeconv_init: (re)initialise for given byte order. - Default is no swapping, but the initialisation should be done - anyway to provide some validity checks (returns FALSE if error). - - Not provided: - c2u4(), c4u2(), u2c4(), u4c2(). - Each of these is best done by truncating or extending a return value - or argument to the appropiate fixed-count function. - c4u2() has too many cases to do in-line conveniently, and the others - are hardly more efficient when done in-line. - - 4 byte orderings for both char arrays and unsigneds are supported: - 0123 - little-endian - 3210 - big-endian - 2301 - little-endian with long words big-endian (pdp11) - 1032 - big-endian with long words little_endian (who knows?) - - The unsigned's byte order is that of the machine on which these - routines are running. - It is determined at run time initialisation since the compiler/ - preprocessor is too dumb to tell us at compile time. -*/ + * Type conversion routines, these have been rewritten for portability. + * + * The only requirement is now that the u2_t and u4_t must be big enough. + */ #include "syshead.h" #include "const.h" #include "type.h" #include "globvar.h" -FORWARD u2_pt c2u2_00 P((char *buf)); -FORWARD u4_pt c4u4_00 P((char *buf)); -FORWARD u2_pt c2u2_ss P((char *buf)); -FORWARD u4_pt c4u4_ss P((char *buf)); -FORWARD u4_pt c4u4_s0 P((char *buf)); -FORWARD u4_pt c4u4_0s P((char *buf)); -FORWARD void u2c2_00 P((char *buf, u2_pt offset)); -FORWARD void u4c4_00 P((char *buf, u4_t offset)); -FORWARD void u2c2_ss P((char *buf, u2_pt offset)); -FORWARD void u4c4_ss P((char *buf, u4_t offset)); -FORWARD void u4c4_s0 P((char *buf, u4_t offset)); -FORWARD void u4c4_0s P((char *buf, u4_t offset)); - -PRIVATE u2_pt (*pc2u2) P((char *buf)) = c2u2_00; -PRIVATE u4_pt (*pc4u4) P((char *buf)) = c4u4_00; -PRIVATE void (*pu2c2) P((char *buf, u2_pt offset)) = u2c2_00; -PRIVATE void (*pu4c4) P((char *buf, u4_t offset)) = u4c4_00; - -/* === char arrays to unsigneds === */ - -/* no bytes swapped, longwinded to avoid alignment problems */ - -PRIVATE u2_pt c2u2_00(buf) -register char *buf; -{ - u2_t offset; - - ((char *) &offset)[0] = buf[0]; - ((char *) &offset)[1] = buf[1]; - return offset; -} - -PRIVATE u4_pt c4u4_00(buf) -register char *buf; -{ - u4_t offset; - - ((char *) &offset)[0] = buf[0]; - ((char *) &offset)[1] = buf[1]; - ((char *) &offset)[2] = buf[2]; - ((char *) &offset)[3] = buf[3]; - return offset; -} - -/* straight swapping for little-endian to big-endian and vice versa */ - -PRIVATE u2_pt c2u2_ss(buf) -register char *buf; -{ - u2_t offset; - - ((char *) &offset)[0] = buf[1]; - ((char *) &offset)[1] = buf[0]; - return offset; -} - -PRIVATE u4_pt c4u4_ss(buf) -register char *buf; -{ - u4_t offset; +void xxerr P((char *)); +void xxerr(x) char * x; { write(2, x, strlen(x)); } - ((char *) &offset)[0] = buf[3]; - ((char *) &offset)[1] = buf[2]; - ((char *) &offset)[2] = buf[1]; - ((char *) &offset)[3] = buf[0]; - return offset; -} +static int no_swap = 1; -/* wierd swapping for different-endian u2's, same-endian u4's */ +static long_off[4] = {0,1,2,3}; +static int_off[2] = {0,1}; -PRIVATE u4_pt c4u4_s0(buf) -register char *buf; +PUBLIC bool_pt typeconv_init(big_endian, long_big_endian) +bool_pt big_endian; +bool_pt long_big_endian; { - u4_t offset; - - ((char *) &offset)[0] = buf[1]; - ((char *) &offset)[1] = buf[0]; - ((char *) &offset)[2] = buf[3]; - ((char *) &offset)[3] = buf[2]; - return offset; -} + int i; + no_swap = (!big_endian && !long_big_endian); -/* very wierd swapping for same-endian u2's, different-endian u4's */ + for(i=0; i<4; i++) long_off[i] = i; + for(i=0; i<2; i++) int_off[i] = i; -PRIVATE u4_pt c4u4_0s(buf) -register char *buf; -{ - u4_t offset; + if( long_big_endian ) + { + i = long_off[0]; long_off[0] = long_off[2]; long_off[2] = i; + i = long_off[1]; long_off[1] = long_off[3]; long_off[3] = i; + } + if( big_endian ) + { + i = long_off[2]; long_off[2] = long_off[3]; long_off[3] = i; + i = long_off[0]; long_off[0] = long_off[1]; long_off[1] = i; - ((char *) &offset)[0] = buf[2]; - ((char *) &offset)[1] = buf[3]; - ((char *) &offset)[2] = buf[0]; - ((char *) &offset)[3] = buf[1]; - return offset; + i = int_off[0]; int_off[0] = int_off[1]; int_off[1] = i; + } + return 1; } -/* === entry points === */ - -PUBLIC u2_pt c2u2(buf) +PUBLIC void u2c2(buf, offset) char *buf; +u2_pt offset; { - return (*pc2u2) (buf); +#ifdef __AS386_16__ + if( no_swap ) + { + *((unsigned short*)buf) = offset; /* UNALIGNED ACCESS! */ + return; + } +#endif + buf[int_off[0]] = offset; + buf[int_off[1]] = (offset>>8); } -PUBLIC u4_t c4u4(buf) +PUBLIC void u4c4(buf, offset) char *buf; +u4_t offset; { - return (*pc4u4) (buf); + int i; +#ifdef __AS386_16__ + if( no_swap ) + { + *((unsigned long*)buf) = offset; /* UNALIGNED ACCESS! */ + return; + } +#endif + for(i=0; i<4; i++) + { + buf[long_off[i]] = offset; + offset >>= 8; + } } -PUBLIC u2_pt cnu2(buf, count) +PUBLIC void u4cn(buf, offset, count) char *buf; +u4_t offset; unsigned count; { - switch (count) + switch(count) { case 1: - return buf[0] & 0xFF; + buf[0] = (char) offset; + return; case 2: - return (*pc2u2) (buf); + u2c2(buf, (u2_pt) offset); + return; case 4: - return (u2_pt) (*pc4u4) (buf); + u4c4(buf, (u4_t) offset); + return; default: - return 0; + xxerr("WARNING: typeconv.c(u4cn) illegal count\n"); + return; } } -PUBLIC u4_t cnu4(buf, count) +PUBLIC void u2cn(buf, offset, count) char *buf; +u2_pt offset; unsigned count; { - switch (count) + switch(count) { case 1: - return buf[0] & 0xFF; + buf[0] = (char) offset; + return; case 2: - return (*pc2u2) (buf); + u2c2(buf, (u2_pt) offset); + return; case 4: - return (*pc4u4) (buf); + u4c4(buf, (u4_t) offset); + return; default: - return 0; + xxerr("WARNING: typeconv.c(u2cn) illegal count\n"); + return; } } -/* === unsigneds to char arrays === */ - -/* no bytes swapped, longwinded to avoid alignment problems */ - -PRIVATE void u2c2_00(buf, offset) -register char *buf; -u2_pt offset; -{ - - buf[0] = ((char *) &offset)[0]; - buf[1] = ((char *) &offset)[1]; -} - -PRIVATE void u4c4_00(buf, offset) -register char *buf; -u4_t offset; -{ - buf[0] = ((char *) &offset)[0]; - buf[1] = ((char *) &offset)[1]; - buf[2] = ((char *) &offset)[2]; - buf[3] = ((char *) &offset)[3]; -} - -/* straight swapping for little-endian to big-endian and vice versa */ - -PRIVATE void u2c2_ss(buf, offset) -register char *buf; -u2_pt offset; -{ - u2_t offset2; - - offset2 = offset; - buf[0] = ((char *) &offset2)[1]; - buf[1] = ((char *) &offset2)[0]; -} - -PRIVATE void u4c4_ss(buf, offset) -register char *buf; -u4_t offset; -{ - buf[0] = ((char *) &offset)[3]; - buf[1] = ((char *) &offset)[2]; - buf[2] = ((char *) &offset)[1]; - buf[3] = ((char *) &offset)[0]; -} - -/* wierd swapping for different-endian u2's, same-endian u4's */ - -PRIVATE void u4c4_s0(buf, offset) -register char *buf; -u4_t offset; -{ - buf[0] = ((char *) &offset)[1]; - buf[1] = ((char *) &offset)[0]; - buf[2] = ((char *) &offset)[3]; - buf[3] = ((char *) &offset)[2]; -} - -/* very wierd swapping for same-endian u2's, different-endian u4's */ - -PRIVATE void u4c4_0s(buf, offset) -register char *buf; -u4_t offset; +PUBLIC u2_pt c2u2(buf) +char *buf; { - buf[0] = ((char *) &offset)[2]; - buf[1] = ((char *) &offset)[3]; - buf[2] = ((char *) &offset)[0]; - buf[3] = ((char *) &offset)[1]; -} - -/* === entry points === */ + u2_pt res; +#ifdef __AS386_16__ + if( no_swap ) return *((u2_pt *)buf); /* UNALIGNED ACCESS! */ +#endif -PUBLIC void u2c2(buf, offset) -register char *buf; -u2_pt offset; -{ - (*pu2c2) (buf, offset); + res = ((unsigned char *)buf) [int_off[0]] + + ((((unsigned char *)buf) [int_off[1]]) << 8); + return res; } -PUBLIC void u4c4(buf, offset) -register char *buf; -u4_t offset; +PUBLIC u4_t c4u4(buf) +char *buf; { - (*pu4c4) (buf, offset); + u4_t res; + int i; +#ifdef __AS386_16__ + if( no_swap ) return *((u4_t *)buf); /* UNALIGNED ACCESS! */ +#endif + res = 0; + for(i=3; i>=0; i--) + { + res = (res<<8) + ((unsigned char *)buf) [long_off[i]]; + } + return res; } -PUBLIC void u2cn(buf, offset, count) -register char *buf; -u2_pt offset; +PUBLIC u4_t cnu4(buf, count) +char *buf; unsigned count; { switch (count) { case 1: - buf[0] = (char) offset; - return; + return buf[0] & 0xFF; case 2: - (*pu2c2) (buf, offset); - return; + return c2u2(buf); case 4: - (*pu4c4) (buf, (u4_t) offset); - return; + return c4u4(buf); + default: + xxerr("WARNING: typeconv.c(cnu4) illegal count\n"); + return 0; } } -PUBLIC void u4cn(buf, offset, count) -register char *buf; -u4_t offset; +PUBLIC u2_pt cnu2(buf, count) +char *buf; unsigned count; { switch (count) { case 1: - buf[0] = (char) offset; - return; + return buf[0] & 0xFF; case 2: - (*pu2c2) (buf, (u2_pt) (u2_t) offset); - return; + return c2u2(buf); case 4: - (*pu4c4) (buf, offset); - return; - } -} - -/* initialise type conversion, return FALSE if it cannot be handled */ - -PUBLIC bool_pt typeconv_init(big_endian, long_big_endian) -bool_pt big_endian; -bool_pt long_big_endian; -{ - u2_pt conv2; - u4_pt conv4; - char *conv2ptr; - char *conv4ptr; - - if (sizeof(u2_t) != 2 || sizeof(u4_t) != 4) - /* dumb preprocessor's don't accept sizeof in #if expressions */ - return FALSE; - - if (big_endian) - { - conv2ptr = (conv4ptr = "\1\2\3\4") + 2; - if (!long_big_endian) - conv4ptr = "\3\4\1\2"; - } - else - { - conv2ptr = conv4ptr = "\4\3\2\1"; - if (long_big_endian) - conv4ptr = "\2\1\4\3"; - } - conv2 = c2u2_00(conv2ptr); - conv4 = c4u4_00(conv4ptr); - if (conv2 == 0x0304) - { - pc2u2 = c2u2_00; - pc4u4 = c4u4_00; - pu2c2 = u2c2_00; - pu4c4 = u4c4_00; - if (conv4 == 0x03040102L) - { - pc4u4 = c4u4_0s; - pu4c4 = u4c4_0s; - } - else if (conv4 != 0x01020304L) - return FALSE; - } - else if (conv2 == 0x0403) - { - pc2u2 = c2u2_ss; - pc4u4 = c4u4_ss; - pu2c2 = u2c2_ss; - pu4c4 = u4c4_ss; - if (conv4 == 0x02010403L) - { - pc4u4 = c4u4_s0; - pu4c4 = u4c4_s0; - } - else if (conv4 != 0x04030201L) - return FALSE; + return (u2_pt) c4u4(buf); + default: + xxerr("WARNING: typeconv.c(cnu2) illegal count\n"); + return 0; } - else - return FALSE; - return TRUE; } - -#ifdef DEBUG_TYPECONV - -main() -{ - char *source; - char target[4]; - u2_t u2; - u2_t u2a; - u4_t u4; - u4_t u4a; - - printf("%u\n", typeconv_init(FALSE, FALSE)); - printf("%u\n", typeconv_init(FALSE, TRUE)); - printf("%u\n", typeconv_init(TRUE, FALSE)); - printf("%u\n", typeconv_init(TRUE, TRUE)); - - typeconv_init(FALSE, FALSE); - source = "\4\3\2\1"; - - target[0] = 0; - target[1] = 0; - u2 = cnu2(source, 2); - u2cn(target, u2, 2); - if (strncmp(source, target, 2)) - printf("oops9\n"); - - target[0] = 0; - target[1] = 0; - u4a = cnu4(source, 2); - u4cn(target, u4a, 2); - if (strncmp(source, target, 2)) - printf("oops10\n"); - - target[0] = 0; - target[1] = 0; - target[2] = 0; - target[3] = 0; - u2a = cnu2(source, 4); - u2cn(target, u2a, 4); - if (strncmp(target, "\4\3\0\0", 4)) - printf("oops11\n"); - - target[0] = 0; - target[1] = 0; - target[2] = 0; - target[3] = 0; - u4 = cnu4(source, 4); - u4cn(target, u4, 4); - if (strncmp(source, target, 4)) - printf("oops12\n"); - - printf("%04x %04x %08lx %08lx\n", u2, u2a, u4, u4a); - - typeconv_init(FALSE, TRUE); - source = "\2\1\4\3"; - - target[0] = 0; - target[1] = 0; - u2 = cnu2(source + 2, 2); - u2cn(target, u2, 2); - if (strncmp(source + 2, target, 2)) - printf("oops13\n"); - - target[0] = 0; - target[1] = 0; - u4a = cnu4(source + 2, 2); - u4cn(target, u4a, 2); - if (strncmp(source + 2, target, 2)) - printf("oops14\n"); - - target[0] = 0; - target[1] = 0; - target[2] = 0; - target[3] = 0; - u2a = cnu2(source, 4); - u2cn(target, u2a, 4); - if (strncmp(target, "\0\0\4\3", 4)) - printf("oops15\n"); - - target[0] = 0; - target[1] = 0; - target[2] = 0; - target[3] = 0; - u4 = cnu4(source, 4); - u4cn(target, u4, 4); - if (strncmp(source, target, 4)) - printf("oops16\n"); - - printf("%04x %04x %08lx %08lx\n", u2, u2a, u4, u4a); - - typeconv_init(TRUE, FALSE); - source = "\3\4\1\2"; - - target[0] = 0; - target[1] = 0; - u2 = cnu2(source, 2); - u2cn(target, u2, 2); - if (strncmp(source, target, 2)) - printf("oops5\n"); - - target[0] = 0; - target[1] = 0; - u4a = cnu4(source, 2); - u4cn(target, u4a, 2); - if (strncmp(source, target, 2)) - printf("oops6\n"); - - target[0] = 0; - target[1] = 0; - target[2] = 0; - target[3] = 0; - u2a = cnu2(source, 4); - u2cn(target, u2a, 4); - if (strncmp(target, "\3\4\0\0", 4)) - printf("oops7\n"); - - target[0] = 0; - target[1] = 0; - target[2] = 0; - target[3] = 0; - u4 = cnu4(source, 4); - u4cn(target, u4, 4); - if (strncmp(source, target, 4)) - printf("oops8\n"); - - printf("%04x %04x %08lx %08lx\n", u2, u2a, u4, u4a); - - typeconv_init(TRUE, TRUE); - source = "\1\2\3\4"; - - target[0] = 0; - target[1] = 0; - u2 = cnu2(source + 2, 2); - u2cn(target, u2, 2); - if (strncmp(source + 2, target, 2)) - printf("oops1\n"); - - target[0] = 0; - target[1] = 0; - u4a = cnu4(source + 2, 2); - u4cn(target, u4a, 2); - if (strncmp(source + 2, target, 2)) - printf("oops2\n"); - - target[0] = 0; - target[1] = 0; - target[2] = 0; - target[3] = 0; - u2a = cnu2(source, 4); - u2cn(target, u2a, 4); - if (strncmp(target, "\0\0\3\4", 4)) - printf("oops3\n"); - - target[0] = 0; - target[1] = 0; - target[2] = 0; - target[3] = 0; - u4 = cnu4(source, 4); - u4cn(target, u4, 4); - if (strncmp(source, target, 4)) - printf("oops4\n"); - - printf("%04x %04x %08lx %08lx\n", u2, u2a, u4, u4a); -} - -#endif /* DEBUG_TYPECONV */ diff -Nurd linux-86.old/as/typeconv.c.old linux-86/as/typeconv.c.old --- linux-86.old/as/typeconv.c.old Thu Jan 1 01:00:00 1970 +++ linux-86/as/typeconv.c.old Sun Apr 13 15:48:04 1997 @@ -0,0 +1,537 @@ +/* typeconv.c - convert between char arrays and unsigneds */ + +/* Copyright (C) 1994 Bruce Evans */ + +/* + c2u2(): 2 byte array to 2 byte unsigned + c4u4(): 4 byte array to 4 byte unsigned + cnu2(): n byte array to 2 byte unsigned + cnu4(): n byte array to 4 byte unsigned + u2c2(): 2 byte unsigned to 2 byte array + u2cn(): 2 byte unsigned to n byte array + u4c4(): 4 byte unsigned to 4 byte array + u4cn(): 4 byte unsigned to n byte array + typeconv_init: (re)initialise for given byte order. + Default is no swapping, but the initialisation should be done + anyway to provide some validity checks (returns FALSE if error). + + Not provided: + c2u4(), c4u2(), u2c4(), u4c2(). + Each of these is best done by truncating or extending a return value + or argument to the appropiate fixed-count function. + c4u2() has too many cases to do in-line conveniently, and the others + are hardly more efficient when done in-line. + + 4 byte orderings for both char arrays and unsigneds are supported: + 0123 - little-endian + 3210 - big-endian + 2301 - little-endian with long words big-endian (pdp11) + 1032 - big-endian with long words little_endian (who knows?) + + The unsigned's byte order is that of the machine on which these + routines are running. + It is determined at run time initialisation since the compiler/ + preprocessor is too dumb to tell us at compile time. +*/ + +#include "syshead.h" +#include "const.h" +#include "type.h" +#include "globvar.h" + +FORWARD u2_pt c2u2_00 P((char *buf)); +FORWARD u4_pt c4u4_00 P((char *buf)); +FORWARD u2_pt c2u2_ss P((char *buf)); +FORWARD u4_pt c4u4_ss P((char *buf)); +FORWARD u4_pt c4u4_s0 P((char *buf)); +FORWARD u4_pt c4u4_0s P((char *buf)); +FORWARD void u2c2_00 P((char *buf, u2_pt offset)); +FORWARD void u4c4_00 P((char *buf, u4_t offset)); +FORWARD void u2c2_ss P((char *buf, u2_pt offset)); +FORWARD void u4c4_ss P((char *buf, u4_t offset)); +FORWARD void u4c4_s0 P((char *buf, u4_t offset)); +FORWARD void u4c4_0s P((char *buf, u4_t offset)); + +PRIVATE u2_pt (*pc2u2) P((char *buf)) = c2u2_00; +PRIVATE u4_pt (*pc4u4) P((char *buf)) = c4u4_00; +PRIVATE void (*pu2c2) P((char *buf, u2_pt offset)) = u2c2_00; +PRIVATE void (*pu4c4) P((char *buf, u4_t offset)) = u4c4_00; + +/* === char arrays to unsigneds === */ + +/* no bytes swapped, longwinded to avoid alignment problems */ + +PRIVATE u2_pt c2u2_00(buf) +register char *buf; +{ + u2_t offset; + + ((char *) &offset)[0] = buf[0]; + ((char *) &offset)[1] = buf[1]; + return offset; +} + +PRIVATE u4_pt c4u4_00(buf) +register char *buf; +{ + u4_t offset; + + ((char *) &offset)[0] = buf[0]; + ((char *) &offset)[1] = buf[1]; + ((char *) &offset)[2] = buf[2]; + ((char *) &offset)[3] = buf[3]; + return offset; +} + +/* straight swapping for little-endian to big-endian and vice versa */ + +PRIVATE u2_pt c2u2_ss(buf) +register char *buf; +{ + u2_t offset; + + ((char *) &offset)[0] = buf[1]; + ((char *) &offset)[1] = buf[0]; + return offset; +} + +PRIVATE u4_pt c4u4_ss(buf) +register char *buf; +{ + u4_t offset; + + ((char *) &offset)[0] = buf[3]; + ((char *) &offset)[1] = buf[2]; + ((char *) &offset)[2] = buf[1]; + ((char *) &offset)[3] = buf[0]; + return offset; +} + +/* wierd swapping for different-endian u2's, same-endian u4's */ + +PRIVATE u4_pt c4u4_s0(buf) +register char *buf; +{ + u4_t offset; + + ((char *) &offset)[0] = buf[1]; + ((char *) &offset)[1] = buf[0]; + ((char *) &offset)[2] = buf[3]; + ((char *) &offset)[3] = buf[2]; + return offset; +} + +/* very wierd swapping for same-endian u2's, different-endian u4's */ + +PRIVATE u4_pt c4u4_0s(buf) +register char *buf; +{ + u4_t offset; + + ((char *) &offset)[0] = buf[2]; + ((char *) &offset)[1] = buf[3]; + ((char *) &offset)[2] = buf[0]; + ((char *) &offset)[3] = buf[1]; + return offset; +} + +/* === entry points === */ + +PUBLIC u2_pt c2u2(buf) +char *buf; +{ + return (*pc2u2) (buf); +} + +PUBLIC u4_t c4u4(buf) +char *buf; +{ + return (*pc4u4) (buf); +} + +PUBLIC u2_pt cnu2(buf, count) +char *buf; +unsigned count; +{ + switch (count) + { + case 1: + return buf[0] & 0xFF; + case 2: + return (*pc2u2) (buf); + case 4: + return (u2_pt) (*pc4u4) (buf); + default: + return 0; + } +} + +PUBLIC u4_t cnu4(buf, count) +char *buf; +unsigned count; +{ + switch (count) + { + case 1: + return buf[0] & 0xFF; + case 2: + return (*pc2u2) (buf); + case 4: + return (*pc4u4) (buf); + default: + return 0; + } +} + +/* === unsigneds to char arrays === */ + +/* no bytes swapped, longwinded to avoid alignment problems */ + +PRIVATE void u2c2_00(buf, offset) +register char *buf; +u2_pt offset; +{ + + buf[0] = ((char *) &offset)[0]; + buf[1] = ((char *) &offset)[1]; +} + +PRIVATE void u4c4_00(buf, offset) +register char *buf; +u4_t offset; +{ + buf[0] = ((char *) &offset)[0]; + buf[1] = ((char *) &offset)[1]; + buf[2] = ((char *) &offset)[2]; + buf[3] = ((char *) &offset)[3]; +} + +/* straight swapping for little-endian to big-endian and vice versa */ + +PRIVATE void u2c2_ss(buf, offset) +register char *buf; +u2_pt offset; +{ + u2_t offset2; + + offset2 = offset; + buf[0] = ((char *) &offset2)[1]; + buf[1] = ((char *) &offset2)[0]; +} + +PRIVATE void u4c4_ss(buf, offset) +register char *buf; +u4_t offset; +{ + buf[0] = ((char *) &offset)[3]; + buf[1] = ((char *) &offset)[2]; + buf[2] = ((char *) &offset)[1]; + buf[3] = ((char *) &offset)[0]; +} + +/* wierd swapping for different-endian u2's, same-endian u4's */ + +PRIVATE void u4c4_s0(buf, offset) +register char *buf; +u4_t offset; +{ + buf[0] = ((char *) &offset)[1]; + buf[1] = ((char *) &offset)[0]; + buf[2] = ((char *) &offset)[3]; + buf[3] = ((char *) &offset)[2]; +} + +/* very wierd swapping for same-endian u2's, different-endian u4's */ + +PRIVATE void u4c4_0s(buf, offset) +register char *buf; +u4_t offset; +{ + buf[0] = ((char *) &offset)[2]; + buf[1] = ((char *) &offset)[3]; + buf[2] = ((char *) &offset)[0]; + buf[3] = ((char *) &offset)[1]; +} + +/* === entry points === */ + +PUBLIC void u2c2(buf, offset) +register char *buf; +u2_pt offset; +{ + (*pu2c2) (buf, offset); +} + +PUBLIC void u4c4(buf, offset) +register char *buf; +u4_t offset; +{ + (*pu4c4) (buf, offset); +} + +PUBLIC void u2cn(buf, offset, count) +register char *buf; +u2_pt offset; +unsigned count; +{ + switch (count) + { + case 1: + buf[0] = (char) offset; + return; + case 2: + (*pu2c2) (buf, offset); + return; + case 4: + (*pu4c4) (buf, (u4_t) offset); + return; + } +} + +PUBLIC void u4cn(buf, offset, count) +register char *buf; +u4_t offset; +unsigned count; +{ + switch (count) + { + case 1: + buf[0] = (char) offset; + return; + case 2: + (*pu2c2) (buf, (u2_pt) (u2_t) offset); + return; + case 4: + (*pu4c4) (buf, offset); + return; + } +} + +/* initialise type conversion, return FALSE if it cannot be handled */ + +PUBLIC bool_pt typeconv_init(big_endian, long_big_endian) +bool_pt big_endian; +bool_pt long_big_endian; +{ + u2_pt conv2; + u4_pt conv4; + char *conv2ptr; + char *conv4ptr; + + if (sizeof(u2_t) != 2 || sizeof(u4_t) != 4) + /* dumb preprocessor's don't accept sizeof in #if expressions */ + return FALSE; + + if (big_endian) + { + conv2ptr = (conv4ptr = "\1\2\3\4") + 2; + if (!long_big_endian) + conv4ptr = "\3\4\1\2"; + } + else + { + conv2ptr = conv4ptr = "\4\3\2\1"; + if (long_big_endian) + conv4ptr = "\2\1\4\3"; + } + conv2 = c2u2_00(conv2ptr); + conv4 = c4u4_00(conv4ptr); + if (conv2 == 0x0304) + { + pc2u2 = c2u2_00; + pc4u4 = c4u4_00; + pu2c2 = u2c2_00; + pu4c4 = u4c4_00; + if (conv4 == 0x03040102L) + { + pc4u4 = c4u4_0s; + pu4c4 = u4c4_0s; + } + else if (conv4 != 0x01020304L) + return FALSE; + } + else if (conv2 == 0x0403) + { + pc2u2 = c2u2_ss; + pc4u4 = c4u4_ss; + pu2c2 = u2c2_ss; + pu4c4 = u4c4_ss; + if (conv4 == 0x02010403L) + { + pc4u4 = c4u4_s0; + pu4c4 = u4c4_s0; + } + else if (conv4 != 0x04030201L) + return FALSE; + } + else + return FALSE; + return TRUE; +} + +#ifdef DEBUG_TYPECONV + +main() +{ + char *source; + char target[4]; + u2_t u2; + u2_t u2a; + u4_t u4; + u4_t u4a; + + printf("%u\n", typeconv_init(FALSE, FALSE)); + printf("%u\n", typeconv_init(FALSE, TRUE)); + printf("%u\n", typeconv_init(TRUE, FALSE)); + printf("%u\n", typeconv_init(TRUE, TRUE)); + + typeconv_init(FALSE, FALSE); + source = "\4\3\2\1"; + + target[0] = 0; + target[1] = 0; + u2 = cnu2(source, 2); + u2cn(target, u2, 2); + if (strncmp(source, target, 2)) + printf("oops9\n"); + + target[0] = 0; + target[1] = 0; + u4a = cnu4(source, 2); + u4cn(target, u4a, 2); + if (strncmp(source, target, 2)) + printf("oops10\n"); + + target[0] = 0; + target[1] = 0; + target[2] = 0; + target[3] = 0; + u2a = cnu2(source, 4); + u2cn(target, u2a, 4); + if (strncmp(target, "\4\3\0\0", 4)) + printf("oops11\n"); + + target[0] = 0; + target[1] = 0; + target[2] = 0; + target[3] = 0; + u4 = cnu4(source, 4); + u4cn(target, u4, 4); + if (strncmp(source, target, 4)) + printf("oops12\n"); + + printf("%04x %04x %08lx %08lx\n", u2, u2a, u4, u4a); + + typeconv_init(FALSE, TRUE); + source = "\2\1\4\3"; + + target[0] = 0; + target[1] = 0; + u2 = cnu2(source + 2, 2); + u2cn(target, u2, 2); + if (strncmp(source + 2, target, 2)) + printf("oops13\n"); + + target[0] = 0; + target[1] = 0; + u4a = cnu4(source + 2, 2); + u4cn(target, u4a, 2); + if (strncmp(source + 2, target, 2)) + printf("oops14\n"); + + target[0] = 0; + target[1] = 0; + target[2] = 0; + target[3] = 0; + u2a = cnu2(source, 4); + u2cn(target, u2a, 4); + if (strncmp(target, "\0\0\4\3", 4)) + printf("oops15\n"); + + target[0] = 0; + target[1] = 0; + target[2] = 0; + target[3] = 0; + u4 = cnu4(source, 4); + u4cn(target, u4, 4); + if (strncmp(source, target, 4)) + printf("oops16\n"); + + printf("%04x %04x %08lx %08lx\n", u2, u2a, u4, u4a); + + typeconv_init(TRUE, FALSE); + source = "\3\4\1\2"; + + target[0] = 0; + target[1] = 0; + u2 = cnu2(source, 2); + u2cn(target, u2, 2); + if (strncmp(source, target, 2)) + printf("oops5\n"); + + target[0] = 0; + target[1] = 0; + u4a = cnu4(source, 2); + u4cn(target, u4a, 2); + if (strncmp(source, target, 2)) + printf("oops6\n"); + + target[0] = 0; + target[1] = 0; + target[2] = 0; + target[3] = 0; + u2a = cnu2(source, 4); + u2cn(target, u2a, 4); + if (strncmp(target, "\3\4\0\0", 4)) + printf("oops7\n"); + + target[0] = 0; + target[1] = 0; + target[2] = 0; + target[3] = 0; + u4 = cnu4(source, 4); + u4cn(target, u4, 4); + if (strncmp(source, target, 4)) + printf("oops8\n"); + + printf("%04x %04x %08lx %08lx\n", u2, u2a, u4, u4a); + + typeconv_init(TRUE, TRUE); + source = "\1\2\3\4"; + + target[0] = 0; + target[1] = 0; + u2 = cnu2(source + 2, 2); + u2cn(target, u2, 2); + if (strncmp(source + 2, target, 2)) + printf("oops1\n"); + + target[0] = 0; + target[1] = 0; + u4a = cnu4(source + 2, 2); + u4cn(target, u4a, 2); + if (strncmp(source + 2, target, 2)) + printf("oops2\n"); + + target[0] = 0; + target[1] = 0; + target[2] = 0; + target[3] = 0; + u2a = cnu2(source, 4); + u2cn(target, u2a, 4); + if (strncmp(target, "\0\0\3\4", 4)) + printf("oops3\n"); + + target[0] = 0; + target[1] = 0; + target[2] = 0; + target[3] = 0; + u4 = cnu4(source, 4); + u4cn(target, u4, 4); + if (strncmp(source, target, 4)) + printf("oops4\n"); + + printf("%04x %04x %08lx %08lx\n", u2, u2a, u4, u4a); +} + +#endif /* DEBUG_TYPECONV */ diff -Nurd linux-86.old/bcc/Makefile linux-86/bcc/Makefile --- linux-86.old/bcc/Makefile Sun Jan 19 10:53:05 1997 +++ linux-86/bcc/Makefile Tue Apr 22 20:36:59 1997 @@ -25,16 +25,16 @@ install -m 755 bcc-cc1 $(LIBDIR)/bcc-cc1 bcc: bcc.c - $(CC) -ansi $(CFLAGS) $(BCCDEFS) $(LDFLAGS) bcc.c -o $@ + $(CC) $(ANSI) $(CFLAGS) $(BCCDEFS) $(LDFLAGS) bcc.c -o $@ ncc: bcc.c - $(CC) -ansi $(CFLAGS) -DL_TREE -DDEFARCH=0 $(LDFLAGS) bcc.c -o $@ + $(CC) $(ANSI) $(CFLAGS) -DL_TREE -DDEFARCH=0 $(LDFLAGS) bcc.c -o $@ bcc09: bcc.c - $(CC) -ansi $(CFLAGS) -DMC6809 $(BCCDEFS) $(LDFLAGS) bcc.c -o $@ + $(CC) $(ANSI) $(CFLAGS) -DMC6809 $(BCCDEFS) $(LDFLAGS) bcc.c -o $@ ccc: bcc.c - $(CC) -ansi $(CFLAGS) -DCCC $(BCCDEFS) $(LDFLAGS) bcc.c -o $@ + $(CC) $(ANSI) $(CFLAGS) -DCCC $(BCCDEFS) $(LDFLAGS) bcc.c -o $@ bcc-cc1: $(OBJS) $(CC) $(LDFLAGS) $(OBJS) -o bcc-cc1 @@ -43,5 +43,8 @@ rm -f bcc bcc-cc1 ncc bcc09 ccc bcc.o $(OBJS) -$(OBJS): align.h byteord.h condcode.h const.h gencode.h input.h label.h os.h \ - output.h parse.h proto.h reg.h sc.h scan.h sizes.h table.h type.h types.h +$(OBJS): bcc.h align.h const.h types.h \ + byteord.h condcode.h gencode.h \ + input.h label.h os.h output.h \ + parse.h proto.h reg.h sc.h scan.h \ + sizes.h table.h type.h diff -Nurd linux-86.old/bcc/align.h linux-86/bcc/align.h --- linux-86.old/bcc/align.h Sat Nov 14 15:12:16 1992 +++ linux-86/bcc/align.h Thu Apr 24 20:10:34 1997 @@ -5,11 +5,10 @@ #ifndef S_ALIGNMENT # define align(x) (x) #else -# ifdef UNPORTABLE_ALIGNMENT -typedef unsigned pointerint_t; -# define align(x) (((pointerint_t) (x) + (S_ALIGNMENT-1)) & ~(S_ALIGNMENT-1)) +# if defined(__STDC__) && defined(_POSIX_SOURCE) +# define align(x) (((ssize_t) (x) + (S_ALIGNMENT-1)) & ~(S_ALIGNMENT-1)) # else -# define align(x) ((char *) (x) + (- (int) (x) & (S_ALIGNMENT-1))) +# define align(x) ((char *) (x) + (- (char) (x) & (S_ALIGNMENT-1))) # endif #endif diff -Nurd linux-86.old/bcc/assign.c linux-86/bcc/assign.c --- linux-86.old/bcc/assign.c Sat Dec 30 09:30:40 1995 +++ linux-86/bcc/assign.c Sun Apr 13 11:37:06 1997 @@ -2,8 +2,7 @@ /* Copyright (C) 1992 Bruce Evans */ -#include "const.h" -#include "types.h" +#include "bcc.h" #include "byteord.h" #include "gencode.h" #include "reg.h" @@ -236,7 +235,7 @@ if (long_big_endian) #endif #if DYNAMIC_LONG_ORDER || LONG_BIG_ENDIAN -# if BIG_ENDIAN +# if INT_BIG_ENDIAN target->offset.offi += oldsize - ctypesize; # else { @@ -249,7 +248,7 @@ else #endif #if DYNAMIC_LONG_ORDER || LONG_BIG_ENDIAN == 0 -# if BIG_ENDIAN +# if INT_BIG_ENDIAN target->offset.offi += ctypesize; # else ; diff -Nurd linux-86.old/bcc/bcc-cc1.c linux-86/bcc/bcc-cc1.c --- linux-86.old/bcc/bcc-cc1.c Sat Jul 20 11:41:14 1996 +++ linux-86/bcc/bcc-cc1.c Sun Apr 13 11:15:39 1997 @@ -2,8 +2,7 @@ /* Copyright (C) 1992 Bruce Evans */ -#include "const.h" -#include "types.h" +#include "bcc.h" PUBLIC int main(argc, argv) int argc; diff -Nurd linux-86.old/bcc/bcc.c linux-86/bcc/bcc.c --- linux-86.old/bcc/bcc.c Fri Feb 21 20:33:21 1997 +++ linux-86/bcc/bcc.c Tue Apr 22 20:36:59 1997 @@ -45,7 +45,7 @@ #define EXESUF #endif -#ifdef __minix +#if defined(__minix) || defined(_AIX) #define realpath(x,y) 0 #endif @@ -531,10 +531,14 @@ addarg(&cppargs, "-D__linux__"); addarg(&ldargs, "-N"); /* Make OMAGIC */ break; + case 0: + break; + default: + fatal("Fatal error: illegal -M option given"); } #endif -if( !aswarn ) + if( !aswarn ) addarg(&asargs, "-w"); if( patch_exe ) addarg(&ldargs, "-s"); diff -Nurd linux-86.old/bcc/bcc.h linux-86/bcc/bcc.h --- linux-86.old/bcc/bcc.h Thu Jan 1 01:00:00 1970 +++ linux-86/bcc/bcc.h Sun Apr 13 11:29:05 1997 @@ -0,0 +1,28 @@ +/* Copyright (C) 1997 Robert de Bath + * This file is part of the Linux-8086 Development environment and is + * distributed under the GNU General Public License. */ + +/* Ansi C has certain guarentees ... except under MSdross :-( */ + +#ifdef __STDC__ +#ifndef MSDOS +#include +#include +#include +#include +#endif + +#define P(x) x + +#else +#define P(x) () +#endif + +#include "const.h" +#include "types.h" +#include "proto.h" + +#if !defined(__STDC__) || defined(MSDOS) +#include "sysproto.h" +#endif + diff -Nurd linux-86.old/bcc/byteord.h linux-86/bcc/byteord.h --- linux-86.old/bcc/byteord.h Sat Nov 14 15:12:16 1992 +++ linux-86/bcc/byteord.h Sun Apr 13 11:37:24 1997 @@ -3,11 +3,11 @@ /* Copyright (C) 1992 Bruce Evans */ #ifdef I8088 -# define BIG_ENDIAN 0 +# define INT_BIG_ENDIAN 0 # define LONG_BIG_ENDIAN 1 /* longs are back to front for Xenix */ #endif #ifdef MC6809 -# define BIG_ENDIAN 1 /* byte order in words is high-low */ +# define INT_BIG_ENDIAN 1 /* byte order in words is high-low */ # define LONG_BIG_ENDIAN 1 /* byte order in longs is high-low */ #endif diff -Nurd linux-86.old/bcc/codefrag.c linux-86/bcc/codefrag.c --- linux-86.old/bcc/codefrag.c Sat Jul 20 07:48:32 1996 +++ linux-86/bcc/codefrag.c Sun Apr 13 11:15:50 1997 @@ -2,8 +2,7 @@ /* Copyright (C) 1992 Bruce Evans */ -#include "const.h" -#include "types.h" +#include "bcc.h" #include "byteord.h" #include "condcode.h" #include "gencode.h" diff -Nurd linux-86.old/bcc/const.h linux-86/bcc/const.h --- linux-86.old/bcc/const.h Fri Jan 31 22:01:00 1997 +++ linux-86/bcc/const.h Thu Apr 24 19:53:38 1997 @@ -17,9 +17,13 @@ #endif +#ifdef __AS386_16__ +#define VERY_SMALL_MEMORY +#endif + #define SELFTYPECHECK /* check calculated type = runtime type */ -#ifndef __AS386_16__ +#ifndef VERY_SMALL_MEMORY #define DEBUG /* generate compiler-debugging code */ #endif @@ -29,7 +33,7 @@ * since assembler has only 1 data seg */ # define DYNAMIC_LONG_ORDER 1 /* long word order spec. at compile time */ -#ifdef __AS386_16__ +#ifdef VERY_SMALL_MEMORY /* Humm, now this is nasty :-) */ #define float no_hope @@ -61,12 +65,9 @@ /* switches for source machine dependencies */ -#ifndef SOS_EDOS -# define S_ALIGNMENT (sizeof(int)) /* source memory alignment, power of 2 */ -#endif - -#ifndef SOS_MSDOS /* need portable alignment for large model */ -# define UNPORTABLE_ALIGNMENT +/* Unportable alignment needed for specific compilers */ +#ifndef VERY_SMALL_MEMORY +# define S_ALIGNMENT (sizeof(long)) /* A little safer */ #endif /* local style */ diff -Nurd linux-86.old/bcc/debug.c linux-86/bcc/debug.c --- linux-86.old/bcc/debug.c Sat Nov 14 15:12:18 1992 +++ linux-86/bcc/debug.c Sun Apr 13 11:20:14 1997 @@ -2,11 +2,9 @@ /* Copyright (C) 1992 Bruce Evans */ -#include "const.h" +#include "bcc.h" #ifdef DEBUG - -#include "types.h" #include "gencode.h" #include "reg.h" #include "sc.h" diff -Nurd linux-86.old/bcc/declare.c linux-86/bcc/declare.c --- linux-86.old/bcc/declare.c Sat Nov 2 11:34:25 1996 +++ linux-86/bcc/declare.c Sun Apr 13 11:37:38 1997 @@ -2,8 +2,7 @@ /* Copyright (C) 1992 Bruce Evans */ -#include "const.h" -#include "types.h" +#include "bcc.h" #include "align.h" #include "byteord.h" #include "gencode.h" @@ -644,7 +643,7 @@ arg1size = itypesize; argsp = softsp -= arg1size; } -#if BIG_ENDIAN +#if INT_BIG_ENDIAN if (argsize < itypesize) argsp += itypesize - argsize; symptr->offset.offi = argsp; diff -Nurd linux-86.old/bcc/express.c linux-86/bcc/express.c --- linux-86.old/bcc/express.c Sat Nov 14 15:12:18 1992 +++ linux-86/bcc/express.c Sun Apr 13 11:16:05 1997 @@ -2,8 +2,7 @@ /* Copyright (C) 1992 Bruce Evans */ -#include "const.h" -#include "types.h" +#include "bcc.h" #include "gencode.h" #include "parse.h" #include "reg.h" diff -Nurd linux-86.old/bcc/exptree.c linux-86/bcc/exptree.c --- linux-86.old/bcc/exptree.c Sat Jul 20 11:59:18 1996 +++ linux-86/bcc/exptree.c Sun Apr 13 11:57:29 1997 @@ -2,8 +2,7 @@ /* Copyright (C) 1992 Bruce Evans */ -#include "const.h" -#include "types.h" +#include "bcc.h" #include "byteord.h" #include "gencode.h" #include "parse.h" @@ -13,7 +12,7 @@ #include "sizes.h" #include "type.h" -#ifdef __AS386_16__ +#ifdef VERY_SMALL_MEMORY #define ETREESIZE 300 #else #define ETREESIZE 1200 @@ -375,6 +374,7 @@ if (lscalar & RSCALAR && !(rscalar & RSCALAR)) { double val; + /* XXX: Gcc warns about ansi vs k&r problem with this */ static double MAXULONG = (double)0xFFFFFFFFL +1; val = *target->offset.offd; @@ -425,7 +425,7 @@ if (long_big_endian) #endif #if DYNAMIC_LONG_ORDER || LONG_BIG_ENDIAN -# if BIG_ENDIAN +# if INT_BIG_ENDIAN target->offset.offi += targszdelta; # else { @@ -438,7 +438,7 @@ else #endif #if DYNAMIC_LONG_ORDER || LONG_BIG_ENDIAN == 0 -# if BIG_ENDIAN +# if INT_BIG_ENDIAN { if (rscalar & CHAR) target->offset.offi += ctypesize; diff -Nurd linux-86.old/bcc/floatop.c linux-86/bcc/floatop.c --- linux-86.old/bcc/floatop.c Sat Nov 14 15:12:19 1992 +++ linux-86/bcc/floatop.c Sun Apr 13 11:16:13 1997 @@ -2,8 +2,7 @@ /* Copyright (C) 1992 Bruce Evans */ -#include "const.h" -#include "types.h" +#include "bcc.h" #include "gencode.h" #include "reg.h" #include "sc.h" diff -Nurd linux-86.old/bcc/function.c linux-86/bcc/function.c --- linux-86.old/bcc/function.c Sat Jul 20 07:49:54 1996 +++ linux-86/bcc/function.c Sun Apr 13 11:16:17 1997 @@ -2,8 +2,7 @@ /* Copyright (C) 1992 Bruce Evans */ -#include "const.h" -#include "types.h" +#include "bcc.h" #include "align.h" #include "byteord.h" #include "gencode.h" diff -Nurd linux-86.old/bcc/gencode.c linux-86/bcc/gencode.c --- linux-86.old/bcc/gencode.c Sat Jul 20 07:50:37 1996 +++ linux-86/bcc/gencode.c Sun Apr 13 11:16:23 1997 @@ -5,8 +5,7 @@ #define islvalop(op) \ (((op) >= ASSIGNOP && (op) <= SUBABOP) || (op) == PTRADDABOP) -#include "const.h" -#include "types.h" +#include "bcc.h" #include "align.h" #include "condcode.h" #include "reg.h" diff -Nurd linux-86.old/bcc/genloads.c linux-86/bcc/genloads.c --- linux-86.old/bcc/genloads.c Sat Jul 20 07:54:47 1996 +++ linux-86/bcc/genloads.c Sun Apr 13 11:16:26 1997 @@ -2,8 +2,7 @@ /* Copyright (C) 1992 Bruce Evans */ -#include "const.h" -#include "types.h" +#include "bcc.h" #include "byteord.h" #include "condcode.h" #include "gencode.h" diff -Nurd linux-86.old/bcc/glogcode.c linux-86/bcc/glogcode.c --- linux-86.old/bcc/glogcode.c Sat Jul 20 07:55:42 1996 +++ linux-86/bcc/glogcode.c Sun Apr 13 11:16:29 1997 @@ -2,8 +2,7 @@ /* Copyright (C) 1992 Bruce Evans */ -#include "const.h" -#include "types.h" +#include "bcc.h" #include "condcode.h" #include "gencode.h" #include "reg.h" diff -Nurd linux-86.old/bcc/hardop.c linux-86/bcc/hardop.c --- linux-86.old/bcc/hardop.c Sat Jul 20 07:55:59 1996 +++ linux-86/bcc/hardop.c Sun Apr 13 11:38:14 1997 @@ -2,8 +2,7 @@ /* Copyright (C) 1992 Bruce Evans */ -#include "const.h" -#include "types.h" +#include "bcc.h" #include "byteord.h" #include "condcode.h" #include "gencode.h" @@ -380,11 +379,11 @@ indcount = source->indcount; # endif outopsep(); -# if BIG_ENDIAN == 0 +# if INT_BIG_ENDIAN == 0 ++source->offset.offi; # endif outadr(source); -# if BIG_ENDIAN == 0 +# if INT_BIG_ENDIAN == 0 --source->offset.offi; # endif # if MAXINDIRECT > 1 @@ -396,7 +395,7 @@ } outregname(BREG); outopsep(); -# if BIG_ENDIAN +# if INT_BIG_ENDIAN ++source->offset.offi; # endif outadr(source); diff -Nurd linux-86.old/bcc/input.c linux-86/bcc/input.c --- linux-86.old/bcc/input.c Wed Jan 22 21:27:56 1997 +++ linux-86/bcc/input.c Sun Apr 13 11:16:39 1997 @@ -5,8 +5,7 @@ #define ARBITRARY_BACKSLASH_NEWLINES_NOT #define INSERT_BACKSLASH_NEWLINES_NOT -#include "const.h" -#include "types.h" +#include "bcc.h" #include "gencode.h" #include "output.h" #include "os.h" diff -Nurd linux-86.old/bcc/label.c linux-86/bcc/label.c --- linux-86.old/bcc/label.c Sat Jul 20 07:57:47 1996 +++ linux-86/bcc/label.c Sun Apr 13 11:16:43 1997 @@ -2,8 +2,7 @@ /* Copyright (C) 1992 Bruce Evans */ -#include "const.h" -#include "types.h" +#include "bcc.h" #include "condcode.h" #include "gencode.h" #include "label.h" diff -Nurd linux-86.old/bcc/loadexp.c linux-86/bcc/loadexp.c --- linux-86.old/bcc/loadexp.c Sat Dec 30 09:30:41 1995 +++ linux-86/bcc/loadexp.c Sun Apr 13 11:16:46 1997 @@ -2,8 +2,7 @@ /* Copyright (C) 1992 Bruce Evans */ -#include "const.h" -#include "types.h" +#include "bcc.h" #include "byteord.h" #include "gencode.h" #include "parse.h" diff -Nurd linux-86.old/bcc/longop.c linux-86/bcc/longop.c --- linux-86.old/bcc/longop.c Sat Dec 30 09:30:41 1995 +++ linux-86/bcc/longop.c Sun Apr 13 11:16:49 1997 @@ -2,8 +2,7 @@ /* Copyright (C) 1992 Bruce Evans */ -#include "const.h" -#include "types.h" +#include "bcc.h" #include "byteord.h" #include "gencode.h" #include "reg.h" diff -Nurd linux-86.old/bcc/output.c linux-86/bcc/output.c --- linux-86.old/bcc/output.c Sun Dec 1 07:25:11 1996 +++ linux-86/bcc/output.c Sun Apr 13 11:16:52 1997 @@ -2,8 +2,7 @@ /* Copyright (C) 1992 Bruce Evans */ -#include "const.h" -#include "types.h" +#include "bcc.h" #include "input.h" #include "os.h" #include "sizes.h" diff -Nurd linux-86.old/bcc/preproc.c linux-86/bcc/preproc.c --- linux-86.old/bcc/preproc.c Sun Jan 19 10:51:15 1997 +++ linux-86/bcc/preproc.c Sun Apr 13 11:16:55 1997 @@ -2,8 +2,7 @@ /* Copyright (C) 1992 Bruce Evans */ -#include "const.h" -#include "types.h" +#include "bcc.h" #include "input.h" #include "os.h" #include "output.h" diff -Nurd linux-86.old/bcc/preserve.c linux-86/bcc/preserve.c --- linux-86.old/bcc/preserve.c Sat Dec 30 09:30:41 1995 +++ linux-86/bcc/preserve.c Sun Apr 13 11:16:58 1997 @@ -2,8 +2,7 @@ /* Copyright (C) 1992 Bruce Evans */ -#include "const.h" -#include "types.h" +#include "bcc.h" #include "gencode.h" #include "reg.h" #include "type.h" diff -Nurd linux-86.old/bcc/proto.h linux-86/bcc/proto.h --- linux-86.old/bcc/proto.h Fri Jan 31 22:01:13 1997 +++ linux-86/bcc/proto.h Sun Apr 13 11:18:57 1997 @@ -2,12 +2,6 @@ /* Copyright (C) 1992 Bruce Evans */ -#ifdef __STDC__ -#define P(x) x -#else -#define P(x) () -#endif - /* assign.c */ void assign P((struct symstruct *source, struct symstruct *target)); void cast P((struct typestruct *type, struct symstruct *target)); @@ -371,28 +365,3 @@ struct typestruct *tounsigned P((struct typestruct *type)); void typeinit P((void)); -/* library - fcntl.h */ -int creat P((const char *_path, int _mode)); -int open P((const char *_path, int _oflag, ...)); - -/* library - stdlib.h */ -double atof P((const char *_str)); -void exit P((int _status)); - -/* library - string.h */ -void *memcpy P((void *_t, const void *_s, unsigned _length)); -void *memset P((void *_s, int _c, unsigned _nbytes)); -char *strcat P((char *_target, const char *_source)); -char *strchr P((const char *_s, int _ch)); -int strcmp P((const char *_s1, const char *_s2)); -char *strcpy P((char *_target, const char *_source)); -unsigned strlen P((const char *_s)); -char *strncpy P((char *_target, const char *_source, unsigned _maxlength)); -char *strrchr P((const char *_s, int _ch)); - -/* library - unistd.h */ -int close P((int _fd)); -int isatty P((int _fd)); -long lseek P((int _fd, long _offset, int _whence)); -int read P((int _fd, char *_buf, unsigned _nbytes)); -int write P((int _fd, char *_buf, unsigned _nbytes)); diff -Nurd linux-86.old/bcc/scan.c linux-86/bcc/scan.c --- linux-86.old/bcc/scan.c Sun Nov 3 20:03:45 1996 +++ linux-86/bcc/scan.c Sun Apr 13 11:17:02 1997 @@ -4,8 +4,7 @@ #define GCH1() do { if (SYMOFCHAR(ch = *++lineptr) == SPECIALCHAR) specialchar(); } while (0) -#include "const.h" -#include "types.h" +#include "bcc.h" #include "input.h" #include "os.h" #include "output.h" diff -Nurd linux-86.old/bcc/softop.c linux-86/bcc/softop.c --- linux-86.old/bcc/softop.c Sat Dec 30 09:30:41 1995 +++ linux-86/bcc/softop.c Sun Apr 13 11:17:04 1997 @@ -2,8 +2,7 @@ /* Copyright (C) 1992 Bruce Evans */ -#include "const.h" -#include "types.h" +#include "bcc.h" #include "gencode.h" #include "reg.h" #include "scan.h" diff -Nurd linux-86.old/bcc/state.c linux-86/bcc/state.c --- linux-86.old/bcc/state.c Sat Jul 20 07:58:21 1996 +++ linux-86/bcc/state.c Sun Apr 13 11:17:08 1997 @@ -2,8 +2,7 @@ /* Copyright (C) 1992 Bruce Evans */ -#include "const.h" -#include "types.h" +#include "bcc.h" #include "align.h" #include "condcode.h" #include "gencode.h" diff -Nurd linux-86.old/bcc/sysproto.h linux-86/bcc/sysproto.h --- linux-86.old/bcc/sysproto.h Thu Jan 1 01:00:00 1970 +++ linux-86/bcc/sysproto.h Sun Apr 13 11:27:55 1997 @@ -0,0 +1,27 @@ + +/* library - fcntl.h */ +int creat P((const char *_path, int _mode)); +int open P((const char *_path, int _oflag, ...)); + +/* library - stdlib.h */ +double atof P((const char *_str)); +void exit P((int _status)); + +/* library - string.h */ +void *memcpy P((void *_t, const void *_s, unsigned _length)); +void *memset P((void *_s, int _c, unsigned _nbytes)); +char *strcat P((char *_target, const char *_source)); +char *strchr P((const char *_s, int _ch)); +int strcmp P((const char *_s1, const char *_s2)); +char *strcpy P((char *_target, const char *_source)); +unsigned strlen P((const char *_s)); +char *strncpy P((char *_target, const char *_source, unsigned _maxlength)); +char *strrchr P((const char *_s, int _ch)); + +/* library - unistd.h */ +int close P((int _fd)); +int isatty P((int _fd)); +long lseek P((int _fd, long _offset, int _whence)); +int read P((int _fd, char *_buf, unsigned _nbytes)); +int write P((int _fd, char *_buf, unsigned _nbytes)); + diff -Nurd linux-86.old/bcc/table.c linux-86/bcc/table.c --- linux-86.old/bcc/table.c Sat Jul 20 12:00:51 1996 +++ linux-86/bcc/table.c Sun Apr 13 11:17:11 1997 @@ -6,8 +6,7 @@ * usually be set to some level different from OFFKLUDGELEVEL. */ -#include "const.h" -#include "types.h" +#include "bcc.h" #include "align.h" #include "gencode.h" #include "os.h" @@ -25,7 +24,7 @@ #define GOLDEN 157 /* GOLDEN/HASHTABSIZE approx golden ratio */ #define HASHTABSIZE 256 #define MARKER ((unsigned) 0x18C396A5L) /* lint everywhere it is used */ -#ifdef __AS386_16__ +#ifdef VERY_SMALL_MEMORY #define MAXEXPR 125 #else #define MAXEXPR 500 diff -Nurd linux-86.old/bcc/type.c linux-86/bcc/type.c --- linux-86.old/bcc/type.c Sat Jul 20 07:58:37 1996 +++ linux-86/bcc/type.c Sun Apr 13 11:17:13 1997 @@ -2,8 +2,7 @@ /* Copyright (C) 1992 Bruce Evans */ -#include "const.h" -#include "types.h" +#include "bcc.h" #include "align.h" #include "gencode.h" /* s.b. switches.h */ #include "sc.h" diff -Nurd linux-86.old/bcc/types.h linux-86/bcc/types.h --- linux-86.old/bcc/types.h Mon Jan 8 13:31:53 1996 +++ linux-86/bcc/types.h Sun Apr 13 11:18:23 1997 @@ -202,5 +202,3 @@ #define NULLNODE ((struct nodestruct *) NULL) #define NULLTYPE ((struct typestruct *) NULL) - -#include "proto.h" diff -Nurd linux-86.old/bootblocks/Makefile linux-86/bootblocks/Makefile --- linux-86.old/bootblocks/Makefile Sat Feb 22 17:51:41 1997 +++ linux-86/bootblocks/Makefile Wed May 7 22:50:45 1997 @@ -15,8 +15,8 @@ CSRC=minix.c SSRC=tarboot.s skip.s com_bcc.s tich.s sysboot.s bootlist.s mbr.s msdos.s -encap: $(SSRC:s=v) $(CSRC:c=v) -bin: $(SSRC:s=bin) $(CSRC:c=bin) +encap: $(SSRC:s=v) $(CSRC:c=v) minixhd.v +bin: $(SSRC:s=bin) $(CSRC:c=bin) minixhd.bin MOBJ=monitor.o i86_funcs.o relocate.o help.o bzimage.o dosfs.o nofs.o MSRC=monitor.c i86_funcs.c relocate.c help.c bzimage.c dosfs.c nofs.c @@ -35,6 +35,9 @@ minix.s: minix.c $(BCC) -Mc -S minix.c +minixhd.s: minix.c + $(BCC) -Mc -DHARDDISK -S minix.c -o minixhd.s + makeboot: makeboot.c sysboot.v skip.v msdos.v tarboot.v $(HOSTCC) $(HOSTCCFLAGS) -o makeboot makeboot.c @@ -62,7 +65,9 @@ .SUFFIXES: .bin .v .s.bin: - $(BCC) -c $*.s -A-b -A$*.bin -A-s -A$*.sym -A-l -A$*.lst + $(BCC) -c $*.s -A-u- -A-b -A/tmp/$*.bin -A-s -A$*.sym -A-l -A$*.lst + -@mv /tmp/$*.bin $*.bin + -@rm $*.o .s.v: as86_encap $*.s $*.v $*_ $(ASFLAGS) $(LST) diff -Nurd linux-86.old/bootblocks/README linux-86/bootblocks/README --- linux-86.old/bootblocks/README Sat Jan 25 22:12:43 1997 +++ linux-86/bootblocks/README Wed May 7 22:54:48 1997 @@ -30,9 +30,7 @@ Place a Linux-8086 executable in the root directory of the floppy. $ make monitor.out -$ mount -t msdos /dev/fd0 /mnt -$ cp monitor.out /mnt/bootfile.sys -$ umount /dev/fd0 +$ mcopy monitor.out a:BOOTFILE.SYS or C:\> copy monitor.out a:\bootfile.sys @@ -80,10 +78,10 @@ $ makeboot dos /dev/fd0 $ mount -t msdos /dev/fd0 /mnt $ cp monitor.out /mnt/bootfile.sys -$ umount /dev/fd0 -$ cp /usr/src/linux/arch/i386/boot/bzImage /mnt/fd0/vmlinuz -$ echo 'root=/dev/ram ramdisk_file=ramdisk.gz mem=80M' > /mnt/fd0/vmlinuz.cmd -$ cp /archive/ramdisk.gz /mnt/fd0/ramdisk.gz + +$ cp /usr/src/linux/arch/i386/boot/bzImage /mnt/vmlinuz +$ echo 'root=/dev/ram ramdisk_file=ramdisk.gz mem=80M' > /mnt/vmlinuz.cmd +$ cp /archive/ramdisk.gz /mnt/ramdisk.gz $ umount /dev/fd0 The stuff about ramdisk is only if you want an init ramdisk. You can also use: diff -Nurd linux-86.old/bootblocks/dosfs.c linux-86/bootblocks/dosfs.c --- linux-86.old/bootblocks/dosfs.c Wed Jan 8 22:27:48 1997 +++ linux-86/bootblocks/dosfs.c Wed May 7 22:36:49 1997 @@ -54,6 +54,7 @@ open_file(fname) char * fname; { + extern union REGS __argr; char conv_name[12]; char *s, *d; int i; diff -Nurd linux-86.old/bootblocks/makeboot.c linux-86/bootblocks/makeboot.c --- linux-86.old/bootblocks/makeboot.c Sat Jan 25 22:13:51 1997 +++ linux-86/bootblocks/makeboot.c Sat May 3 08:09:11 1997 @@ -24,7 +24,7 @@ } bblocks[] = { { "tar", tarboot_data, FS_TAR, "Bootable GNU tar volume lable" }, { "dosfs", msdos_data, FS_ADOS, "Boots file BOOTFILE.SYS from dosfs" }, - { "bare", sysboot_data, FS_DOS, "Bare bootblock, lockup if booted" }, + { "none", sysboot_data, FS_DOS, "No OS bookblock, just message" }, { "skip", skip_data, FS_DOS, "Bypasses floppy boot with message" }, { "stat", 0, FS_STAT, "Display dosfs superblock" }, { "copy", 0, FS_STAT, "Copy boot block to makeboot.sav" }, diff -Nurd linux-86.old/bootblocks/mbr.s linux-86/bootblocks/mbr.s --- linux-86.old/bootblocks/mbr.s Fri Jan 3 15:27:31 1997 +++ linux-86/bootblocks/mbr.s Sat May 3 09:17:18 1997 @@ -8,7 +8,7 @@ ! Lowest available is $0500, MSDOS appears to use $0600 ... I wonder why? ORGADDR=$0500 -preboot=1 ! Include the pre-boot loader ? +preboot=0 ! Include the pre-boot loader ? ! Include standard layout org ORGADDR @@ -58,7 +58,7 @@ jnc more_boot ! This doesn't retry, with a HD it shouldn't be bad. jc disk_error load_done: - call [di] + call di exec_done: pop bx endif @@ -70,6 +70,7 @@ check_active: cmp byte [si],#$80 ! Flag for activated partition jz found_active +bad_boot: add si,#partition_2-partition_1 cmp si,#bootblock_magic jnz check_active @@ -83,6 +84,7 @@ mov cx,[si+2] ! cx = Sector & head encoded for int $13 ! bx is correct retry: + movb [$7DFE],#0 ! Clear magic for dosemu mov ax,#$0201 ! Read 1 sector int $13 ! Disk read. jnc sector_loaded @@ -101,7 +103,7 @@ sector_loaded: mov di,#$7DFE ! End of sector loaded cmp [di],#$AA55 ! Check for magic - jnz check_active ! No? Try next partition. + jnz bad_boot ! No? Try next partition. mov bp,si ! LILO says some BBs use bp rather than si jmpi #$7C00,#0 ! Go! @@ -141,6 +143,8 @@ export pre_boot_table pre_boot_table: + ! Example: Load rest of H0,C0 into mem at $7C00 (8k). + ! .word $7C00, $7C00,$0002,$0000,$0210, $0000 .word return .word 0 endif diff -Nurd linux-86.old/bootblocks/minix.c linux-86/bootblocks/minix.c --- linux-86.old/bootblocks/minix.c Mon Oct 14 21:33:48 1996 +++ linux-86/bootblocks/minix.c Wed May 7 22:26:17 1997 @@ -2,7 +2,7 @@ * This bootblock loads the linux-8086 executable in the file 'linux' * from the root directory of a minix filesystem. * - * Copyright (C) 1990-1996 Robert de Bath, distributed under the GPL Version 2 + * Copyright (C) 1990-1997 Robert de Bath, distributed under the GPL Version 2 * Based on minix filesystem definitions. */ @@ -16,36 +16,72 @@ #define BOOTSEG (0x07c0) #define LOADSEG (0x1000) +#ifdef HARDDISK +#define get_now() +#endif + #asm -BOOTSEG = 0x07c0 +! BOOTSEG = 0x07c0 +! LOADSEG = 0x1000 ! This must be sector aligned + BOOTADDR = 0x7c00 -LOADSEG = 0x1000 ! This must be sector aligned +ORGADDR = $0500 .text ! Apparently on startup the only things we can assume are that we start at -! `start` (ABS addr $07C00) ... +! `start` (ABS addr $07C00) and the boot sector is in the segment. ! So first set CS=DS=ES=SS=0 ! The we move this to $0500 and put the stack at the top of the first 64k. ! The directory 'file' is loaded $1500 and scanned there. ! The final executable will be loaded in the 2nd 64k chunk. ! -org $0500 ! The lowest available address. +org ORGADDR ! The lowest available address. start: include sysboot.s + +org dos_sysid + .ascii "MINIXFS BOOT (C) 1990-1997, Robert de Bath" + org codestart +#ifdef HARDDISK + mov bx,[si+8] ! Fetch the linear address of part from DS:SI + mov dh,[si+10] ! DL is drive number +#endif + xor ax,ax mov ds,ax mov es,ax mov ss,ax mov sp,ax +#ifndef HARDDISK mov ax,#$0204 ! Read 4 sectors, code + superblock. mov bx,#start ! Where this _should_ be mov cx,#$0001 ! From sector 1 xor dx,dx ! Of the floppy drive head zero int $13 +#else + + mov cx,#$100 ! Move 256 words + mov si,#BOOTADDR ! From default BB + mov di,#ORGADDR ! To the correct address. + rep + movsw + + xchg dl,dh + mov [bootpart],bx ! Save the partition sector offset (and drive) + mov [bootpart+2],dx + + ! Read first 3 sectors of hd. + xor dx,dx + mov cx,#1 + mov bx,#ORGADDR+$200 + mov al,#3 + + call load_sect +#endif jmpi code,#0 @@ -214,15 +250,213 @@ .ascii "linux" .byte 0,0,0,0,0,0,0,0,0 +#ifdef HARDDISK +bootpart: .long 0 +#else _loadcount: .word 0 _firstsect: .word 0 _loadaddr: .word 0 _lastsect: .word 0 +#endif code: call _loadprog call _runprog br _nogood + +#endasm + +#ifdef HARDDISK + +#asm +_load_block: + push bp + mov bp,sp + + ! Fetch load location + mov ax,[bp+4] + mov es,ax + + ! Test for block zero + mov ax,6[bp] + test ax,ax + jne real_block + + ! Iff block zero, zap memory + push di + mov cx,#512 + xor ax,ax + mov di,ax + rep + stosw + pop di + +func_exit: + mov sp,bp + pop bp + ret + +real_block: +#ifdef DOTS + mov ax,#$2E + push ax + call _bios_putc + inc sp + inc sp +#endif + +! Load a real block. + mov cx,ax + xor dx,dx + shl cx,#1 + rcl dx,#1 + + xor bx,bx + mov al,#2 + call load_sect + + j func_exit + +! +! Load AL sectors from linear sector DX:CX into location ES:BX +! Linear sector zero is a [bootpart] +! This loads one sector at a time, but that's OK cause even in the _very_ +! worst case it'll take no more that 5 seconds to load a 16 bit executable. +! +load_sect: + add cx,[bootpart] + adc dx,[bootpart+2] +moresect: + cmp al,#0 + jnz onesect + clc + ret + +! Load one sector... +onesect: + push ax ! Save lots + push di + push si + push cx ! Drive and sector. + push dx + + push es ! Load location + push bx + + push cx ! Drive and sector. + push dx + + ! Fetch drive 'shape' + mov ah,#8 + mov dl,dh + int $13 ! DX:CX = drive specification + jc _nogood + + and cx,#$3F ! Get sector count => DI + mov di,cx + + xor dl,dl ! Get head count => SI + xchg dl,dh + inc dx + mov si,dx + + pop dx ! Get back drive and sector + pop ax + + mov bl,dh ! Save drive + xor dh,dh + + div di ! DX=sector, AX=track number + mov cx,dx + inc cl ! CL=sector number + + xor dx,dx + div si ! DX=head, AX=cylinder + + mov dh,dl + mov dl,bl ! DX for int 1302 + + xchg al,ah + ror al,#1 + ror al,#1 + or cx,ax ! CX for int 1302 + + pop bx ! ES:BX for int 1302 + pop es + + mov ax,#$0201 + int $13 + jc _nogood + + pop dx + pop cx + pop si + pop di + pop ax + + dec al + add cx,#1 + adc dh,#0 + add bh,#2 + jmp moresect +#endasm + +#else +#asm +_set_bpb: +bios_tabl=dosfs_stat ! Temp space. +bios_disk=dosfs_stat+4 ! + +#ifndef __CALLER_SAVES__ + push si + push di +#endif + + mov di,#bios_disk + mov bx,#0x78 +! 0:bx is parameter table address + + push ds + push di + + mov si,[bx] + mov ax,[bx+2] + mov [bios_tabl],si + mov [bios_tabl+2],ax + push ax + + pop ds +! ds:si is source + +! copy 12 bytes + mov cl,#6 + cld + rep + movsw + + pop di + pop ds + mov ax,[_n_sectors] + movb 4[di],al ! patch sector count + + mov [bx],di + mov 2[bx],es + +#ifndef __CALLER_SAVES__ + pop si + pop di +#endif + ret + +_unset_bpb: +! 0:0x78 is parameter table address + + mov ax,[bios_tabl] + mov [0x78],ax + mov ax,[bios_tabl+2] + mov [0x78+2],ax + ret + #endasm static @@ -314,11 +548,7 @@ #endasm } -#ifndef load_zone -NOT_DEFINED_load_zone(address, zoneno) -{ -} -#endif +#endif /* !HARDDISK */ #ifdef DOTS static @@ -339,6 +569,27 @@ static nogood() { +#ifdef HARDDISK +#asm + mov si,#fail_fs +min_nextc: + lodsb + cmp al,#0 + jz min_eos + mov bx,#7 + mov ah,#$E ! Can't use $13 cause that's AT+ only! + int $10 + jmp min_nextc +min_eos: ! Wait for a key then reboot + xor ax,ax + int $16 + !int $19 ! This should be OK as we haven't touched anything. + jmpi $0,$FFFF ! Wam! Try or die! + +fail_fs: + .asciz "Inital boot failed, press return to reboot\r\n" +#endasm +#else /* This didn't work, chain the boot sector of the HD */ #asm push cs @@ -352,16 +603,20 @@ jc hcode ! Keep trying forever! jmpi BOOTADDR,0 #endasm +#endif } +/****************************************************************************/ #asm end_of_part1: if *>start+0x200 - fail + fail! Part 1 too large! endif .blkb 0x200+start-* #endasm +/****************************************************************************/ + static loadprog() { @@ -372,6 +627,10 @@ n_sectors = b_super.s_nzones / 80; if( n_sectors < 5 ) n_sectors = b_super.s_nzones / 40; +#ifndef HARDDISK + set_bpb(); +#endif + try_again:; #ifdef zone_shift if( zone_shift != b_super.s_log_zone_size) nogood(); @@ -459,6 +718,9 @@ } nogood(); } +#ifndef HARDDISK + unset_bpb(); +#endif } static @@ -466,8 +728,14 @@ { /* This did work, run the loaded executable */ #asm +#ifdef HARDDISK + mov dx,[bootpart+2] + xchg dh,dl ! DX => hard drive + push [bootpart] ! CX => partition offset +#else xor dx,dx ! DX=0 => floppy drive push dx ! CX=0 => partition offset = 0 +#endif mov si,[_n_sectors] ! Save for monitor.out mov bx,#LOADSEG @@ -477,7 +745,7 @@ xor di,di ! Zero mov ax,[di] cmp ax,#0x0301 ! Right magic ? - bne nogood ! Yuk ... + bne _nogood ! Yuk ... mov ax,[di+2] and ax,#$20 ! Is it split I/D ? jz impure ! No ... @@ -509,6 +777,13 @@ xor dx,dx div bx ret +#ifndef zone_shift +isl: +islu: + mov cl,bl + shl ax,cl + ret +#endif libend: vars: diff -Nurd linux-86.old/bootblocks/monitor.c linux-86/bootblocks/monitor.c --- linux-86.old/bootblocks/monitor.c Wed Jan 8 22:00:36 1997 +++ linux-86/bootblocks/monitor.c Wed May 7 22:42:24 1997 @@ -9,7 +9,7 @@ #include "readfs.h" #ifdef __STANDALONE__ -#define VT52COLOUR +#define NOT_VT52COLOUR #define NOT_ANSICOLOUR #endif @@ -27,6 +27,9 @@ static unsigned int current_address; static int number_base = 16; +#ifdef __STANDALONE__ + extern union REGS __argr; +#endif #ifdef __STANDALONE__ main() @@ -48,22 +51,17 @@ #endif init_prog(); - -#if 0 #ifdef __STANDALONE__ - reg_line(); -#endif -#ifdef VT52COLOUR - colour_line(); -#endif + if( (__argr.x.dx & 0xFF) == 0 ) #endif + { + display_help(0); - display_help(0); - - if(1) /* ( x86 > 2 && !x86_emu ) /* Check some basics */ - cmd_bzimage((void*)0); - else - printf("System appears incompatible use '=' to try anyway\n"); + if( x86 > 2 && !x86_emu ) /* Check some basics */ + cmd_bzimage((void*)0); + else + printf("System is not a 386+ in real mode, load aborted.\nUse 'bzimage' command toattempt load.\n"); + } for (;;) { @@ -175,7 +173,6 @@ #ifdef __STANDALONE__ reg_line() { - extern union REGS __argr; printf("REGS: AX=%04x BX=%04x CX=%04x DX=%04x SI=%04x DI=%04x\n", __argr.x.ax, __argr.x.bx, __argr.x.cx, __argr.x.dx, __argr.x.si, __argr.x.di); diff -Nurd linux-86.old/bootblocks/sysboot.s linux-86/bootblocks/sysboot.s --- linux-86.old/bootblocks/sysboot.s Thu Jan 2 09:53:48 1997 +++ linux-86/bootblocks/sysboot.s Sat May 3 08:03:40 1997 @@ -45,10 +45,37 @@ dos4_label: .blkb 11 ! Disk Label (DOS 4+) dos4_fattype: .blkb 8 ! FAT type +! +! This is where the code will be overlaid, the default is an 'oops' .blkb sysboot_start+0x3E-* public codestart codestart: - jmp codestart + xor ax,ax + mov ds,ax + mov es,ax + mov ss,ax + mov sp,ax + jmpi sys_code+$7C00-sysboot_start,#0 + +sys_code: ! SI now has pointer to error message + mov si,#sys_no_os+$7C00-sysboot_start +sys_nextc: + lodsb + cmp al,#0 + jz sys_eos + mov bx,#7 + mov ah,#$E ! Can't use $13 cause that's AT+ only! + int $10 + jmp sys_nextc +sys_eos: ! Wait for a key then reboot + xor ax,ax + int $16 + !int $19 ! This should be OK as we haven't touched anything. + jmpi $0,$FFFF ! Wam! Try or die! + +sys_no_os: + .asciz "PANIC! NO OS Found!\r\n" + ! Partition table public partition_1 diff -Nurd linux-86.old/copt/copt.diff linux-86/copt/copt.diff --- linux-86.old/copt/copt.diff Thu Jan 1 01:00:00 1970 +++ linux-86/copt/copt.diff Tue Apr 22 20:32:28 1997 @@ -0,0 +1,72 @@ +diff -rc linux-86.orig/copt/copt.c linux-86/copt/copt.c +*** linux-86.orig/copt/copt.c Tue Feb 18 21:31:34 1997 +--- linux-86/copt/copt.c Tue Apr 22 14:11:05 1997 +*************** +*** 303,314 **** + } + + +- +- /* +- * Eval an expression into an integer number +- */ +- static long eval(char *str, int len) +- { + #define NO_OP 0 + #define ADD_OP 1 + #define SUB_OP 2 +--- 303,308 ---- +*************** +*** 317,330 **** + #define SHL_OP 5 + #define SHR_OP 6 + +! char *oldcp, *cp, c; +! long retval = 0; +! long num = 0; +! int sign = 1; +! int base = 10; +! int state = 0; +! int op = NO_OP; +! int i, varnum; + + /* Apply operation to current numeric value */ + static void doretval(void) +--- 311,321 ---- + #define SHL_OP 5 + #define SHR_OP 6 + +! static int op = NO_OP; +! static long retval = 0; +! static long num = 0; +! static int sign = 1; +! static int base = 10; + + /* Apply operation to current numeric value */ + static void doretval(void) +*************** +*** 350,355 **** +--- 341,363 ---- + sign = 1; + base = 10; + } ++ ++ ++ /* ++ * Eval an expression into an integer number ++ */ ++ static long eval(char *str, int len) ++ { ++ ++ char *oldcp, *cp, c; ++ int state = 0; ++ int i, varnum; ++ ++ op = NO_OP; ++ retval = 0; ++ num = 0; ++ sign = 1; ++ base = 10; + + /* Scan through whole string and decode it */ + for (cp = str, i = 0; *cp && i < len; cp++, i++) { diff -Nurd linux-86.old/copt/rules.86 linux-86/copt/rules.86 --- linux-86.old/copt/rules.86 Tue Feb 18 21:40:53 1997 +++ linux-86/copt/rules.86 Wed Feb 26 19:55:01 1997 @@ -2,10 +2,9 @@ # Rules for loading short variables -# Chad says this one (I think) is broken -# mov %0$0[%2],%3 -# = -# mov %0[%2],%3 +mov %0$0[%2],%3 += +mov %0[%2],%3 mov %2,%[ax|bx|cx|dx]1 mov %[ax|bx|cx|dx]1,%2 @@ -131,12 +130,14 @@ # Rules for manipulating short values -mov %[ax|bx]2,%1 -%[add|and|xor|sub|or]4 %[ax|bx]2,%3 -mov %1,%[ax|bx]2 -= -mov %2,%3 -%4 %1,%2 +# This is the broken rule - Chad + +#mov %[ax|bx]2,%1 +#%[add|and|xor|sub|or]4 %[ax|bx]2,%3 +#mov %1,%[ax|bx]2 +#= +#mov %2,%3 +#%4 %1,%2 mov %[ax|bx]2,%1 %[add|and|xor|or]4 %[ax|bx]2,%3 diff -Nurd linux-86.old/elksemu/Makefile linux-86/elksemu/Makefile --- linux-86.old/elksemu/Makefile Mon Jan 27 22:13:26 1997 +++ linux-86/elksemu/Makefile Mon Mar 31 20:34:38 1997 @@ -10,6 +10,9 @@ CFLAGS=-O2 -fno-strength-reduce -Wall -idirafter . $(DEFS) endif +# Turn on elkemu's strace like facility. +# DEFS=-DDEBUG + # For gcc making a.out with a basically ELF compiler # CFLAGS=-O2 -fno-strength-reduce -b i486-linuxaout -N -s -static diff -Nurd linux-86.old/elksemu/elks.c linux-86/elksemu/elks.c --- linux-86.old/elksemu/elks.c Mon Jan 27 22:14:17 1997 +++ linux-86/elksemu/elks.c Sat Mar 22 19:39:51 1997 @@ -234,7 +234,7 @@ setregid(rgid, egid); setreuid(ruid, euid); - dbprintf(("ELKSEMU 0.0.6 Alpha\n")); + dbprintf(("ELKSEMU 0.12.0\n")); elks_init(); /* The Linux vm will deal with not allocating the unused pages */ diff -Nurd linux-86.old/elksemu/elks_sys.c linux-86/elksemu/elks_sys.c --- linux-86.old/elksemu/elks_sys.c Mon Oct 21 22:20:28 1996 +++ linux-86/elksemu/elks_sys.c Mon Mar 31 20:33:42 1997 @@ -110,13 +110,22 @@ bx,cx,dx)); if( bx >= 10000 && bx < 10000+DIRCOUNT) return elks_readdir(bx, cx, dx); + if( dx < 0 || dx > 1024 ) dx = 1024; return read(bx, ELKS_PTR(void, cx), dx); } #define sys_write elks_write static int elks_write(int bx,int cx,int dx,int di,int si) { - dbprintf(("write(%d, %d, %d)\n",bx,cx,dx)); + if( dx > 1024 || dx < 0 ) + { + dx = 1024; + dbprintf(("write(%d, %d, >%d)\n",bx,cx,dx)); + } + else + { + dbprintf(("write(%d, %d, %d)\n",bx,cx,dx)); + } return write(bx,ELKS_PTR(void, cx),dx); } diff -Nurd linux-86.old/ifdef.c linux-86/ifdef.c --- linux-86.old/ifdef.c Fri Jan 31 22:51:15 1997 +++ linux-86/ifdef.c Thu Apr 24 20:21:14 1997 @@ -2,6 +2,16 @@ #include #include +#include + +#ifdef __STDC__ /* == Not braindead compiler (hopefully!) */ +#include + +#define P(x) x +#else +#define P(x) () +#define void char +#endif struct varrec { @@ -32,6 +42,18 @@ char names[16][32]; char state[16]; +int main P((int argc, char ** argv)); +void Usage P((char * prog)); +void save_name P((char * varname, int state)); +void do_file P((char * fname)); +void set_line P((int lineno)); +int do_hashcom P((void)); +int do_ifdef P((char * p, int which)); +void check_name P((char * nm)); +void fatal P((char * msg)); +void manifest_constant P((void)); + +int main(argc, argv) int argc; char ** argv; @@ -77,7 +99,7 @@ exit(0); } -Usage(prog) +void Usage(prog) char * prog; { fprintf(stderr, "Usage: %s [-DFLAG] [-UFLAG] [-blcrMDU] [-C##] files\n", @@ -85,6 +107,7 @@ exit(1); } +void save_name(varname, state) char * varname; int state; @@ -110,7 +133,7 @@ curr->state = state; } - +void do_file(fname) char * fname; { @@ -146,6 +169,7 @@ fclose(fd); } +void set_line(lineno) int lineno; { @@ -156,6 +180,7 @@ prline = lineno; } +int do_hashcom() { char * p = linebuf+1; @@ -202,6 +227,7 @@ return 0; } +int do_ifdef(p, which) char * p; int which; @@ -245,6 +271,7 @@ return 1; } +void check_name(nm) char * nm; { @@ -270,6 +297,7 @@ fputc('\n', stderr); } +void fatal(msg) char * msg; { @@ -281,6 +309,7 @@ * * Unfortunatly I can find no way of discovering the variables automatically */ +void manifest_constant() { /* General */ @@ -289,6 +318,9 @@ #endif #ifdef __GNUC__ save_name("__GNUC__", 'D'); +#endif +#ifdef GNUMAKE + save_name("GNUMAKE", 'D'); #endif /* MSDOS */ diff -Nurd linux-86.old/ld/Makefile linux-86/ld/Makefile --- linux-86.old/ld/Makefile Sat Feb 1 14:03:06 1997 +++ linux-86/ld/Makefile Fri Apr 25 20:39:09 1997 @@ -4,11 +4,19 @@ LDFLAGS =-s # May need some of these if the auto-sense fails. -# -DV7_A_OUT -DBSD_A_OUT -DSTANDARD_GNU_A_OUT -DEFS =-DREL_OUTPUT +# -DV7_A_OUT # a.out.h is like V7 +# -DBSD_A_OUT # a.out.h is like BSD +# -DSTANDARD_GNU_A_OUT # a.out.h is like GNU normal. +# -DNO_AOUT # a.out.h is like nothing known! +# +DEFS =-DREL_OUTPUT -DBUGCOMPAT + +# An alternative file for a non-standard a.out.h (eg i386 linux on an Alpha) +# +# NATIVE= -DA_OUT_INCL='"a_out_local.h"' OBJS= dumps.o io.o ld.o readobj.o table.o typeconv.o linksyms.o \ - writex86.o writebin.o + writex86.o writebin.o writerel.o all: ld86 @@ -28,6 +36,11 @@ ar.h: ln -s ../libc/include/ar.h . || \ ln ../libc/include/ar.h . + +writebin.o: writebin.c + $(CC) $(CFLAGS) $(DEFS) $(NATIVE) -c writebin.c + +writerel.o: writebin.c .c.o: $(CC) $(CFLAGS) $(DEFS) -c $< -o $@ diff -Nurd linux-86.old/ld/align.h linux-86/ld/align.h --- linux-86.old/ld/align.h Sun Aug 4 19:41:12 1996 +++ linux-86/ld/align.h Thu Apr 24 21:20:13 1997 @@ -5,8 +5,14 @@ #ifndef S_ALIGNMENT # define align(x) #else -# define align(x) ((x)=(void*) \ - ((char *)(x) + ((S_ALIGNMENT-(int)(x)) & (S_ALIGNMENT-1)))) + +#if defined(__STDC__) && defined(_POSIX_SOURCE) +# define align(x) ((x)=(void *) \ + (((ssize_t)(x) + (S_ALIGNMENT-1)) & ~(S_ALIGNMENT-1))) +#else +# define align(x) ((x)=(void *) \ + ((char *)(x) + ((S_ALIGNMENT-(char)(x)) & (S_ALIGNMENT-1)))) +#endif #endif @@ -14,7 +20,4 @@ -/* * assumes sizeof(int) == sizeof(char *) * -# define align(x) ((x) = (void *)(((int) (x) + (S_ALIGNMENT-1)) & ~(S_ALIGNMENT-1))) -*/ diff -Nurd linux-86.old/ld/bindef.h linux-86/ld/bindef.h --- linux-86.old/ld/bindef.h Sun Dec 1 07:54:36 1996 +++ linux-86/ld/bindef.h Fri Apr 25 20:18:20 1997 @@ -66,8 +66,12 @@ # endif /* BSD_A_OUT */ /* And finally make sure it worked */ -#ifdef C_EXT +#if defined(A_MINHDR) || defined(BSD_A_OUT) +#if defined(C_EXT) && defined(C_STAT) && !defined(SCNHSZ) + #define AOUT_DETECTED 1 + +#endif #endif #endif /* NO_AOUT */ diff -Nurd linux-86.old/ld/bugs linux-86/ld/bugs --- linux-86.old/ld/bugs Sun Dec 1 17:46:14 1996 +++ linux-86/ld/bugs Thu Jan 1 01:00:00 1970 @@ -1,14 +0,0 @@ -1. Should cause error when an address which requires > 16 bits is referenced - using 16 bits. - -TODO: - integrate byteord.h with compiler as well as assembler - -TODO: - integrate align.h with compiler and assembler - use alignment for *86 like compiler - use more portable macro - ((x) + (-(int) (x) & MASK)) when it is either necessary or - faster - -TODO: - do malloc stuff better, as in compiler diff -Nurd linux-86.old/ld/byteord.h linux-86/ld/byteord.h --- linux-86.old/ld/byteord.h Sat Feb 19 22:35:28 1994 +++ linux-86/ld/byteord.h Sun Apr 13 12:34:16 1997 @@ -5,16 +5,16 @@ /* These are for the targets of everything and for linker source too. */ #ifdef I8086 -# define BIG_ENDIAN 0 +# define INT_BIG_ENDIAN 0 # define LONG_BIG_ENDIAN 0 /* except longs are back to front for Xenix */ #endif #ifdef I80386 -# define BIG_ENDIAN 0 +# define INT_BIG_ENDIAN 0 # define LONG_BIG_ENDIAN 0 #endif #ifdef MC6809 -# define BIG_ENDIAN 1 /* byte order in words is high-low */ +# define INT_BIG_ENDIAN 1 /* byte order in words is high-low */ # define LONG_BIG_ENDIAN 1 /* byte order in longs is high-low */ #endif diff -Nurd linux-86.old/ld/ld.c linux-86/ld/ld.c --- linux-86.old/ld/ld.c Fri Dec 20 21:30:17 1996 +++ linux-86/ld/ld.c Sun Apr 13 12:34:30 1997 @@ -83,7 +83,7 @@ ioinit(argv[0]); objinit(); syminit(); - typeconv_init(BIG_ENDIAN, LONG_BIG_ENDIAN); + typeconv_init(INT_BIG_ENDIAN, LONG_BIG_ENDIAN); #ifndef MC6809 flag['3'] = sizeof(char *) >= 4; #endif @@ -205,6 +205,7 @@ #ifdef REL_OUTPUT #ifndef MSDOS +#ifndef BUGCOMPAT if( flag['r'] && !flag['N'] ) { /* Ok, try for an alternate linker */ @@ -217,6 +218,7 @@ } #endif #endif +#endif #ifdef MSDOS /* MSDOS Native is special, we make a COM file */ @@ -238,6 +240,12 @@ #ifndef MSDOS if( flag['N'] ) writebin(outfilename, flag['i'], flag['3'], flag['s'], + flag['z'] & flag['3']); + else +#endif +#ifdef BUGCOMPAT + if( flag['r'] ) + write_rel(outfilename, flag['i'], flag['3'], flag['s'], flag['z'] & flag['3']); else #endif diff -Nurd linux-86.old/ld/rel_aout.h linux-86/ld/rel_aout.h --- linux-86.old/ld/rel_aout.h Thu Jan 1 01:00:00 1970 +++ linux-86/ld/rel_aout.h Tue Apr 22 21:30:03 1997 @@ -0,0 +1,383 @@ +#ifndef _BSD_A_OUT_H +#define _BSD_A_OUT_H + +struct exec { /* a.out header */ + unsigned char a_magic[2]; /* magic number */ + unsigned char a_flags; /* flags, see below */ + unsigned char a_cpu; /* cpu id */ + unsigned char a_hdrlen; /* length of header */ + unsigned char a_unused; /* reserved for future use */ + unsigned short a_version; /* version stamp (not used at present) */ + long a_text; /* size of text segement in bytes */ + long a_data; /* size of data segment in bytes */ + long a_bss; /* size of bss segment in bytes */ + long a_entry; /* entry point */ + long a_total; /* total memory allocated */ + long a_syms; /* size of symbol table */ + /* SHORT FORM ENDS HERE */ + + long a_trsize; /* text relocation size */ + long a_drsize; /* data relocation size */ + long a_tbase; /* text relocation base */ + long a_dbase; /* data relocation base */ +}; + +#define A_MAGIC0 ((unsigned char) 0x01) +#define A_MAGIC1 ((unsigned char) 0x03) +#define BADMAG(X) ((X).a_magic[0] != A_MAGIC0 || (X).a_magic[1] != A_MAGIC1) + +/* CPU Id of TARGET machine (byte order coded in low order two bits) */ +#define A_NONE 0x00 /* unknown */ +#define A_I8086 0x04 /* intel i8086/8088 */ +#define A_M68K 0x0B /* motorola m68000 */ +#define A_NS16K 0x0C /* national semiconductor 16032 */ +#define A_I80386 0x10 /* intel i80386 */ +#define A_SPARC 0x17 /* Sun SPARC */ + +#define A_BLR(cputype) ((cputype&0x01)!=0) /* TRUE if bytes left-to-right */ +#define A_WLR(cputype) ((cputype&0x02)!=0) /* TRUE if words left-to-right */ + +/* Flags. */ +#define A_UZP 0x01 /* unmapped zero page (pages) */ +#define A_EXEC 0x10 /* executable */ +#define A_SEP 0x20 /* separate I/D */ +#define A_PURE 0x40 /* pure text */ /* not used */ +#define A_TOVLY 0x80 /* text overlay */ /* not used */ + +/* Tell a.out.gnu.h not to define `struct exec'. */ +#define __STRUCT_EXEC_OVERRIDE__ + +/* Hide M_386 from enum declaration in a.out.h. */ +#define M_386 HIDE_M_386 + +#ifndef __A_OUT_GNU_H__ +#define __A_OUT_GNU_H__ + +#if defined(sequent) && defined(i386) +#define a_magic a_info +#include +#undef a_magic +#define __STRUCT_EXEC_OVERRIDE__ +#define N_NLIST_DECLARED +#define N_RELOCATION_INFO_DECLARED +#endif + +#define __GNU_EXEC_MACROS__ + +#ifndef __STRUCT_EXEC_OVERRIDE__ + +struct exec +{ + unsigned long a_info; /* Use macros N_MAGIC, etc for access */ + unsigned long a_text; /* length of text, in bytes */ + unsigned long a_data; /* length of data, in bytes */ + unsigned long a_bss; /* length of uninitialized data area for file, in bytes */ + unsigned long a_syms; /* length of symbol table data in file, in bytes */ + unsigned long a_entry; /* start address */ + unsigned long a_trsize; /* length of relocation info for text, in bytes */ + unsigned long a_drsize; /* length of relocation info for data, in bytes */ +}; + +#endif /* __STRUCT_EXEC_OVERRIDE__ */ + +/* these go in the N_MACHTYPE field */ +enum machine_type { +#if defined (M_OLDSUN2) + M__OLDSUN2 = M_OLDSUN2, +#else + M_OLDSUN2 = 0, +#endif +#if defined (M_68010) + M__68010 = M_68010, +#else + M_68010 = 1, +#endif +#if defined (M_68020) + M__68020 = M_68020, +#else + M_68020 = 2, +#endif +#if defined (M_SPARC) + M__SPARC = M_SPARC, +#else + M_SPARC = 3, +#endif + /* skip a bunch so we don't run into any of sun's numbers */ + M_386 = 100, +}; + +#if !defined (N_MAGIC) +#define N_MAGIC(exec) ((exec).a_info & 0xffff) +#endif +#define N_MACHTYPE(exec) ((enum machine_type)(((exec).a_info >> 16) & 0xff)) +#define N_FLAGS(exec) (((exec).a_info >> 24) & 0xff) +#define N_SET_INFO(exec, magic, type, flags) \ + ((exec).a_info = ((magic) & 0xffff) \ + | (((int)(type) & 0xff) << 16) \ + | (((flags) & 0xff) << 24)) +#define N_SET_MAGIC(exec, magic) \ + ((exec).a_info = (((exec).a_info & 0xffff0000) | ((magic) & 0xffff))) + +#define N_SET_MACHTYPE(exec, machtype) \ + ((exec).a_info = \ + ((exec).a_info&0xff00ffff) | ((((int)(machtype))&0xff) << 16)) + +#define N_SET_FLAGS(exec, flags) \ + ((exec).a_info = \ + ((exec).a_info&0x00ffffff) | (((flags) & 0xff) << 24)) + +#ifndef OMAGIC +/* Code indicating object file or impure executable. */ +#define OMAGIC 0407 +/* Code indicating pure executable. */ +#define NMAGIC 0410 +/* Code indicating demand-paged executable. */ +#define ZMAGIC 0413 +#endif /* not OMAGIC */ + +#if !defined (N_BADMAG) +#define N_BADMAG(x) \ + (N_MAGIC(x) != OMAGIC && N_MAGIC(x) != NMAGIC \ + && N_MAGIC(x) != ZMAGIC) +#endif + +#define _N_BADMAG(x) \ + (N_MAGIC(x) != OMAGIC && N_MAGIC(x) != NMAGIC \ + && N_MAGIC(x) != ZMAGIC) + +#define _N_HDROFF(x) (SEGMENT_SIZE - sizeof (struct exec)) + +#if !defined (N_TXTOFF) +#define N_TXTOFF(x) \ + (N_MAGIC(x) == ZMAGIC ? _N_HDROFF((x)) + sizeof (struct exec) : sizeof (struct exec)) +#endif + +#if !defined (N_DATOFF) +#define N_DATOFF(x) (N_TXTOFF(x) + (x).a_text) +#endif + +#if !defined (N_TRELOFF) +#define N_TRELOFF(x) (N_DATOFF(x) + (x).a_data) +#endif + +#if !defined (N_DRELOFF) +#define N_DRELOFF(x) (N_TRELOFF(x) + (x).a_trsize) +#endif + +#if !defined (N_SYMOFF) +#define N_SYMOFF(x) (N_DRELOFF(x) + (x).a_drsize) +#endif + +#if !defined (N_STROFF) +#define N_STROFF(x) (N_SYMOFF(x) + (x).a_syms) +#endif + +/* Address of text segment in memory after it is loaded. */ +#if !defined (N_TXTADDR) +#define N_TXTADDR(x) 0 +#endif + +/* Address of data segment in memory after it is loaded. + Note that it is up to you to define SEGMENT_SIZE + on machines not listed here. */ +#if defined(vax) || defined(hp300) || defined(pyr) +#define SEGMENT_SIZE PAGE_SIZE +#endif +#ifdef hp300 +#define PAGE_SIZE 4096 +#endif +#ifdef sony +#define SEGMENT_SIZE 0x2000 +#endif /* Sony. */ +#ifdef is68k +#define SEGMENT_SIZE 0x20000 +#endif +#if defined(m68k) && defined(PORTAR) +#define PAGE_SIZE 0x400 +#define SEGMENT_SIZE PAGE_SIZE +#endif + +#define _N_SEGMENT_ROUND(x) (((x) + SEGMENT_SIZE - 1) & ~(SEGMENT_SIZE - 1)) + +#define _N_TXTENDADDR(x) (N_TXTADDR(x)+(x).a_text) + +#ifndef N_DATADDR +#define N_DATADDR(x) \ + (N_MAGIC(x)==OMAGIC? (_N_TXTENDADDR(x)) \ + : (_N_SEGMENT_ROUND (_N_TXTENDADDR(x)))) +#endif + +/* Address of bss segment in memory after it is loaded. */ +#if !defined (N_BSSADDR) +#define N_BSSADDR(x) (N_DATADDR(x) + (x).a_data) +#endif + +#if !defined (N_NLIST_DECLARED) +struct nlist { + union { + char *n_name; + struct nlist *n_next; + long n_strx; + } n_un; + unsigned char n_type; + char n_other; + short n_desc; + unsigned long n_value; +}; +#endif /* no N_NLIST_DECLARED. */ + +#if !defined (N_UNDF) +#define N_UNDF 0 +#endif +#if !defined (N_ABS) +#define N_ABS 2 +#endif +#if !defined (N_TEXT) +#define N_TEXT 4 +#endif +#if !defined (N_DATA) +#define N_DATA 6 +#endif +#if !defined (N_BSS) +#define N_BSS 8 +#endif +#if !defined (N_COMM) +#define N_COMM 18 +#endif +#if !defined (N_FN) +#define N_FN 15 +#endif + +#if !defined (N_EXT) +#define N_EXT 1 +#endif +#if !defined (N_TYPE) +#define N_TYPE 036 +#endif +#if !defined (N_STAB) +#define N_STAB 0340 +#endif + +/* The following type indicates the definition of a symbol as being + an indirect reference to another symbol. The other symbol + appears as an undefined reference, immediately following this symbol. + + Indirection is asymmetrical. The other symbol's value will be used + to satisfy requests for the indirect symbol, but not vice versa. + If the other symbol does not have a definition, libraries will + be searched to find a definition. */ +#define N_INDR 0xa + +/* The following symbols refer to set elements. + All the N_SET[ATDB] symbols with the same name form one set. + Space is allocated for the set in the text section, and each set + element's value is stored into one word of the space. + The first word of the space is the length of the set (number of elements). + + The address of the set is made into an N_SETV symbol + whose name is the same as the name of the set. + This symbol acts like a N_DATA global symbol + in that it can satisfy undefined external references. */ + +/* These appear as input to LD, in a .o file. */ +#define N_SETA 0x14 /* Absolute set element symbol */ +#define N_SETT 0x16 /* Text set element symbol */ +#define N_SETD 0x18 /* Data set element symbol */ +#define N_SETB 0x1A /* Bss set element symbol */ + +/* This is output from LD. */ +#define N_SETV 0x1C /* Pointer to set vector in data area. */ + +#if !defined (N_RELOCATION_INFO_DECLARED) +/* This structure describes a single relocation to be performed. + The text-relocation section of the file is a vector of these structures, + all of which apply to the text section. + Likewise, the data-relocation section applies to the data section. */ + +struct relocation_info +{ + /* Address (within segment) to be relocated. */ + unsigned long r_address; +#if 0 + /* The meaning of r_symbolnum depends on r_extern. */ + unsigned int r_symbolnum:24; + /* Nonzero means value is a pc-relative offset + and it should be relocated for changes in its own address + as well as for changes in the symbol or section specified. */ + unsigned int r_pcrel:1; + /* Length (as exponent of 2) of the field to be relocated. + Thus, a value of 2 indicates 1<<2 bytes. */ + unsigned int r_length:2; + /* 1 => relocate with value of symbol. + r_symbolnum is the index of the symbol + in file's the symbol table. + 0 => relocate with the address of a segment. + r_symbolnum is N_TEXT, N_DATA, N_BSS or N_ABS + (the N_EXT bit may be set also, but signifies nothing). */ + unsigned int r_extern:1; + /* Four bits that aren't used, but when writing an object file + it is desirable to clear them. */ + unsigned int r_pad:4; +#else + unsigned long foo; +#endif +}; +#endif /* no N_RELOCATION_INFO_DECLARED. */ + + +#endif /* __A_OUT_GNU_H__ */ + +#undef M_386 +#define M_386 A_I80386 + +#undef N_MAGIC +#define N_MAGIC3(magic0, magic1, type) \ + ((magic0) | ((magic1) << 8) | ((type) << 16)) +#define N_MAGIC(exec) \ + N_MAGIC3((exec).a_magic[0], (exec).a_magic[1], (exec).a_flags) + +#undef N_MACHTYPE +#define N_MACHTYPE(exec) ((enum machine_type)((exec).a_cpu)) + +#undef N_FLAGS +#define N_FLAGS(exec) 0 + +#undef N_SET_INFO +#define N_SET_INFO(exec, magic, type, flags) \ + ((exec).a_magic[0] = (magic) & 0xff, \ + (exec).a_magic[1] = ((magic) >> 8) & 0xff, \ + (exec).a_flags = ((magic) >> 16) & 0xff, \ + (exec).a_cpu = (type) & 0xff) + +#undef N_SET_MAGIC +#define N_SET_MAGIC(exec, magic) \ + ((exec).a_magic[0] = (magic) & 0xff, \ + (exec).a_magic[1] = ((magic) >> 8) & 0xff, \ + (exec).a_flags = ((magic) >> 16) & 0xff) + +#undef N_SET_MACHTYPE +#define N_SET_MACHTYPE(exec, machtype) \ + ((exec).a_cpu = (machtype) & 0xff, \ + (exec).a_hdrlen = sizeof (exec)) + +#undef N_SET_FLAGS +#define N_SET_FLAGS(exec, flags) /* nothing */ + +#undef OMAGIC +#define OMAGIC N_MAGIC3(A_MAGIC0, A_MAGIC1, 0) + +#undef NMAGIC +#define NMAGIC N_MAGIC3(A_MAGIC0, A_MAGIC1, A_EXEC) + +#undef ZMAGIC +#define ZMAGIC N_MAGIC3(A_MAGIC0, A_MAGIC1, A_EXEC) + +#undef _N_HDROFF +#define _N_HDROFF(x) 0 + +#undef PAGE_SIZE +#define PAGE_SIZE 16 +#define SEGMENT_SIZE PAGE_SIZE +#define getpagesize() PAGE_SIZE + +#endif /* _BSD_A_OUT_H */ diff -Nurd linux-86.old/ld/type.h linux-86/ld/type.h --- linux-86.old/ld/type.h Sat Oct 26 10:52:26 1996 +++ linux-86/ld/type.h Fri Apr 25 20:34:27 1997 @@ -159,6 +159,9 @@ void writebin P((char *outfilename, bool_pt argsepid, bool_pt argbits32, bool_pt argstripflag, bool_pt arguzp)); +void write_rel P((char *outfilename, bool_pt argsepid, bool_pt argbits32, + bool_pt argstripflag, bool_pt arguzp)); + /* write_elks.c */ void write_elks P((char *outfilename, bool_pt argsepid, bool_pt argbits32, bool_pt argstripflag, bool_pt arguzp)); diff -Nurd linux-86.old/ld/typeconv.c linux-86/ld/typeconv.c --- linux-86.old/ld/typeconv.c Sat Feb 19 22:35:30 1994 +++ linux-86/ld/typeconv.c Fri Apr 25 21:02:49 1997 @@ -1,536 +1,187 @@ -/* typeconv.c - convert between char arrays and unsigneds */ - -/* Copyright (C) 1994 Bruce Evans */ /* - c2u2(): 2 byte array to 2 byte unsigned - c4u4(): 4 byte array to 4 byte unsigned - cnu2(): n byte array to 2 byte unsigned - cnu4(): n byte array to 4 byte unsigned - u2c2(): 2 byte unsigned to 2 byte array - u2cn(): 2 byte unsigned to n byte array - u4c4(): 4 byte unsigned to 4 byte array - u4cn(): 4 byte unsigned to n byte array - typeconv_init: (re)initialise for given byte order. - Default is no swapping, but the initialisation should be done - anyway to provide some validity checks (returns FALSE if error). - - Not provided: - c2u4(), c4u2(), u2c4(), u4c2(). - Each of these is best done by truncating or extending a return value - or argument to the appropiate fixed-count function. - c4u2() has too many cases to do in-line conveniently, and the others - are hardly more efficient when done in-line. - - 4 byte orderings for both char arrays and unsigneds are supported: - 0123 - little-endian - 3210 - big-endian - 2301 - little-endian with long words big-endian (pdp11) - 1032 - big-endian with long words little_endian (who knows?) - - The unsigned's byte order is that of the machine on which these - routines are running. - It is determined at run time initialisation since the compiler/ - preprocessor is too dumb to tell us at compile time. -*/ + * Type conversion routines, these have been rewritten for portability. + * + * The only requirement is now that the u2_t and u4_t must be big enough. + */ +#include "syshead.h" #include "const.h" #include "type.h" #include "globvar.h" -FORWARD u2_pt c2u2_00 P((char *buf)); -FORWARD u4_pt c4u4_00 P((char *buf)); -FORWARD u2_pt c2u2_ss P((char *buf)); -FORWARD u4_pt c4u4_ss P((char *buf)); -FORWARD u4_pt c4u4_s0 P((char *buf)); -FORWARD u4_pt c4u4_0s P((char *buf)); -FORWARD void u2c2_00 P((char *buf, u2_pt offset)); -FORWARD void u4c4_00 P((char *buf, u4_t offset)); -FORWARD void u2c2_ss P((char *buf, u2_pt offset)); -FORWARD void u4c4_ss P((char *buf, u4_t offset)); -FORWARD void u4c4_s0 P((char *buf, u4_t offset)); -FORWARD void u4c4_0s P((char *buf, u4_t offset)); - -PRIVATE u2_pt (*pc2u2) P((char *buf)) = c2u2_00; -PRIVATE u4_pt (*pc4u4) P((char *buf)) = c4u4_00; -PRIVATE void (*pu2c2) P((char *buf, u2_pt offset)) = u2c2_00; -PRIVATE void (*pu4c4) P((char *buf, u4_t offset)) = u4c4_00; - -/* === char arrays to unsigneds === */ - -/* no bytes swapped, longwinded to avoid alignment problems */ - -PRIVATE u2_pt c2u2_00(buf) -register char *buf; -{ - u2_t offset; - - ((char *) &offset)[0] = buf[0]; - ((char *) &offset)[1] = buf[1]; - return offset; -} - -PRIVATE u4_pt c4u4_00(buf) -register char *buf; -{ - u4_t offset; - - ((char *) &offset)[0] = buf[0]; - ((char *) &offset)[1] = buf[1]; - ((char *) &offset)[2] = buf[2]; - ((char *) &offset)[3] = buf[3]; - return offset; -} - -/* straight swapping for little-endian to big-endian and vice versa */ - -PRIVATE u2_pt c2u2_ss(buf) -register char *buf; -{ - u2_t offset; - - ((char *) &offset)[0] = buf[1]; - ((char *) &offset)[1] = buf[0]; - return offset; -} - -PRIVATE u4_pt c4u4_ss(buf) -register char *buf; -{ - u4_t offset; +void xxerr P((char *)); +void xxerr(x) char * x; { write(2, x, strlen(x)); } - ((char *) &offset)[0] = buf[3]; - ((char *) &offset)[1] = buf[2]; - ((char *) &offset)[2] = buf[1]; - ((char *) &offset)[3] = buf[0]; - return offset; -} +static int no_swap = 1; -/* wierd swapping for different-endian u2's, same-endian u4's */ +static long_off[4] = {0,1,2,3}; +static int_off[2] = {0,1}; -PRIVATE u4_pt c4u4_s0(buf) -register char *buf; +PUBLIC bool_pt typeconv_init(big_endian, long_big_endian) +bool_pt big_endian; +bool_pt long_big_endian; { - u4_t offset; - - ((char *) &offset)[0] = buf[1]; - ((char *) &offset)[1] = buf[0]; - ((char *) &offset)[2] = buf[3]; - ((char *) &offset)[3] = buf[2]; - return offset; -} + int i; + no_swap = (!big_endian && !long_big_endian); -/* very wierd swapping for same-endian u2's, different-endian u4's */ + for(i=0; i<4; i++) long_off[i] = i; + for(i=0; i<2; i++) int_off[i] = i; -PRIVATE u4_pt c4u4_0s(buf) -register char *buf; -{ - u4_t offset; + if( long_big_endian ) + { + i = long_off[0]; long_off[0] = long_off[2]; long_off[2] = i; + i = long_off[1]; long_off[1] = long_off[3]; long_off[3] = i; + } + if( big_endian ) + { + i = long_off[2]; long_off[2] = long_off[3]; long_off[3] = i; + i = long_off[0]; long_off[0] = long_off[1]; long_off[1] = i; - ((char *) &offset)[0] = buf[2]; - ((char *) &offset)[1] = buf[3]; - ((char *) &offset)[2] = buf[0]; - ((char *) &offset)[3] = buf[1]; - return offset; + i = int_off[0]; int_off[0] = int_off[1]; int_off[1] = i; + } + return 1; } -/* === entry points === */ - -PUBLIC u2_pt c2u2(buf) +PUBLIC void u2c2(buf, offset) char *buf; +u2_pt offset; { - return (*pc2u2) (buf); +#ifdef __AS386_16__ + if( no_swap ) + { + *((unsigned short*)buf) = offset; /* UNALIGNED ACCESS! */ + return; + } +#endif + buf[int_off[0]] = offset; + buf[int_off[1]] = (offset>>8); } -PUBLIC u4_t c4u4(buf) +PUBLIC void u4c4(buf, offset) char *buf; +u4_t offset; { - return (*pc4u4) (buf); + int i; +#ifdef __AS386_16__ + if( no_swap ) + { + *((unsigned long*)buf) = offset; /* UNALIGNED ACCESS! */ + return; + } +#endif + for(i=0; i<4; i++) + { + buf[long_off[i]] = offset; + offset >>= 8; + } } -PUBLIC u2_pt cnu2(buf, count) +PUBLIC void u4cn(buf, offset, count) char *buf; +u4_t offset; unsigned count; { - switch (count) + switch(count) { case 1: - return buf[0] & 0xFF; + buf[0] = (char) offset; + return; case 2: - return (*pc2u2) (buf); + u2c2(buf, (u2_pt) offset); + return; case 4: - return (u2_pt) (*pc4u4) (buf); + u4c4(buf, (u4_t) offset); + return; default: - return 0; + xxerr("WARNING: typeconv.c(u4cn) illegal count\n"); + return; } } -PUBLIC u4_t cnu4(buf, count) +PUBLIC void u2cn(buf, offset, count) char *buf; +u2_pt offset; unsigned count; { - switch (count) + switch(count) { case 1: - return buf[0] & 0xFF; + buf[0] = (char) offset; + return; case 2: - return (*pc2u2) (buf); + u2c2(buf, (u2_pt) offset); + return; case 4: - return (*pc4u4) (buf); + u4c4(buf, (u4_t) offset); + return; default: - return 0; + xxerr("WARNING: typeconv.c(u2cn) illegal count\n"); + return; } } -/* === unsigneds to char arrays === */ - -/* no bytes swapped, longwinded to avoid alignment problems */ - -PRIVATE void u2c2_00(buf, offset) -register char *buf; -u2_pt offset; -{ - - buf[0] = ((char *) &offset)[0]; - buf[1] = ((char *) &offset)[1]; -} - -PRIVATE void u4c4_00(buf, offset) -register char *buf; -u4_t offset; -{ - buf[0] = ((char *) &offset)[0]; - buf[1] = ((char *) &offset)[1]; - buf[2] = ((char *) &offset)[2]; - buf[3] = ((char *) &offset)[3]; -} - -/* straight swapping for little-endian to big-endian and vice versa */ - -PRIVATE void u2c2_ss(buf, offset) -register char *buf; -u2_pt offset; -{ - u2_t offset2; - - offset2 = offset; - buf[0] = ((char *) &offset2)[1]; - buf[1] = ((char *) &offset2)[0]; -} - -PRIVATE void u4c4_ss(buf, offset) -register char *buf; -u4_t offset; -{ - buf[0] = ((char *) &offset)[3]; - buf[1] = ((char *) &offset)[2]; - buf[2] = ((char *) &offset)[1]; - buf[3] = ((char *) &offset)[0]; -} - -/* wierd swapping for different-endian u2's, same-endian u4's */ - -PRIVATE void u4c4_s0(buf, offset) -register char *buf; -u4_t offset; -{ - buf[0] = ((char *) &offset)[1]; - buf[1] = ((char *) &offset)[0]; - buf[2] = ((char *) &offset)[3]; - buf[3] = ((char *) &offset)[2]; -} - -/* very wierd swapping for same-endian u2's, different-endian u4's */ - -PRIVATE void u4c4_0s(buf, offset) -register char *buf; -u4_t offset; +PUBLIC u2_pt c2u2(buf) +char *buf; { - buf[0] = ((char *) &offset)[2]; - buf[1] = ((char *) &offset)[3]; - buf[2] = ((char *) &offset)[0]; - buf[3] = ((char *) &offset)[1]; -} - -/* === entry points === */ + u2_pt res; +#ifdef __AS386_16__ + if( no_swap ) return *((u2_pt *)buf); /* UNALIGNED ACCESS! */ +#endif -PUBLIC void u2c2(buf, offset) -register char *buf; -u2_pt offset; -{ - (*pu2c2) (buf, offset); + res = ((unsigned char *)buf) [int_off[0]] + + ((((unsigned char *)buf) [int_off[1]]) << 8); + return res; } -PUBLIC void u4c4(buf, offset) -register char *buf; -u4_t offset; +PUBLIC u4_t c4u4(buf) +char *buf; { - (*pu4c4) (buf, offset); + u4_t res; + int i; +#ifdef __AS386_16__ + if( no_swap ) return *((u4_t *)buf); /* UNALIGNED ACCESS! */ +#endif + res = 0; + for(i=3; i>=0; i--) + { + res = (res<<8) + ((unsigned char *)buf) [long_off[i]]; + } + return res; } -PUBLIC void u2cn(buf, offset, count) -register char *buf; -u2_pt offset; +PUBLIC u4_t cnu4(buf, count) +char *buf; unsigned count; { switch (count) { case 1: - buf[0] = (char) offset; - return; + return buf[0] & 0xFF; case 2: - (*pu2c2) (buf, offset); - return; + return c2u2(buf); case 4: - (*pu4c4) (buf, (u4_t) offset); - return; + return c4u4(buf); + default: + xxerr("WARNING: typeconv.c(cnu4) illegal count\n"); + return 0; } } -PUBLIC void u4cn(buf, offset, count) -register char *buf; -u4_t offset; +PUBLIC u2_pt cnu2(buf, count) +char *buf; unsigned count; { switch (count) { case 1: - buf[0] = (char) offset; - return; + return buf[0] & 0xFF; case 2: - (*pu2c2) (buf, (u2_pt) (u2_t) offset); - return; + return c2u2(buf); case 4: - (*pu4c4) (buf, offset); - return; - } -} - -/* initialise type conversion, return FALSE if it cannot be handled */ - -PUBLIC bool_pt typeconv_init(big_endian, long_big_endian) -bool_pt big_endian; -bool_pt long_big_endian; -{ - u2_pt conv2; - u4_pt conv4; - char *conv2ptr; - char *conv4ptr; - - if (sizeof(u2_t) != 2 || sizeof(u4_t) != 4) - /* dumb preprocessor's don't accept sizeof in #if expressions */ - return FALSE; - - if (big_endian) - { - conv2ptr = (conv4ptr = "\1\2\3\4") + 2; - if (!long_big_endian) - conv4ptr = "\3\4\1\2"; - } - else - { - conv2ptr = conv4ptr = "\4\3\2\1"; - if (long_big_endian) - conv4ptr = "\2\1\4\3"; - } - conv2 = c2u2_00(conv2ptr); - conv4 = c4u4_00(conv4ptr); - if (conv2 == 0x0304) - { - pc2u2 = c2u2_00; - pc4u4 = c4u4_00; - pu2c2 = u2c2_00; - pu4c4 = u4c4_00; - if (conv4 == 0x03040102L) - { - pc4u4 = c4u4_0s; - pu4c4 = u4c4_0s; - } - else if (conv4 != 0x01020304L) - return FALSE; - } - else if (conv2 == 0x0403) - { - pc2u2 = c2u2_ss; - pc4u4 = c4u4_ss; - pu2c2 = u2c2_ss; - pu4c4 = u4c4_ss; - if (conv4 == 0x02010403L) - { - pc4u4 = c4u4_s0; - pu4c4 = u4c4_s0; - } - else if (conv4 != 0x04030201L) - return FALSE; + return (u2_pt) c4u4(buf); + default: + xxerr("WARNING: typeconv.c(cnu2) illegal count\n"); + return 0; } - else - return FALSE; - return TRUE; } - -#ifdef DEBUG_TYPECONV - -main() -{ - char *source; - char target[4]; - u2_t u2; - u2_t u2a; - u4_t u4; - u4_t u4a; - - printf("%u\n", typeconv_init(FALSE, FALSE)); - printf("%u\n", typeconv_init(FALSE, TRUE)); - printf("%u\n", typeconv_init(TRUE, FALSE)); - printf("%u\n", typeconv_init(TRUE, TRUE)); - - typeconv_init(FALSE, FALSE); - source = "\4\3\2\1"; - - target[0] = 0; - target[1] = 0; - u2 = cnu2(source, 2); - u2cn(target, u2, 2); - if (strncmp(source, target, 2)) - printf("oops9\n"); - - target[0] = 0; - target[1] = 0; - u4a = cnu4(source, 2); - u4cn(target, u4a, 2); - if (strncmp(source, target, 2)) - printf("oops10\n"); - - target[0] = 0; - target[1] = 0; - target[2] = 0; - target[3] = 0; - u2a = cnu2(source, 4); - u2cn(target, u2a, 4); - if (strncmp(target, "\4\3\0\0", 4)) - printf("oops11\n"); - - target[0] = 0; - target[1] = 0; - target[2] = 0; - target[3] = 0; - u4 = cnu4(source, 4); - u4cn(target, u4, 4); - if (strncmp(source, target, 4)) - printf("oops12\n"); - - printf("%04x %04x %08lx %08lx\n", u2, u2a, u4, u4a); - - typeconv_init(FALSE, TRUE); - source = "\2\1\4\3"; - - target[0] = 0; - target[1] = 0; - u2 = cnu2(source + 2, 2); - u2cn(target, u2, 2); - if (strncmp(source + 2, target, 2)) - printf("oops13\n"); - - target[0] = 0; - target[1] = 0; - u4a = cnu4(source + 2, 2); - u4cn(target, u4a, 2); - if (strncmp(source + 2, target, 2)) - printf("oops14\n"); - - target[0] = 0; - target[1] = 0; - target[2] = 0; - target[3] = 0; - u2a = cnu2(source, 4); - u2cn(target, u2a, 4); - if (strncmp(target, "\0\0\4\3", 4)) - printf("oops15\n"); - - target[0] = 0; - target[1] = 0; - target[2] = 0; - target[3] = 0; - u4 = cnu4(source, 4); - u4cn(target, u4, 4); - if (strncmp(source, target, 4)) - printf("oops16\n"); - - printf("%04x %04x %08lx %08lx\n", u2, u2a, u4, u4a); - - typeconv_init(TRUE, FALSE); - source = "\3\4\1\2"; - - target[0] = 0; - target[1] = 0; - u2 = cnu2(source, 2); - u2cn(target, u2, 2); - if (strncmp(source, target, 2)) - printf("oops5\n"); - - target[0] = 0; - target[1] = 0; - u4a = cnu4(source, 2); - u4cn(target, u4a, 2); - if (strncmp(source, target, 2)) - printf("oops6\n"); - - target[0] = 0; - target[1] = 0; - target[2] = 0; - target[3] = 0; - u2a = cnu2(source, 4); - u2cn(target, u2a, 4); - if (strncmp(target, "\3\4\0\0", 4)) - printf("oops7\n"); - - target[0] = 0; - target[1] = 0; - target[2] = 0; - target[3] = 0; - u4 = cnu4(source, 4); - u4cn(target, u4, 4); - if (strncmp(source, target, 4)) - printf("oops8\n"); - - printf("%04x %04x %08lx %08lx\n", u2, u2a, u4, u4a); - - typeconv_init(TRUE, TRUE); - source = "\1\2\3\4"; - - target[0] = 0; - target[1] = 0; - u2 = cnu2(source + 2, 2); - u2cn(target, u2, 2); - if (strncmp(source + 2, target, 2)) - printf("oops1\n"); - - target[0] = 0; - target[1] = 0; - u4a = cnu4(source + 2, 2); - u4cn(target, u4a, 2); - if (strncmp(source + 2, target, 2)) - printf("oops2\n"); - - target[0] = 0; - target[1] = 0; - target[2] = 0; - target[3] = 0; - u2a = cnu2(source, 4); - u2cn(target, u2a, 4); - if (strncmp(target, "\0\0\3\4", 4)) - printf("oops3\n"); - - target[0] = 0; - target[1] = 0; - target[2] = 0; - target[3] = 0; - u4 = cnu4(source, 4); - u4cn(target, u4, 4); - if (strncmp(source, target, 4)) - printf("oops4\n"); - - printf("%04x %04x %08lx %08lx\n", u2, u2a, u4, u4a); -} - -#endif /* DEBUG_TYPECONV */ diff -Nurd linux-86.old/ld/typeconv.c.old linux-86/ld/typeconv.c.old --- linux-86.old/ld/typeconv.c.old Thu Jan 1 01:00:00 1970 +++ linux-86/ld/typeconv.c.old Sun Apr 13 14:57:23 1997 @@ -0,0 +1,536 @@ +/* typeconv.c - convert between char arrays and unsigneds */ + +/* Copyright (C) 1994 Bruce Evans */ + +/* + c2u2(): 2 byte array to 2 byte unsigned + c4u4(): 4 byte array to 4 byte unsigned + cnu2(): n byte array to 2 byte unsigned + cnu4(): n byte array to 4 byte unsigned + u2c2(): 2 byte unsigned to 2 byte array + u2cn(): 2 byte unsigned to n byte array + u4c4(): 4 byte unsigned to 4 byte array + u4cn(): 4 byte unsigned to n byte array + typeconv_init: (re)initialise for given byte order. + Default is no swapping, but the initialisation should be done + anyway to provide some validity checks (returns FALSE if error). + + Not provided: + c2u4(), c4u2(), u2c4(), u4c2(). + Each of these is best done by truncating or extending a return value + or argument to the appropiate fixed-count function. + c4u2() has too many cases to do in-line conveniently, and the others + are hardly more efficient when done in-line. + + 4 byte orderings for both char arrays and unsigneds are supported: + 0123 - little-endian + 3210 - big-endian + 2301 - little-endian with long words big-endian (pdp11) + 1032 - big-endian with long words little_endian (who knows?) + + The unsigned's byte order is that of the machine on which these + routines are running. + It is determined at run time initialisation since the compiler/ + preprocessor is too dumb to tell us at compile time. +*/ + +#include "const.h" +#include "type.h" +#include "globvar.h" + +FORWARD u2_pt c2u2_00 P((char *buf)); +FORWARD u4_pt c4u4_00 P((char *buf)); +FORWARD u2_pt c2u2_ss P((char *buf)); +FORWARD u4_pt c4u4_ss P((char *buf)); +FORWARD u4_pt c4u4_s0 P((char *buf)); +FORWARD u4_pt c4u4_0s P((char *buf)); +FORWARD void u2c2_00 P((char *buf, u2_pt offset)); +FORWARD void u4c4_00 P((char *buf, u4_t offset)); +FORWARD void u2c2_ss P((char *buf, u2_pt offset)); +FORWARD void u4c4_ss P((char *buf, u4_t offset)); +FORWARD void u4c4_s0 P((char *buf, u4_t offset)); +FORWARD void u4c4_0s P((char *buf, u4_t offset)); + +PRIVATE u2_pt (*pc2u2) P((char *buf)) = c2u2_00; +PRIVATE u4_pt (*pc4u4) P((char *buf)) = c4u4_00; +PRIVATE void (*pu2c2) P((char *buf, u2_pt offset)) = u2c2_00; +PRIVATE void (*pu4c4) P((char *buf, u4_t offset)) = u4c4_00; + +/* === char arrays to unsigneds === */ + +/* no bytes swapped, longwinded to avoid alignment problems */ + +PRIVATE u2_pt c2u2_00(buf) +register char *buf; +{ + u2_t offset; + + ((char *) &offset)[0] = buf[0]; + ((char *) &offset)[1] = buf[1]; + return offset; +} + +PRIVATE u4_pt c4u4_00(buf) +register char *buf; +{ + u4_t offset; + + ((char *) &offset)[0] = buf[0]; + ((char *) &offset)[1] = buf[1]; + ((char *) &offset)[2] = buf[2]; + ((char *) &offset)[3] = buf[3]; + return offset; +} + +/* straight swapping for little-endian to big-endian and vice versa */ + +PRIVATE u2_pt c2u2_ss(buf) +register char *buf; +{ + u2_t offset; + + ((char *) &offset)[0] = buf[1]; + ((char *) &offset)[1] = buf[0]; + return offset; +} + +PRIVATE u4_pt c4u4_ss(buf) +register char *buf; +{ + u4_t offset; + + ((char *) &offset)[0] = buf[3]; + ((char *) &offset)[1] = buf[2]; + ((char *) &offset)[2] = buf[1]; + ((char *) &offset)[3] = buf[0]; + return offset; +} + +/* wierd swapping for different-endian u2's, same-endian u4's */ + +PRIVATE u4_pt c4u4_s0(buf) +register char *buf; +{ + u4_t offset; + + ((char *) &offset)[0] = buf[1]; + ((char *) &offset)[1] = buf[0]; + ((char *) &offset)[2] = buf[3]; + ((char *) &offset)[3] = buf[2]; + return offset; +} + +/* very wierd swapping for same-endian u2's, different-endian u4's */ + +PRIVATE u4_pt c4u4_0s(buf) +register char *buf; +{ + u4_t offset; + + ((char *) &offset)[0] = buf[2]; + ((char *) &offset)[1] = buf[3]; + ((char *) &offset)[2] = buf[0]; + ((char *) &offset)[3] = buf[1]; + return offset; +} + +/* === entry points === */ + +PUBLIC u2_pt c2u2(buf) +char *buf; +{ + return (*pc2u2) (buf); +} + +PUBLIC u4_t c4u4(buf) +char *buf; +{ + return (*pc4u4) (buf); +} + +PUBLIC u2_pt cnu2(buf, count) +char *buf; +unsigned count; +{ + switch (count) + { + case 1: + return buf[0] & 0xFF; + case 2: + return (*pc2u2) (buf); + case 4: + return (u2_pt) (*pc4u4) (buf); + default: + return 0; + } +} + +PUBLIC u4_t cnu4(buf, count) +char *buf; +unsigned count; +{ + switch (count) + { + case 1: + return buf[0] & 0xFF; + case 2: + return (*pc2u2) (buf); + case 4: + return (*pc4u4) (buf); + default: + return 0; + } +} + +/* === unsigneds to char arrays === */ + +/* no bytes swapped, longwinded to avoid alignment problems */ + +PRIVATE void u2c2_00(buf, offset) +register char *buf; +u2_pt offset; +{ + + buf[0] = ((char *) &offset)[0]; + buf[1] = ((char *) &offset)[1]; +} + +PRIVATE void u4c4_00(buf, offset) +register char *buf; +u4_t offset; +{ + buf[0] = ((char *) &offset)[0]; + buf[1] = ((char *) &offset)[1]; + buf[2] = ((char *) &offset)[2]; + buf[3] = ((char *) &offset)[3]; +} + +/* straight swapping for little-endian to big-endian and vice versa */ + +PRIVATE void u2c2_ss(buf, offset) +register char *buf; +u2_pt offset; +{ + u2_t offset2; + + offset2 = offset; + buf[0] = ((char *) &offset2)[1]; + buf[1] = ((char *) &offset2)[0]; +} + +PRIVATE void u4c4_ss(buf, offset) +register char *buf; +u4_t offset; +{ + buf[0] = ((char *) &offset)[3]; + buf[1] = ((char *) &offset)[2]; + buf[2] = ((char *) &offset)[1]; + buf[3] = ((char *) &offset)[0]; +} + +/* wierd swapping for different-endian u2's, same-endian u4's */ + +PRIVATE void u4c4_s0(buf, offset) +register char *buf; +u4_t offset; +{ + buf[0] = ((char *) &offset)[1]; + buf[1] = ((char *) &offset)[0]; + buf[2] = ((char *) &offset)[3]; + buf[3] = ((char *) &offset)[2]; +} + +/* very wierd swapping for same-endian u2's, different-endian u4's */ + +PRIVATE void u4c4_0s(buf, offset) +register char *buf; +u4_t offset; +{ + buf[0] = ((char *) &offset)[2]; + buf[1] = ((char *) &offset)[3]; + buf[2] = ((char *) &offset)[0]; + buf[3] = ((char *) &offset)[1]; +} + +/* === entry points === */ + +PUBLIC void u2c2(buf, offset) +register char *buf; +u2_pt offset; +{ + (*pu2c2) (buf, offset); +} + +PUBLIC void u4c4(buf, offset) +register char *buf; +u4_t offset; +{ + (*pu4c4) (buf, offset); +} + +PUBLIC void u2cn(buf, offset, count) +register char *buf; +u2_pt offset; +unsigned count; +{ + switch (count) + { + case 1: + buf[0] = (char) offset; + return; + case 2: + (*pu2c2) (buf, offset); + return; + case 4: + (*pu4c4) (buf, (u4_t) offset); + return; + } +} + +PUBLIC void u4cn(buf, offset, count) +register char *buf; +u4_t offset; +unsigned count; +{ + switch (count) + { + case 1: + buf[0] = (char) offset; + return; + case 2: + (*pu2c2) (buf, (u2_pt) (u2_t) offset); + return; + case 4: + (*pu4c4) (buf, offset); + return; + } +} + +/* initialise type conversion, return FALSE if it cannot be handled */ + +PUBLIC bool_pt typeconv_init(big_endian, long_big_endian) +bool_pt big_endian; +bool_pt long_big_endian; +{ + u2_pt conv2; + u4_pt conv4; + char *conv2ptr; + char *conv4ptr; + + if (sizeof(u2_t) != 2 || sizeof(u4_t) != 4) + /* dumb preprocessor's don't accept sizeof in #if expressions */ + return FALSE; + + if (big_endian) + { + conv2ptr = (conv4ptr = "\1\2\3\4") + 2; + if (!long_big_endian) + conv4ptr = "\3\4\1\2"; + } + else + { + conv2ptr = conv4ptr = "\4\3\2\1"; + if (long_big_endian) + conv4ptr = "\2\1\4\3"; + } + conv2 = c2u2_00(conv2ptr); + conv4 = c4u4_00(conv4ptr); + if (conv2 == 0x0304) + { + pc2u2 = c2u2_00; + pc4u4 = c4u4_00; + pu2c2 = u2c2_00; + pu4c4 = u4c4_00; + if (conv4 == 0x03040102L) + { + pc4u4 = c4u4_0s; + pu4c4 = u4c4_0s; + } + else if (conv4 != 0x01020304L) + return FALSE; + } + else if (conv2 == 0x0403) + { + pc2u2 = c2u2_ss; + pc4u4 = c4u4_ss; + pu2c2 = u2c2_ss; + pu4c4 = u4c4_ss; + if (conv4 == 0x02010403L) + { + pc4u4 = c4u4_s0; + pu4c4 = u4c4_s0; + } + else if (conv4 != 0x04030201L) + return FALSE; + } + else + return FALSE; + return TRUE; +} + +#ifdef DEBUG_TYPECONV + +main() +{ + char *source; + char target[4]; + u2_t u2; + u2_t u2a; + u4_t u4; + u4_t u4a; + + printf("%u\n", typeconv_init(FALSE, FALSE)); + printf("%u\n", typeconv_init(FALSE, TRUE)); + printf("%u\n", typeconv_init(TRUE, FALSE)); + printf("%u\n", typeconv_init(TRUE, TRUE)); + + typeconv_init(FALSE, FALSE); + source = "\4\3\2\1"; + + target[0] = 0; + target[1] = 0; + u2 = cnu2(source, 2); + u2cn(target, u2, 2); + if (strncmp(source, target, 2)) + printf("oops9\n"); + + target[0] = 0; + target[1] = 0; + u4a = cnu4(source, 2); + u4cn(target, u4a, 2); + if (strncmp(source, target, 2)) + printf("oops10\n"); + + target[0] = 0; + target[1] = 0; + target[2] = 0; + target[3] = 0; + u2a = cnu2(source, 4); + u2cn(target, u2a, 4); + if (strncmp(target, "\4\3\0\0", 4)) + printf("oops11\n"); + + target[0] = 0; + target[1] = 0; + target[2] = 0; + target[3] = 0; + u4 = cnu4(source, 4); + u4cn(target, u4, 4); + if (strncmp(source, target, 4)) + printf("oops12\n"); + + printf("%04x %04x %08lx %08lx\n", u2, u2a, u4, u4a); + + typeconv_init(FALSE, TRUE); + source = "\2\1\4\3"; + + target[0] = 0; + target[1] = 0; + u2 = cnu2(source + 2, 2); + u2cn(target, u2, 2); + if (strncmp(source + 2, target, 2)) + printf("oops13\n"); + + target[0] = 0; + target[1] = 0; + u4a = cnu4(source + 2, 2); + u4cn(target, u4a, 2); + if (strncmp(source + 2, target, 2)) + printf("oops14\n"); + + target[0] = 0; + target[1] = 0; + target[2] = 0; + target[3] = 0; + u2a = cnu2(source, 4); + u2cn(target, u2a, 4); + if (strncmp(target, "\0\0\4\3", 4)) + printf("oops15\n"); + + target[0] = 0; + target[1] = 0; + target[2] = 0; + target[3] = 0; + u4 = cnu4(source, 4); + u4cn(target, u4, 4); + if (strncmp(source, target, 4)) + printf("oops16\n"); + + printf("%04x %04x %08lx %08lx\n", u2, u2a, u4, u4a); + + typeconv_init(TRUE, FALSE); + source = "\3\4\1\2"; + + target[0] = 0; + target[1] = 0; + u2 = cnu2(source, 2); + u2cn(target, u2, 2); + if (strncmp(source, target, 2)) + printf("oops5\n"); + + target[0] = 0; + target[1] = 0; + u4a = cnu4(source, 2); + u4cn(target, u4a, 2); + if (strncmp(source, target, 2)) + printf("oops6\n"); + + target[0] = 0; + target[1] = 0; + target[2] = 0; + target[3] = 0; + u2a = cnu2(source, 4); + u2cn(target, u2a, 4); + if (strncmp(target, "\3\4\0\0", 4)) + printf("oops7\n"); + + target[0] = 0; + target[1] = 0; + target[2] = 0; + target[3] = 0; + u4 = cnu4(source, 4); + u4cn(target, u4, 4); + if (strncmp(source, target, 4)) + printf("oops8\n"); + + printf("%04x %04x %08lx %08lx\n", u2, u2a, u4, u4a); + + typeconv_init(TRUE, TRUE); + source = "\1\2\3\4"; + + target[0] = 0; + target[1] = 0; + u2 = cnu2(source + 2, 2); + u2cn(target, u2, 2); + if (strncmp(source + 2, target, 2)) + printf("oops1\n"); + + target[0] = 0; + target[1] = 0; + u4a = cnu4(source + 2, 2); + u4cn(target, u4a, 2); + if (strncmp(source + 2, target, 2)) + printf("oops2\n"); + + target[0] = 0; + target[1] = 0; + target[2] = 0; + target[3] = 0; + u2a = cnu2(source, 4); + u2cn(target, u2a, 4); + if (strncmp(target, "\0\0\3\4", 4)) + printf("oops3\n"); + + target[0] = 0; + target[1] = 0; + target[2] = 0; + target[3] = 0; + u4 = cnu4(source, 4); + u4cn(target, u4, 4); + if (strncmp(source, target, 4)) + printf("oops4\n"); + + printf("%04x %04x %08lx %08lx\n", u2, u2a, u4, u4a); +} + +#endif /* DEBUG_TYPECONV */ diff -Nurd linux-86.old/ld/writebin.c linux-86/ld/writebin.c --- linux-86.old/ld/writebin.c Sat Dec 21 20:54:55 1996 +++ linux-86/ld/writebin.c Fri Apr 25 20:37:16 1997 @@ -4,8 +4,10 @@ /* Copyright (C) 1994 Bruce Evans */ #ifndef NO_AOUT +#ifndef A_OUT_INCL #define A_OUT_INCL #endif +#endif #include "syshead.h" #include "bindef.h" @@ -43,7 +45,9 @@ # define HEADERLEN (A_MINHDR) # endif # endif -# define FILEHEADERLENGTH (headerless?0:HEADERLEN) +# ifndef FILEHEADERLENGTH +# define FILEHEADERLENGTH (headerless?0:HEADERLEN) +# endif #endif #define DPSEG 2 @@ -119,8 +123,11 @@ FORWARD void writenulls P((bin_off_t count)); /* write binary file */ +#ifndef FUNCNAME +#define FUNCNAME writebin +#endif -PUBLIC void writebin(outfilename, argsepid, argbits32, argstripflag, arguzp) +PUBLIC void FUNCNAME(outfilename, argsepid, argbits32, argstripflag, arguzp) char *outfilename; bool_pt argsepid; bool_pt argbits32; @@ -422,11 +429,11 @@ extsym.n_was_sclass = C_EXT; else extsym.n_was_sclass = C_STAT; - if (!(flags & I_MASK) || + if (!(flags & I_MASK) || ( #ifdef REL_OUTPUT !reloc_output && #endif - flags & C_MASK) + (flags & C_MASK))) switch (flags & (A_MASK | SEGM_MASK)) { case 0: @@ -485,14 +492,17 @@ memsizeof(struct exec, a_syms)); writeout(buf4, memsizeof(struct exec, a_syms)); #ifdef REL_OUTPUT - seekout((unsigned long) offsetof(struct exec, a_trsize)); - u4cn(buf4, (u4_t) ntreloc * RELOC_INFO_SIZE, - memsizeof(struct exec, a_trsize)); - writeout(buf4, memsizeof(struct exec, a_trsize)); - seekout((unsigned long) offsetof(struct exec, a_drsize)); - u4cn(buf4, (u4_t) ndreloc * RELOC_INFO_SIZE, - memsizeof(struct exec, a_drsize)); - writeout(buf4, memsizeof(struct exec, a_drsize)); + if( FILEHEADERLENGTH >= offsetof(struct exec, a_trsize)+8) + { + seekout((unsigned long) offsetof(struct exec, a_trsize)); + u4cn(buf4, (u4_t) ntreloc * RELOC_INFO_SIZE, + memsizeof(struct exec, a_trsize)); + writeout(buf4, memsizeof(struct exec, a_trsize)); + seekout((unsigned long) offsetof(struct exec, a_drsize)); + u4cn(buf4, (u4_t) ndreloc * RELOC_INFO_SIZE, + memsizeof(struct exec, a_drsize)); + writeout(buf4, memsizeof(struct exec, a_drsize)); + } #endif } #endif /* MINIX */ diff -Nurd linux-86.old/ld/writerel.c linux-86/ld/writerel.c --- linux-86.old/ld/writerel.c Thu Jan 1 01:00:00 1970 +++ linux-86/ld/writerel.c Wed Apr 23 22:05:32 1997 @@ -0,0 +1,22 @@ +/* + * This uses a special version of writebin for bug compatibility with + * the old bin86 package. + * + * This _should_ be replaced by a function that writes out a as86 object + * but then it would completely **** up dosemu compiles. + * + * NOTE: A some time I intend to replace this with a routine that generates + * an as86 object file. + */ + +#ifdef BUGCOMPAT +#define A_OUT_INCL "rel_aout.h" +#define BSD_A_OUT 1 +#define FILEHEADERLENGTH 32 +#define ELF_SYMS 0 + +#define FUNCNAME write_rel +#undef NO_AOUT + +#include "writebin.c" +#endif diff -Nurd linux-86.old/ld/x86_aout.h linux-86/ld/x86_aout.h --- linux-86.old/ld/x86_aout.h Fri Dec 20 21:42:14 1996 +++ linux-86/ld/x86_aout.h Fri Apr 25 21:53:36 1997 @@ -8,25 +8,33 @@ #ifndef __AOUT_H #define __AOUT_H +/* If the host isn't an x86 all bets are off, use chars. */ +#if defined(i386) || defined(__BCC__) +typedef long Long; +#define __OUT_OK 1 +#else +typedef char Long[4]; +#endif + struct exec { /* a.out header */ unsigned char a_magic[2]; /* magic number */ unsigned char a_flags; /* flags, see below */ unsigned char a_cpu; /* cpu id */ unsigned char a_hdrlen; /* length of header */ unsigned char a_unused; /* reserved for future use */ - unsigned short a_version; /* version stamp (not used at present) */ - long a_text; /* size of text segement in bytes */ - long a_data; /* size of data segment in bytes */ - long a_bss; /* size of bss segment in bytes */ - long a_entry; /* entry point */ - long a_total; /* total memory allocated */ - long a_syms; /* size of symbol table */ + unsigned char a_version[2]; /* version stamp (not used at present) */ + Long a_text; /* size of text segement in bytes */ + Long a_data; /* size of data segment in bytes */ + Long a_bss; /* size of bss segment in bytes */ + Long a_entry; /* entry point */ + Long a_total; /* total memory allocated */ + Long a_syms; /* size of symbol table */ /* SHORT FORM ENDS HERE */ - long a_trsize; /* text relocation size */ - long a_drsize; /* data relocation size */ - long a_tbase; /* text relocation base */ - long a_dbase; /* data relocation base */ + Long a_trsize; /* text relocation size */ + Long a_drsize; /* data relocation size */ + Long a_tbase; /* text relocation base */ + Long a_dbase; /* data relocation base */ }; #define A_MAGIC0 (unsigned char) 0x01 @@ -34,12 +42,12 @@ #define BADMAG(X) ((X).a_magic[0] != A_MAGIC0 ||(X).a_magic[1] != A_MAGIC1) /* CPU Id of TARGET machine (byte order coded in low order two bits) */ -#define A_NONE 0x00 /* unknown */ -#define A_I8086 0x04 /* intel i8086/8088 */ -#define A_M68K 0x0B /* motorola m68000 */ -#define A_NS16K 0x0C /* national semiconductor 16032 */ +#define A_NONE 0x00 /* unknown */ +#define A_I8086 0x04 /* intel i8086/8088 */ +#define A_M68K 0x0B /* motorola m68000 */ +#define A_NS16K 0x0C /* national semiconductor 16032 */ #define A_I80386 0x10 /* intel i80386 */ -#define A_SPARC 0x17 /* Sun SPARC */ +#define A_SPARC 0x17 /* Sun SPARC */ #define A_BLR(cputype) ((cputype&0x01)!=0) /* TRUE if bytes left-to-right */ #define A_WLR(cputype) ((cputype&0x02)!=0) /* TRUE if words left-to-right */ @@ -56,15 +64,17 @@ /* Offsets of various things. */ #define A_MINHDR 32 #define A_TEXTPOS(X) ((long)(X).a_hdrlen) -#define A_DATAPOS(X) (A_TEXTPOS(X) + (X).a_text) #define A_HASRELS(X) ((X).a_hdrlen > (unsigned char) A_MINHDR) #define A_HASEXT(X) ((X).a_hdrlen > (unsigned char) (A_MINHDR + 8)) #define A_HASLNS(X) ((X).a_hdrlen > (unsigned char) (A_MINHDR + 16)) #define A_HASTOFF(X) ((X).a_hdrlen > (unsigned char) (A_MINHDR + 24)) +#ifdef __OUT_OK +#define A_DATAPOS(X) (A_TEXTPOS(X) + (X).a_text) #define A_TRELPOS(X) (A_DATAPOS(X) + (X).a_data) #define A_DRELPOS(X) (A_TRELPOS(X) + (X).a_trsize) #define A_SYMPOS(X) (A_TRELPOS(X) + (A_HASRELS(X) ? \ ((X).a_trsize + (X).a_drsize) : 0)) +#endif struct reloc { long r_vaddr; /* virtual address of reference */ diff -Nurd linux-86.old/libc/Config_sh linux-86/libc/Config_sh --- linux-86.old/libc/Config_sh Sun Oct 6 22:03:46 1996 +++ linux-86/libc/Config_sh Sat Apr 19 20:29:58 1997 @@ -30,7 +30,7 @@ CHANGED=0 RUNNING=1 - [ "$DIST" != "" ] && { + [ "$DIST" != "" -o ! -t 1 -o ! -t 0 ] && { RUNNING=0 echo 'Using default configuration' } diff -Nurd linux-86.old/libc/Makefile linux-86/libc/Makefile --- linux-86.old/libc/Makefile Fri Feb 21 22:43:27 1997 +++ linux-86/libc/Makefile Fri May 9 18:33:51 1997 @@ -10,8 +10,8 @@ endif VERMAJOR=0 -VERMINOR=0 -VERPATCH=11 +VERMINOR=12 +VERPATCH=0 VER=$(VERMAJOR).$(VERMINOR).$(VERPATCH) CC=bcc diff -Nurd linux-86.old/libc/bcc/Makefile linux-86/libc/bcc/Makefile --- linux-86.old/libc/bcc/Makefile Sat Feb 1 11:37:48 1997 +++ linux-86/libc/bcc/Makefile Sat Mar 8 20:07:58 1997 @@ -50,34 +50,29 @@ ifneq ($(OBJ),) all: $(LIBC) - @: + @$(RM) $(OBJ) $(LIBC): $(LIBC)($(OBJ)) $(LIBC)($(IOBJ)): $(ISRC) $(CC) $(CFLAGS) -DL_$* $< -c -o $*.o $(AR) $(ARFLAGS) $@ $*.o - $(RM) $*.o $(LIBC)($(LOBJ)): $(LSRC) $(CC) $(CFLAGS) -DL_$* $< -c -o $*.o $(AR) $(ARFLAGS) $@ $*.o - $(RM) $*.o $(LIBC)($(AOBJ)): $(ASRC) $(CC) $(CFLAGS) -DL_$* $< -c -o $*.o $(AR) $(ARFLAGS) $@ $*.o - $(RM) $*.o $(LIBC)($(ROBJ)): $(RSRC) $(CC) $(CFLAGS) -DL_$* $< -c -o $*.o $(AR) $(ARFLAGS) $@ $*.o - $(RM) $*.o $(LIBC)($(POBJ)): $(PSRC) $(CC) $(CFLAGS) -DL_$* $< -c -o $*.o $(AR) $(ARFLAGS) $@ $*.o - $(RM) $*.o else all: @: diff -Nurd linux-86.old/libc/bios/Makefile linux-86/libc/bios/Makefile --- linux-86.old/libc/bios/Makefile Sun Jan 5 16:49:55 1997 +++ linux-86/libc/bios/Makefile Sat Mar 8 20:10:38 1997 @@ -15,17 +15,15 @@ CFLAGS=$(ARCH) $(CCFLAGS) $(DEFS) all: $(LIBC)($(OBJ)) - @: + @$(RM) $(OBJ) $(LIBC)($(AOBJ)): $(ASRC) $(CC) $(CFLAGS) -DL_$* $< -c -o $*.o $(AR) $(ARFLAGS) $@ $*.o - $(RM) $*.o $(LIBC)($(BOBJ)): $(BSRC) $(CC) $(CFLAGS) -DL_$* $< -c -o $*.o $(AR) $(ARFLAGS) $@ $*.o - $(RM) $*.o else all: @: diff -Nurd linux-86.old/libc/error/Makefile linux-86/libc/error/Makefile --- linux-86.old/libc/error/Makefile Sun Dec 15 10:32:51 1996 +++ linux-86/libc/error/Makefile Sat Mar 8 20:11:03 1997 @@ -8,7 +8,7 @@ OBJ=error.o sys_errlist.o perror.o sys_siglist.o __assert.o all: $(LIBC)($(OBJ)) - @: + @$(RM) $(OBJ) else all: @: diff -Nurd linux-86.old/libc/getent/Makefile linux-86/libc/getent/Makefile --- linux-86.old/libc/getent/Makefile Sat Feb 1 17:33:44 1997 +++ linux-86/libc/getent/Makefile Sat Mar 8 20:11:26 1997 @@ -22,7 +22,7 @@ OBJ=$(POBJ) $(GOBJ) $(UOBJ) all: $(LIBC)($(OBJ)) - @: + @$(RM) $(OBJ) $(LIBC)($(GOBJ)): config-grp.h diff -Nurd linux-86.old/libc/gtermcap/Makefile linux-86/libc/gtermcap/Makefile --- linux-86.old/libc/gtermcap/Makefile Sun Dec 15 10:32:59 1996 +++ linux-86/libc/gtermcap/Makefile Sat Mar 8 20:11:41 1997 @@ -8,7 +8,7 @@ OBJ=termcap.o tparam.o all: $(LIBC)($(OBJ)) - @: + @$(RM) $(OBJ) else all: @: diff -Nurd linux-86.old/libc/i386fp/Makefile linux-86/libc/i386fp/Makefile --- linux-86.old/libc/i386fp/Makefile Sun Dec 15 10:33:05 1996 +++ linux-86/libc/i386fp/Makefile Sat Mar 8 20:12:40 1997 @@ -24,7 +24,7 @@ ifeq ($(LIB_CPU),i386) all: $(LIBC)($(FPOBJ)) - rm -f $(JUNK) + rm -f $(JUNK) $(FPOBJ) else all: @: diff -Nurd linux-86.old/libc/i386sys/Makefile linux-86/libc/i386sys/Makefile --- linux-86.old/libc/i386sys/Makefile Thu Jan 30 19:39:59 1997 +++ linux-86/libc/i386sys/Makefile Sat Mar 8 20:13:27 1997 @@ -19,7 +19,7 @@ CFLAGS=$(ARCH) $(CCFLAGS) $(DEFS) all: $(SYSCALLS) $(LIBC)($(OBJ)) - @: + @$(RM) $(OBJ) syscalls: syscall.mak $(MAKE) -f syscall.mak LIBC="$(LIBC)" CFLAGS="$(CFLAGS)" @@ -30,17 +30,14 @@ $(LIBC)($(LOBJ)): $(LSRC) $(CC) $(CFLAGS) -DL_$* $< -c -o $*.o $(AR) $(ARFLAGS) $@ $*.o - $(RM) $*.o $(LIBC)($(DOBJ)): $(DSRC) $(CC) $(CFLAGS) -DL_$* $< -c -o $*.o $(AR) $(ARFLAGS) $@ $*.o - $(RM) $*.o $(LIBC)($(EOBJ)): $(ESRC) $(CC) $(CFLAGS) -DL_$* $< -c -o $*.o $(AR) $(ARFLAGS) $@ $*.o - $(RM) $*.o else all: @: diff -Nurd linux-86.old/libc/i386sys/mksyscall linux-86/libc/i386sys/mksyscall --- linux-86.old/libc/i386sys/mksyscall Thu Jan 30 19:23:48 1997 +++ linux-86/libc/i386sys/mksyscall Sat Mar 8 20:20:37 1997 @@ -132,12 +132,11 @@ CFLAGS=$(ARCH) $(CCFLAGS) $(DEFS) all: $(LIBC)($(OBJ)) - @: + @$(RM) $(OBJ) $(LIBC)($(OBJ)): syscall.dat $(CC) $(CFLAGS) -DL_$* syscall.c -c -o $*.o $(AR) $(ARFLAGS) $@ $*.o - $(RM) $*.o ! exit $? diff -Nurd linux-86.old/libc/malloc1/Makefile linux-86/libc/malloc1/Makefile --- linux-86.old/libc/malloc1/Makefile Sun Dec 15 10:33:14 1996 +++ linux-86/libc/malloc1/Makefile Sat Mar 8 20:13:52 1997 @@ -8,12 +8,11 @@ CFLAGS=$(ARCH) $(CCFLAGS) $(DEFS) all: $(LIBC)($(AOBJ)) - @: + @$(RM) $(OBJ) $(LIBC)($(AOBJ)): $(ASRC) $(CC) $(CFLAGS) -DL_$* $< -c -o $*.o $(AR) $(ARFLAGS) $@ $*.o - $(RM) $*.o clean: rm -f *.o libc.a diff -Nurd linux-86.old/libc/malloc2/Makefile linux-86/libc/malloc2/Makefile --- linux-86.old/libc/malloc2/Makefile Sun Dec 15 11:39:29 1996 +++ linux-86/libc/malloc2/Makefile Sat Mar 8 20:14:11 1997 @@ -4,7 +4,8 @@ CFLAGS=$(ARCH) $(CCFLAGS) $(DEFS) all: $(LIBC)($(OBJ)) - @: + @$(RM) $(OBJ) + clean: rm -f *.o libc.a diff -Nurd linux-86.old/libc/misc/Makefile linux-86/libc/misc/Makefile --- linux-86.old/libc/misc/Makefile Sun Dec 15 10:33:18 1996 +++ linux-86/libc/misc/Makefile Sat Mar 8 20:14:34 1997 @@ -29,19 +29,17 @@ CFLAGS=$(ARCH) $(CCFLAGS) $(DEFS) all: $(LIBC) - @: + @$(RM) $(OBJ) $(LIBC): $(LIBC)($(OBJ)) $(LIBC)($(MOBJ)): $(MSRC) $(CC) $(CFLAGS) -DL_$* $< -c -o $*.o $(AR) $(ARFLAGS) $@ $*.o - $(RM) $*.o $(LIBC)($(EOBJ)): $(ESRC) $(CC) $(CFLAGS) -DL_$* $< -c -o $*.o $(AR) $(ARFLAGS) $@ $*.o - $(RM) $*.o clean: rm -f *.o libc.a @@ -49,14 +47,11 @@ $(LIBC)(strtol.o): strtol.c $(CC) -c -ansi $(ARCH) $(CCFLAGS) $(DEFS) $*.c $(AR) $(ARFLAGS) $@ $*.o - $(RM) $*.o $(LIBC)(strtod.o): strtod.c $(CC) -c -ansi $(ARCH) $(CCFLAGS) $(DEFS) $*.c $(AR) $(ARFLAGS) $@ $*.o - $(RM) $*.o $(LIBC)(crypt.o): crypt.c $(CC) -c -ansi $(ARCH) $(CCFLAGS) $(DEFS) $*.c $(AR) $(ARFLAGS) $@ $*.o - $(RM) $*.o diff -Nurd linux-86.old/libc/msdos/Makefile linux-86/libc/msdos/Makefile --- linux-86.old/libc/msdos/Makefile Thu Jan 2 22:52:42 1997 +++ linux-86/libc/msdos/Makefile Sat Mar 8 20:14:54 1997 @@ -22,19 +22,17 @@ CFLAGS=$(ARCH) $(CCFLAGS) $(DEFS) all: $(LIBC) - @: + @$(RM) $(OBJ) $(LIBC): $(LIBC)($(OBJ)) $(LIBC)($(AOBJ)): $(ASRC) $(CC) $(CFLAGS) -DL_$* $< -c -o $*.o $(AR) $(ARFLAGS) $@ $*.o - $(RM) $*.o $(LIBC)($(BOBJ)): $(BSRC) $(CC) $(CFLAGS) -DL_$* $< -c -o $*.o $(AR) $(ARFLAGS) $@ $*.o - $(RM) $*.o else all: @: diff -Nurd linux-86.old/libc/regexp/Makefile linux-86/libc/regexp/Makefile --- linux-86.old/libc/regexp/Makefile Sun Dec 15 10:33:28 1996 +++ linux-86/libc/regexp/Makefile Sat Mar 8 20:15:26 1997 @@ -5,7 +5,7 @@ CFLAGS=$(ARCH) $(CCFLAGS) $(DEFS) all: $(LIBC) - @: + @$(RM) $(OBJ) $(LIBC): $(LIBC)($(OBJ)) @@ -16,12 +16,10 @@ $(LIBC)(regexp.o): regexp.c regexp.h regmagic.h $(CC) $(CFLAGS) -DL_$* $< -c -o $*.o $(AR) $(ARFLAGS) $@ $*.o - $(RM) $*.o $(LIBC)(regsub.o): regsub.c regexp.h regmagic.h $(CC) $(CFLAGS) -DL_$* $< -c -o $*.o $(AR) $(ARFLAGS) $@ $*.o - $(RM) $*.o clean: rm -f libc.a *.o core mon.out timer.t.h dMakefile dtr try timer diff -Nurd linux-86.old/libc/stdio2/Makefile linux-86/libc/stdio2/Makefile --- linux-86.old/libc/stdio2/Makefile Sun Dec 15 10:33:31 1996 +++ linux-86/libc/stdio2/Makefile Sat Mar 8 20:15:46 1997 @@ -22,24 +22,21 @@ CFLAGS=$(ARCH) $(CCFLAGS) $(DEFS) all: $(LIBC) - @: + @$(RM) $(OBJ) $(LIBC): $(LIBC)($(OBJ)) $(LIBC)($(AOBJ)): $(ASRC) $(CC) $(CFLAGS) -DL_$* $< -c -o $*.o $(AR) $(ARFLAGS) $@ $*.o - $(RM) $*.o $(LIBC)($(POBJ)): $(PSRC) $(CC) $(CFLAGS) -DL_$* $< -c -o $*.o $(AR) $(ARFLAGS) $@ $*.o - $(RM) $*.o $(LIBC)($(SOBJ)): $(SSRC) $(CC) $(CFLAGS) -DL_$* $< -c -o $*.o $(AR) $(ARFLAGS) $@ $*.o - $(RM) $*.o transfer: -@rm -f ../include/stdio.h diff -Nurd linux-86.old/libc/stdio2/stdio.c linux-86/libc/stdio2/stdio.c --- linux-86.old/libc/stdio2/stdio.c Sun Dec 15 10:24:37 1996 +++ linux-86/libc/stdio2/stdio.c Mon Mar 31 20:13:53 1997 @@ -207,7 +207,8 @@ fflush(fp) FILE *fp; { - int len, cc; + int len, cc, rv=0; + char * bstart; if (fp == NULL) /* On NULL flush the lot. */ { if (fflush(stdin)) @@ -231,24 +232,29 @@ if (len) { + bstart = fp->bufstart; /* - * The loop is so we don't get upset by signals + * The loop is so we don't get upset by signals or partial writes. */ do { - cc = write(fp->fd, fp->bufstart, len); + cc = write(fp->fd, bstart, len); + if( cc > 0 ) + { + bstart+=cc; len-=cc; + } } - while (cc == -1 && errno == EINTR); + while ( cc>0 || (cc == -1 && errno == EINTR)); /* - * I think the following test is _too_ stringent, but it's not - * serious If it is found to be a problem then if cc>0 we can do - * a memcpy to put the buffer in a state for a retry. Or even do - * the retry ourselves. + * If we get here with len!=0 there was an error, exactly what to + * do about it is another matter ... + * + * I'll just clear the buffer. */ - if (cc != len) + if (len) { fp->mode |= __MODE_ERR; - return EOF; + rv = EOF; } } } @@ -260,7 +266,7 @@ len = fp->bufread - fp->bufpos; /* Bytes buffered but unread */ /* If it's a file, make it good */ - if (len > 0 && lseek(fp->fd, -len, 1) < 0) + if (len > 0 && lseek(fp->fd, (long)-len, 1) < 0) { /* Hummm - Not certain here, I don't think this is reported */ /* @@ -272,7 +278,7 @@ /* All done, no problem */ fp->mode &= (~(__MODE_READING|__MODE_WRITING|__MODE_EOF|__MODE_UNGOT)); fp->bufread = fp->bufwrite = fp->bufpos = fp->bufstart; - return 0; + return rv; } #endif @@ -475,12 +481,21 @@ else /* Too big for the buffer */ { - put = write(fp->fd, buf, bytes); - if (put < 0) + put = bytes; + do { - fp->mode |= __MODE_ERR; - put = 0; + len = write(fp->fd, buf, bytes); + if( len > 0 ) + { + buf+=len; bytes-=len; + } } + while (len > 0 || (len == -1 && errno == EINTR)); + + if (len < 0) + fp->mode |= __MODE_ERR; + + put -= bytes; } return put / size; @@ -504,8 +519,6 @@ long offset; int ref; { - /* Use fflush to sync the pointers */ - #if 1 /* if __MODE_READING and no ungetc ever done can just move pointer */ /* This needs testing! */ @@ -531,6 +544,8 @@ } } #endif + + /* Use fflush to sync the pointers */ if (fflush(fp) == EOF) return EOF; diff -Nurd linux-86.old/libc/string/Makefile linux-86/libc/string/Makefile --- linux-86.old/libc/string/Makefile Sun Dec 15 10:33:34 1996 +++ linux-86/libc/string/Makefile Sat Mar 8 20:16:09 1997 @@ -13,14 +13,13 @@ CFLAGS=$(ARCH) $(CCFLAGS) $(DEFS) all: $(LIBC) - @: + @$(RM) $(OBJ) $(LIBC): $(LIBC)($(OBJ)) $(LIBC)($(SOBJ)): $(SSRC) $(CC) $(CFLAGS) -DL_$* $< -c -o $*.o $(AR) $(ARFLAGS) $@ $*.o - $(RM) $*.o transfer: -@rm -f ../include/string.h diff -Nurd linux-86.old/libc/syscall/Makefile linux-86/libc/syscall/Makefile --- linux-86.old/libc/syscall/Makefile Thu Jan 30 19:43:25 1997 +++ linux-86/libc/syscall/Makefile Sat Mar 8 20:16:33 1997 @@ -28,7 +28,7 @@ CFLAGS=$(ARCH) $(CCFLAGS) $(DEFS) all: $(SYSCALLS) $(LIBC) - @: + @$(RM) $(OBJ) call_i86: syscall.mak $(MAKE) -f syscall.mak LIBC="$(LIBC)" CFLAGS="$(CFLAGS)" @@ -41,22 +41,18 @@ $(LIBC)($(LOBJ)): $(LSRC) $(CC) $(CFLAGS) -DL_$* $< -c -o $*.o $(AR) $(ARFLAGS) $@ $*.o - $(RM) $*.o $(LIBC)($(DOBJ)): $(DSRC) $(CC) $(CFLAGS) -DL_$* $< -c -o $*.o $(AR) $(ARFLAGS) $@ $*.o - $(RM) $*.o $(LIBC)($(EOBJ)): $(ESRC) $(CC) $(CFLAGS) -DL_$* $< -c -o $*.o $(AR) $(ARFLAGS) $@ $*.o - $(RM) $*.o $(LIBC)($(LOBJ0)): $(LSRC0) $(CC) $(CFLAGS) -DL_$* $< -c -o $*.o $(AR) $(ARFLAGS) $@ $*.o - $(RM) $*.o clean: rm -f *.o libc.a diff -Nurd linux-86.old/libc/syscall/mksyscall linux-86/libc/syscall/mksyscall --- linux-86.old/libc/syscall/mksyscall Sun Dec 15 10:49:05 1996 +++ linux-86/libc/syscall/mksyscall Sat Mar 8 20:20:01 1997 @@ -278,12 +278,11 @@ cat >> syscall.mak <<\! all: $(LIBC)($(OBJ)) - @: + @$(RM) $(OBJ) $(LIBC)($(OBJ)): syscall.dat $(CC) $(CFLAGS) -DL_$* syscall.c -c -o $*.o $(AR) $(ARFLAGS) $@ $*.o - $(RM) $*.o ! exit $? diff -Nurd linux-86.old/libc/termios/Makefile linux-86/libc/termios/Makefile --- linux-86.old/libc/termios/Makefile Sun Dec 15 10:33:46 1996 +++ linux-86/libc/termios/Makefile Sat Mar 8 20:16:50 1997 @@ -13,14 +13,13 @@ CFLAGS=$(ARCH) $(CCFLAGS) $(DEFS) all: $(LIBC) - @: + @$(RM) $(OBJ) $(LIBC): $(LIBC)($(OBJ)) $(LIBC)($(TOBJ)): $(TSRC) $(CC) $(CFLAGS) -DL_$* $< -c -o $*.o $(AR) $(ARFLAGS) $@ $*.o - $(RM) $*.o else all: @: diff -Nurd linux-86.old/libc/time/Makefile linux-86/libc/time/Makefile --- linux-86.old/libc/time/Makefile Sun Dec 15 10:33:49 1996 +++ linux-86/libc/time/Makefile Sat Mar 8 20:17:02 1997 @@ -7,7 +7,7 @@ CFLAGS=$(ARCH) $(CCFLAGS) $(DEFS) all: $(LIBC) - @: + @$(RM) $(OBJ) $(LIBC): $(LIBC)($(OBJ)) diff -Nurd linux-86.old/makefile.in linux-86/makefile.in --- linux-86.old/makefile.in Fri Feb 21 19:56:40 1997 +++ linux-86/makefile.in Thu Apr 24 23:13:56 1997 @@ -21,24 +21,34 @@ MAKEX= #ifdef __GNUC__ +# unproto is yukky, I've included '-w' in the local makefile. + WALL =-Wtraditional -Wshadow -Wid-clash-14 -Wpointer-arith \ -Wcast-qual -Wcast-align -Wconversion -Waggregate-return \ -Wstrict-prototypes -Wmissing-prototypes -Wredundant-decls \ -Wnested-externs -Winline -# unproto is yukky, I've included '-w' in the local makefile. WALL =-Wstrict-prototypes CC =gcc $(GCCFLAG) +#ifdef __i386__ +CFLAGS =-Wall $(WALL) -O2 -m486 -fno-strength-reduce +#else CFLAGS =-Wall $(WALL) -O2 -fno-strength-reduce +#endf LDFLAGS =-s #endif +#ifndef GNUMAKE +MAKEC=sh makec +MAKEX=makec +#endif + #ifdef __minix # Minix make doesn't understand -C, cc runs out of memory with the headers. MAKEC=ash makec MAKEX=makec -CFLAGS=-O -m -w -DPOSIX_HEADERS_MISSING +CFLAGS=-O -m -w -DPOSIX_HEADERS_MISSING -DVERY_SMALL_MEMORY #endif #ifdef __BCC__ @@ -106,12 +116,12 @@ as86: bindir $(MAKEC) as $(MAKEARG) all - cp -p as/as86 lib/as86 + cp -p as/as86 bin/as86 cp -p as/as86_encap bin/as86_encap ld86: bindir $(MAKEC) ld $(MAKEARG) ld86 - cp -p ld/ld86 lib/ld86 + cp -p ld/ld86 bin/ld86 elksemu: bindir $(MAKEC) elksemu $(MAKEARG) elksemu @@ -120,13 +130,15 @@ install-bcc: bcc unproto copt as86 ld86 install -d $(DISTBIN) $(DISTLIB) $(DISTLIB)/i86 install $(INEXE) bin/bcc $(DISTBIN)/bcc + install $(INEXE) bin/as86_encap $(DISTBIN)/as86_encap + install $(INEXE) bin/as86 $(DISTBIN)/as86 + install $(INEXE) bin/ld86 $(DISTBIN)/ld86 install $(INEXE) lib/bcc-cc1 $(DISTLIB)/bcc-cc1 install $(INEXE) lib/unproto $(DISTLIB)/unproto - install $(INEXE) lib/as86 $(DISTLIB)/as86 - install $(INEXE) bin/as86_encap $(DISTBIN)/as86_encap - install $(INEXE) lib/ld86 $(DISTLIB)/ld86 install $(INEXE) lib/copt $(DISTLIB)/copt install $(INDAT) lib/rules.* $(DISTLIB)/i86 + @test ! -f $(DISTLIB)/as86 || rm -f $(DISTLIB)/as86 + @test ! -f $(DISTLIB)/ld86 || rm -f $(DISTLIB)/ld86 install-emu: elksemu install -d $(DIST)/lib @@ -191,12 +203,20 @@ ############################################################################## -check_config: +#ifdef GNUMAKE + +check_config: $(MAKEX) $(MAKEC) libc .config.dir -config: +config: $(MAKEX) $(MAKEC) libc config +#else +check_config: $(MAKEX) ; + +config: ; +#endif + makec: echo 'cd $$1 ; shift ; make "$$@"' > makec chmod +x makec @@ -222,5 +242,6 @@ -@for i in $(CLEANLIST) ; do $(MAKEC) $$i $@ ; true ; done rm -rf bin lib rm -f include + rm -f makec ############################################################################## diff -Nurd linux-86.old/man/as86.1 linux-86/man/as86.1 --- linux-86.old/man/as86.1 Tue Jan 21 22:01:33 1997 +++ linux-86/man/as86.1 Sun Mar 23 11:35:34 1997 @@ -73,7 +73,9 @@ 486 or 586) .TP .B -a -enable partial compatibility with Minix asld +enable partial compatibility with Minix asld. This swaps the interpretation +of round brackets and square brackets as well as making alterations to the +code generation for 16bit jumps and calls. .TP .B -g only put global symbols in object or symbol file diff -Nurd linux-86.old/man/bcc.1 linux-86/man/bcc.1 --- linux-86.old/man/bcc.1 Wed Feb 19 22:57:07 1997 +++ linux-86/man/bcc.1 Tue Apr 29 06:56:06 1997 @@ -325,14 +325,11 @@ The .B bcc -executable itself is in /usr/bin and the +executable itself, .B as86 and .B ld86 -executables can be placed there also, but be aware that some programs -will require the old operation of the -.B -r -argument to ld86 (eg compiling DOSEMU) +are in /usr/bin. .SH SEE ALSO unprotoize(1), as86(1), ld86(1), elksemu(1) @@ -342,3 +339,8 @@ upsets the assembler. The bcc.c compiler driver source is very untidy. + +The linker, ld86, produces a broken a.out object file if given one input and +the +.B -r +option this is so it is compatible with pre-dev86 versions. diff -Nurd linux-86.old/man/ld86.1 linux-86/man/ld86.1 --- linux-86.old/man/ld86.1 Tue Jan 21 22:02:11 1997 +++ linux-86/man/ld86.1 Tue Apr 29 07:01:36 1997 @@ -83,8 +83,9 @@ strip symbols .TP .B -r -Generate a relocatable object from one source object, note this only works -when creating native (-N) binaries. +Generate a relocatable object from one source object, if the linker is +given the -N option also the output format will be the hosts native format +if possible. .TP .B -t trace modules being looked at on stdout @@ -102,10 +103,12 @@ segments of a size >64k, now only i386 executables may have segments this large. -The output format for the -r option has changed. - .SH BUGS The linker cannot deal with reverse seeks caused by .B org instructions in the object file. Unlike previous versions the current one traps the error rather than trying to fill up the hard disk. + +The linker produces a broken a.out object file if given one input and the +.B -r +option this is so it is compatible with pre-dev86 versions. diff -Nurd linux-86.old/mkcompile linux-86/mkcompile --- linux-86.old/mkcompile Tue Dec 3 23:00:22 1996 +++ linux-86/mkcompile Sun Mar 23 10:52:10 1997 @@ -35,7 +35,7 @@ ARCH=-Ml build bcc bcc-cc1 lib "$HDR_CC1" $SRC_CC1 build as as86 bin "$HDR_AS" $SRC_AS - build ld ld86 lib "$HDR_LD" $SRC_LD + build ld ld86 bin "$HDR_LD" $SRC_LD echo ":exit_now" } diff -Nurd linux-86.old/mkcompile2 linux-86/mkcompile2 --- linux-86.old/mkcompile2 Wed Dec 4 21:57:05 1996 +++ linux-86/mkcompile2 Sun Mar 23 10:52:15 1997 @@ -35,7 +35,7 @@ ARCH=-ml build bcc bcc-cc1 lib "$HDR_CC1" $SRC_CC1 build as as86 bin "$HDR_AS" $SRC_AS - build ld ld86 lib "$HDR_LD" $SRC_LD + build ld ld86 bin "$HDR_LD" $SRC_LD echo ":exit_now" } diff -Nurd linux-86.old/tests/compr.c linux-86/tests/compr.c --- linux-86.old/tests/compr.c Sat Feb 24 09:36:02 1996 +++ linux-86/tests/compr.c Sun Mar 23 12:50:07 1997 @@ -22,8 +22,12 @@ int * itb; int size; -int maxno= 8000; long cnt=0; +#ifdef __GNUC__ +int maxno= 16384; +#else +int maxno= 8000; +#endif long icount = 0; long ocount = 0; diff -Nurd linux-86.old/unproto/unproto.c linux-86/unproto/unproto.c --- linux-86.old/unproto/unproto.c Fri Jan 24 18:47:42 1997 +++ linux-86/unproto/unproto.c Thu Apr 24 20:21:14 1997 @@ -147,7 +147,11 @@ /* Application-specific stuff */ #include "vstring.h" +#ifdef _AIX +#include +#else #include "stdarg.h" +#endif #include "token.h" #include "error.h" #include "symbol.h"