diff --git a/Makefile b/Makefile index b121d3e28..596a7cbca 100644 --- a/Makefile +++ b/Makefile @@ -63,7 +63,7 @@ include plat/pc86/build.mk include plat/cpm/build.mk include plat/linux386/build.mk include plat/linux68k/build.mk -include plat/linuxppc/build.mk +# include plat/linuxppc/build.mk .PHONY: installables installables: $(INSTALLABLES) diff --git a/h/cgg_cg.h b/h/cgg_cg.h index a7802ad33..6cc04b007 100644 --- a/h/cgg_cg.h +++ b/h/cgg_cg.h @@ -39,7 +39,6 @@ #define DO_TOSTACK 23 #define DO_KILLREG 24 #define DO_LABDEF 25 -#define DO_STACKADJUST 26 #ifndef MAXATT #define MAXATT TOKENSIZE @@ -134,7 +133,6 @@ typedef struct exprnode *node_p; #define EX_ISROM 44 #define EX_TOPELTSIZE 45 #define EX_FALLTHROUGH 46 -#define EX_STACKOFFSET 47 typedef struct { /* to stack coercions */ diff --git a/plat/linux386/descr b/plat/linux386/descr index 73fbf1779..ff2b26dfb 100644 --- a/plat/linux386/descr +++ b/plat/linux386/descr @@ -59,7 +59,9 @@ name led (.ocm:{TAIL}={PLATFORMDIR}/liboccam.a) \ (.ocm.b.mod.c.p:{TAIL}={PLATFORMDIR}/libc.a) \ {FLOATS?} \ - (.e:{TAIL}={PLATFORMDIR}/libem.a \ + (.e:{TAIL}={PLATFORMDIR}/liblinux.a \ + {PLATFORMDIR}/libem.a \ + {PLATFORMDIR}/liblinux.a \ {PLATFORMDIR}/libsys.a \ {PLATFORMDIR}/libend.a) linker diff --git a/plat/linux386/pmfile b/plat/linux386/pmfile index 24adc42ef..b7ce18123 100644 --- a/plat/linux386/pmfile +++ b/plat/linux386/pmfile @@ -5,6 +5,7 @@ local d = ROOTDIR.."plat/linux386/" include (d.."libsys/pmfile") +include "plat/linux/liblinux/pmfile" local bootsector = ackfile { file (d.."boot.s"), @@ -41,6 +42,7 @@ platform_linux386 = group { -- Build the PC standalone syscall library. + liblinux, libsys_linux386, bootsector, } diff --git a/plat/linux68k/descr b/plat/linux68k/descr index 1fb157c59..14f973d52 100644 --- a/plat/linux68k/descr +++ b/plat/linux68k/descr @@ -69,6 +69,6 @@ name cv from .out to .exe program {EM}/bin/aelflod - args 4 1 < > + args -m4 -b < > outfile linux68k.exe end diff --git a/plat/linuxppc/descr b/plat/linuxppc/descr index 2e54a5da8..2cfb9ac48 100644 --- a/plat/linuxppc/descr +++ b/plat/linuxppc/descr @@ -76,6 +76,6 @@ name cv from .out to .exe program {EM}/bin/aelflod - args 20 1 < > + args -m20 -b < > outfile linuxppc.exe end diff --git a/pmfile b/pmfile index 14b518a53..2f6d416df 100644 --- a/pmfile +++ b/pmfile @@ -186,7 +186,7 @@ default = group { platform_pc86, platform_linux386, - platform_linuxppc, +-- platform_linuxppc, platform_linux68k, platform_cpm, } diff --git a/util/amisc/aelflod.c b/util/amisc/aelflod.c index 23701048f..d9a2ed6e0 100644 --- a/util/amisc/aelflod.c +++ b/util/amisc/aelflod.c @@ -32,7 +32,8 @@ /* Global settings. */ int bigendian = 0; -int elfmachine; +int elfabi = 3; /* abi = Linux */ +int elfmachine = 3; /* machine = EM_386 */ /* Header and section table of an ack object file. */ @@ -116,7 +117,7 @@ int follows(struct outsect* pa, struct outsect* pb) { /* return 1 if pa follows pb */ - return (pa->os_base == align(pb->os_base+pb->os_size, pa->os_lign)); + return (pa->os_base >= align(pb->os_base+pb->os_size, pa->os_lign)); } /* Writes a byte. */ @@ -276,11 +277,27 @@ int main(int argc, char* argv[]) { switch (argv[1][1]) { + case 'a': + elfabi = atoi(&argv[1][2]); + break; + + case 'b': + bigendian = 1; + break; + case 'h': - fprintf(stderr, "%s: Syntax: aelflod [-h] \n", + fprintf(stderr, "%s: Syntax: aelflod [-a] [-b] [-h] [-l]\n\t[-m] \n", program); exit(0); - + + case 'l': + bigendian = 0; + break; + + case 'm': + elfmachine = atoi(&argv[1][2]); + break; + default: syntaxerror: fatal("syntax error --- try -h for help"); @@ -382,13 +399,13 @@ int main(int argc, char* argv[]) emit8(1); /* class = ELFCLASS32 */ emit8(bigendian ? 2 : 1); /* endianness */ emit8(1); /* ELF version */ - emit8(3); /* ABI = Linux */ + emit8(elfabi); /* ABI */ emit8(0); /* ABI version */ emit8(0); emit16(0); /* padding... */ emit32(0); /* ...to offset 0x10 */ emit16(2); /* type = ET_EXEC */ - emit16(3); /* machine = EM_386 */ + emit16(elfmachine); /* machine */ emit32(1); /* ELF version again */ emit32(outsect[TEXT].os_base); /* entry point */ emit32(ELF_HEADER_SIZE); /* program header offset */ diff --git a/util/data/new_table b/util/data/new_table index 58ce61441..c94958c8c 100755 --- a/util/data/new_table +++ b/util/data/new_table @@ -1,4 +1,5 @@ #!/bin/sh +set -e em_table=$1 h=${2-.} diff --git a/util/ncgg/cgg.y b/util/ncgg/cgg.y index 24948abad..4f9cbb00c 100644 --- a/util/ncgg/cgg.y +++ b/util/ncgg/cgg.y @@ -38,7 +38,7 @@ int Xstackflag=0; /* set in coercions, moves, and tests. %1 means something */ struct varinfo *gen_inst(),*gen_move(),*gen_test(),*gen_preturn(),*gen_tlab(); -struct varinfo *gen_label(), *gen_stackadjust(), *make_erase(); +struct varinfo *gen_label(), *make_erase(); expr_t make_expr(),ident_expr(),subreg_expr(),tokm_expr(),all_expr(); expr_t perc_ident_expr(),sum_expr(),regvar_expr(); @@ -74,9 +74,9 @@ iocc_t iops[20]; %token TOPELTSIZE FALLTHROUGH LABELDEF %token PROC CALL EXAMPLE %token FROM TO -%token TEST MOVE STACK RETURN STACKADJUST +%token TEST MOVE STACK RETURN %token PATTERNS PAT WITH EXACT KILLS USES REUSING GEN YIELDS LEAVING -%token DEFINED SAMESIGN SFIT UFIT ROM LOWW HIGHW ISROM STACKOFFSET +%token DEFINED SAMESIGN SFIT UFIT ROM LOWW HIGHW ISROM %token CMPEQ CMPNE CMPLT CMPGT CMPLE CMPGE OR2 AND2 LSHIFT RSHIFT NOT COMP %token INREG REGVAR REG_ANY REG_FLOAT REG_LOOP REG_POINTER %token ADORNACCESS @@ -635,8 +635,8 @@ coderule maxempatlen=empatlen; } patterns - { /* if (!saferulefound) - error("Previous rule impossible on empty stack"); */ + { if (!saferulefound) + error("Previous rule impossible on empty stack"); outpatterns(); } | PROC IDENT example @@ -849,8 +849,6 @@ gen_instruction { $$ = gen_label($2-1); use_tes++; } | RETURN { $$ = gen_preturn(); } - | STACKADJUST expr - { $$ = gen_stackadjust($2.ex_index); use_noframepointer++; } ; optstar : /* empty */ @@ -1030,8 +1028,6 @@ expr { $$ = make_expr(TYPINT,EX_LOWW,$3-1,0); } | HIGHW '(' emarg ')' { $$ = make_expr(TYPINT,EX_HIGHW,$3-1,0); } - | STACKOFFSET '(' ')' - { $$ = make_expr(TYPINT,EX_STACKOFFSET, 0, 0); } /* Excluded, because it causes a shift-reduce conflict (problems with a tokenset_no followed by an optexpr) | '-' expr %prec UMINUS diff --git a/util/ncgg/coerc.c b/util/ncgg/coerc.c index eb5f6ee7a..893f81be3 100644 --- a/util/ncgg/coerc.c +++ b/util/ncgg/coerc.c @@ -127,15 +127,6 @@ struct varinfo *gen_preturn() { return(vp); } -struct varinfo *gen_stackadjust(int expr) { - register struct varinfo *vp; - - NEW(vp,struct varinfo); - vp->vi_int[0] = INSSTACKADJUST; - vp->vi_int[1] = expr; - return(vp); -} - struct varinfo *gen_tlab(n) { register struct varinfo *vp; diff --git a/util/ncgg/emlookup.c b/util/ncgg/emlookup.c index 6d0d9a3f1..6927f9259 100644 --- a/util/ncgg/emlookup.c +++ b/util/ncgg/emlookup.c @@ -10,6 +10,7 @@ static char rcsid[]= "$Id$"; #include #include "param.h" #include "expr.h" +#include "extern.h" #include #include diff --git a/util/ncgg/error.c b/util/ncgg/error.c index 48cac2c00..5d083d577 100644 --- a/util/ncgg/error.c +++ b/util/ncgg/error.c @@ -8,6 +8,8 @@ static char rcsid[]= "$Id$"; #include #include +#include +#include "extern.h" int nerrors=0; @@ -24,24 +26,38 @@ goodbye() { #endif } -/*VARARGS1*/ -fatal(s,a,b,c,d) char *s; { +void errorv(const char* s, va_list ap) +{ + extern int lineno; + extern char *filename; + + fprintf(stderr, "\"%s\", line %d:", filename, lineno); + vfprintf(stderr, s, ap); + fprintf(stderr, "\n"); + nerrors++; +} + +void fatal(const char* s, ...) +{ + + va_list ap; + + va_start(ap, s); + errorv(s, ap); + va_end(ap); - error(s,a,b,c,d); errorexit(); goodbye(); exit(-1); } -/*VARARGS1*/ -error(s,a,b,c,d) char *s; { - extern int lineno; - extern char *filename; +void error(const char* s, ...) +{ + va_list ap; - fprintf(stderr,"\"%s\", line %d:",filename,lineno); - fprintf(stderr,s,a,b,c,d); - fprintf(stderr,"\n"); - nerrors++; + va_start(ap, s); + errorv(s, ap); + va_end(ap); } #ifndef NDEBUG diff --git a/util/ncgg/extern.h b/util/ncgg/extern.h index 8a9604fa7..561591627 100644 --- a/util/ncgg/extern.h +++ b/util/ncgg/extern.h @@ -37,7 +37,10 @@ extern int regclass; extern int maxtokensize; extern int nprocargs, maxprocargs; extern int use_tes; -extern int use_noframepointer; extern char *mystrcpy(); extern char *myalloc(); + +extern void error(const char* s, ...); +extern void fatal(const char* s, ...); + diff --git a/util/ncgg/hall.c b/util/ncgg/hall.c index b22f03210..f8a5364c7 100644 --- a/util/ncgg/hall.c +++ b/util/ncgg/hall.c @@ -9,6 +9,7 @@ static char rcsid[]= "$Id$"; #include "assert.h" #include "param.h" #include "set.h" +#include "extern.h" #include /* diff --git a/util/ncgg/keywords b/util/ncgg/keywords index 641fd45b9..606f7c839 100644 --- a/util/ncgg/keywords +++ b/util/ncgg/keywords @@ -43,8 +43,6 @@ reusing REUSING rom ROM samesign SAMESIGN sfit SFIT -stackadjust STACKADJUST -stackoffset STACKOFFSET topeltsize TOPELTSIZE test TEST to TO diff --git a/util/ncgg/lookup.c b/util/ncgg/lookup.c index c59610fdd..ab31baebc 100644 --- a/util/ncgg/lookup.c +++ b/util/ncgg/lookup.c @@ -9,6 +9,7 @@ static char rcsid[]= "$Id$"; #include "assert.h" #include "param.h" #include "lookup.h" +#include "extern.h" char *myalloc(); char *mystrcpy(); diff --git a/util/ncgg/main.c b/util/ncgg/main.c index 2c805e7a8..330e08c98 100644 --- a/util/ncgg/main.c +++ b/util/ncgg/main.c @@ -8,6 +8,7 @@ static char rcsid[]= "$Id$"; #include #include +#include "extern.h" char *filename; char *beg_sbrk; diff --git a/util/ncgg/output.c b/util/ncgg/output.c index 2a905c339..50458e369 100644 --- a/util/ncgg/output.c +++ b/util/ncgg/output.c @@ -12,8 +12,6 @@ int tabledebug=0; /* do not generate code for table debugging */ #endif int verbose=0; /* print all statistics */ int use_tes; /* use top element size information */ -int use_noframepointer; /* use stackadjust mechanism to remove requirement - for frame pointer */ char *c_file= "tables.c"; char *h_file= "tables.H"; char *cd_file= "code"; @@ -614,8 +612,6 @@ outdefs() { cdef("TABLEDEBUG",1); if (use_tes) cdef("USE_TES",1); - if (use_noframepointer) - cdef("USE_NOFRAMEPOINTER",1); } outars() { @@ -856,11 +852,6 @@ varinfo *kills,*allocates,*generates,*yields,*leaving; codeint(vp->vi_int[1]); codenl(); break; - case INSSTACKADJUST: - code8(DO_STACKADJUST); - codeint(vp->vi_int[1]); - codenl(); - break; } } codecoco(cocono); diff --git a/util/ncgg/pseudo.h b/util/ncgg/pseudo.h index 91013354a..24b335c50 100644 --- a/util/ncgg/pseudo.h +++ b/util/ncgg/pseudo.h @@ -12,4 +12,3 @@ #define INSERASE (-6) #define INSREMOVE (-7) #define INSLABDEF (-8) -#define INSSTACKADJUST (-9) diff --git a/util/ncgg/strlookup.c b/util/ncgg/strlookup.c index 5d5877abc..d473341aa 100644 --- a/util/ncgg/strlookup.c +++ b/util/ncgg/strlookup.c @@ -7,6 +7,7 @@ static char rcsid[]= "$Id$"; #endif #include "param.h" +#include "extern.h" int nstrings=0; char *l_strings[MAXSTRINGS]; diff --git a/util/ncgg/var.c b/util/ncgg/var.c index 792b78923..72a3f825d 100644 --- a/util/ncgg/var.c +++ b/util/ncgg/var.c @@ -13,6 +13,7 @@ static char rcsid[]= "$Id$"; #include "set.h" #include "instruct.h" #include "lookup.h" +#include "extern.h" #include int wordsize;