Apply George Koehler's aelflod fix for generating non-EM_386 binaries.
authorDavid Given <dg@cowlark.com>
Thu, 9 May 2013 14:54:23 +0000 (15:54 +0100)
committerDavid Given <dg@cowlark.com>
Thu, 9 May 2013 14:54:23 +0000 (15:54 +0100)
Adjust platforms to use it. Fix some bugs in the linux386 platform.

--HG--
branch : dtrg-experimental-powerpc

plat/linux386/descr
plat/linux386/pmfile
plat/linux68k/descr
plat/linuxppc/descr
util/amisc/aelflod.c

index 6b7b1a0..9121df9 100644 (file)
@@ -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
index 24adc42..b7ce181 100644 (file)
@@ -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,
 }
index 4758a48..43cdb95 100644 (file)
@@ -69,6 +69,6 @@ name cv
        from .out
        to .exe
        program {EM}/bin/aelflod
-       args 4 1 < >
+       args -m4 -b < >
        outfile linux68k.exe
 end
index 64f838e..06005f6 100644 (file)
@@ -76,6 +76,6 @@ name cv
        from .out
        to .exe
        program {EM}/bin/aelflod
-       args 20 1 < >
+       args -m20 -b < >
        outfile linuxppc.exe
 end
index 2370104..d9a2ed6 100644 (file)
@@ -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] <inputfile> <outputfile>\n",
+                               fprintf(stderr, "%s: Syntax: aelflod [-a<number>] [-b] [-h] [-l]\n\t[-m<number>] <inputfile> <outputfile>\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 */