From 99d7f513f28bdfc48454acbedc6265e6e9fbfa89 Mon Sep 17 00:00:00 2001 From: David Given Date: Thu, 9 May 2013 11:20:36 +0100 Subject: [PATCH 1/3] Properly error out if something goes wrong rather than ploughing ahead anyway. --HG-- branch : dtrg-experimental-powerpc --- util/data/new_table | 1 + 1 file changed, 1 insertion(+) 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-.} From b9b808e01a02d875d71b01eefa7fc1c1a18b0c84 Mon Sep 17 00:00:00 2001 From: David Given Date: Thu, 9 May 2013 15:54:23 +0100 Subject: [PATCH 2/3] Apply George Koehler's aelflod fix for generating non-EM_386 binaries. Adjust platforms to use it. Fix some bugs in the linux386 platform. --HG-- branch : dtrg-experimental-powerpc --- plat/linux386/descr | 4 +++- plat/linux386/pmfile | 2 ++ plat/linux68k/descr | 2 +- plat/linuxppc/descr | 2 +- util/amisc/aelflod.c | 29 +++++++++++++++++++++++------ 5 files changed, 30 insertions(+), 9 deletions(-) diff --git a/plat/linux386/descr b/plat/linux386/descr index 6b7b1a0af..9121df924 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 4758a48c2..43cdb95de 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 64f838e61..06005f660 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/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 */ From d89f1728417bdfbcb6e3390ca2774dce8e42657d Mon Sep 17 00:00:00 2001 From: David Given Date: Fri, 10 May 2013 12:04:21 +0100 Subject: [PATCH 3/3] Change fatal() and error() to use varargs. --- util/ncgg/emlookup.c | 1 + util/ncgg/error.c | 38 +++++++++++++++++++++++++++----------- util/ncgg/extern.h | 4 ++++ util/ncgg/hall.c | 1 + util/ncgg/lookup.c | 1 + util/ncgg/main.c | 1 + util/ncgg/strlookup.c | 1 + util/ncgg/var.c | 1 + 8 files changed, 37 insertions(+), 11 deletions(-) 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 ff5260704..561591627 100644 --- a/util/ncgg/extern.h +++ b/util/ncgg/extern.h @@ -40,3 +40,7 @@ extern int use_tes; 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/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/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;