build: Use arch-dir.
authorJan Nieuwenhuizen <janneke@gnu.org>
Tue, 29 May 2018 18:07:46 +0000 (20:07 +0200)
committerJan Nieuwenhuizen <janneke@gnu.org>
Tue, 29 May 2018 18:07:46 +0000 (20:07 +0200)
* lib/x86-mes: Move from stage0.
* build-aux/build-cc.sh: Create libraries in lib/gcc.  Update users.
* build-aux/build-mes.sh: Create libraries in lib/x86-mes.  Update users.
* build-aux/build-mes-gcc.sh: Rename from build-mlibc.sh.  Create
  libraries in lib/x86-mes-gcc.  Update callers.
* build-aux/cc-mes-gcc.sh: Rename from cc-mlibc.sh.  Update callers.

46 files changed:
.gitignore
GNUmakefile
build-aux/build-cc.sh
build-aux/build-mes-gcc.sh [new file with mode: 0755]
build-aux/build-mes.sh
build-aux/build-mlibc.sh [deleted file]
build-aux/cc-mes-gcc.sh [new file with mode: 0755]
build-aux/cc-mes.sh
build-aux/cc-mlibc.sh [deleted file]
build-aux/cc.sh
build-aux/check-mescc.sh
build-aux/test.sh
build.sh
check.sh
include/30-test.i
install.sh
lib/libc+tcc-gcc.c
lib/libc+tcc-mes.c
lib/libc+tcc.c
lib/libc-gcc.c [deleted file]
lib/libc-mes.c [deleted file]
lib/libc-mini-gcc.c [deleted file]
lib/libc-mini-mes.c [deleted file]
lib/libc-mini.c
lib/libc.c
lib/libmes.c
lib/x86-mes/elf-0footer.hex2 [new file with mode: 0644]
lib/x86-mes/elf32-0header.hex2 [new file with mode: 0644]
lib/x86-mes/elf32-body-exit-42.hex2 [new file with mode: 0644]
lib/x86-mes/elf32-footer-single-main.hex2 [new file with mode: 0644]
lib/x86-mes/elf32-header.hex2 [new file with mode: 0644]
lib/x86-mes/exit-42.c [new file with mode: 0644]
lib/x86-mes/x86.M1 [new file with mode: 0644]
module/mescc/mescc.scm
scaffold/tests/77-pointer-assign.c
scaffold/tests/7j-strtoull.c
scripts/mescc
src/mes.c
stage0/elf-0footer.hex2 [deleted file]
stage0/elf32-0header.hex2 [deleted file]
stage0/elf32-body-exit-42.hex2 [deleted file]
stage0/elf32-footer-single-main.hex2 [deleted file]
stage0/elf32-header.hex2 [deleted file]
stage0/elf32.hex3 [deleted file]
stage0/exit-42.c [deleted file]
stage0/x86.M1 [deleted file]

index 72179c1366cad0e496c60fe0d7b1a6dd57cb50a0..734586495576fec20f529a8cb5ac2efd6b69fa13 100644 (file)
@@ -1,35 +1,32 @@
 *-
-*.blood-elf-M1
-*.blood-elf-hex2
-*.go
 *~
 .#*
-*.0-M1
-*.0-guile
-*.0-hex2
 *.E
 *.S
-*.o
 *.blood-elf
+*.blood-elf-M1
+*.blood-elf-hex2
 *.gcc
+*.gcc-o
+*.gcc-out
+*.go
 *.guile
 *.log
-*.gcc-o
+*.mes-gcc
+*.mes-gcc-o
+*.mes-gcc-out
+*.mes-gcc-out
+*.mes-gcc-stdout
 *.mes-o
+*.mes-out
 *.mes-stdout
 *.mini-M1
 *.mini-guile
 *.mini-hex2
-*.mlibc-gcc
-*.mlibc-o
-*.mlibc-out
-*.mlibc-stdout
+*.o
+*.seed-out
 *.stderr
 *.stdout
-*.tcc-guile
-!/stage0/*
-!/stage0/*.c
-/stage0/exit-42.*
 
 /src/*.h
 /src/*.i
 /.store
 /.tarball-version
 /ChangeLog
-/a.out
-*.gcc-out
-*.mes-out
-*.mlibc-out
-*.seed-out
 
 #keep this: bootstrap
 #/mes.mes
index 820b27295cc968f673afaa66d8cd662225c16262..506f93b3ce1a4022c94c453a093a970b1eb9f1b7 100644 (file)
@@ -14,8 +14,8 @@ all:
 cc:
        build-aux/build-cc.sh
 
-mlibc:
-       build-aux/build-mlibc.sh
+mes-gcc:
+       build-aux/build-mes-gcc.sh
 
 mes:
        build-aux/build-mes.sh
@@ -43,7 +43,7 @@ seed: all-go
        MES=$(GUILE) GUILE=$(GUILE) SEED=1 build-aux/build-mes.sh
        cd $(MES_SEED) && MES_PREFIX=$(PWD) ./refresh.sh
        MES=$(GUILE) GUILE=$(GUILE) SEED=1 build-aux/build-mes.sh
-       build-aux/build-mlibc.sh
+       build-aux/build-mes-gcc.sh
        cd $(TINYCC_SEED) && MES_PREFIX=$(PWD) ./refresh.sh
 
 define HELP_TOP
@@ -53,7 +53,7 @@ Targets:
   all             update everything
   all-go          update .go files
   cc              update src/mes.gcc-out
-  mlibc           update src/mes.mlibc-out
+  mes-gcc         update src/mes.mes-gcc-out
   mes             update src/mes
   check           run unit tests
   clean           run git clean -dfx
index a6544ebeceac7cb61aa8d02902f8a15f8565af8d..f3e54150cbc3a6d95b98e4529130be9347a40949 100755 (executable)
@@ -50,4 +50,5 @@ build-aux/mes-snarf.scm src/posix.c
 build-aux/mes-snarf.scm src/reader.c
 build-aux/mes-snarf.scm src/vector.c
 
+ARCHDIR=1 NOLINK=1 sh build-aux/cc.sh lib/libmes
 sh build-aux/cc.sh src/mes
diff --git a/build-aux/build-mes-gcc.sh b/build-aux/build-mes-gcc.sh
new file mode 100755 (executable)
index 0000000..71552ae
--- /dev/null
@@ -0,0 +1,78 @@
+#! /bin/sh
+
+# Mes --- Maxwell Equations of Software
+# Copyright © 2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
+#
+# This file is part of Mes.
+#
+# Mes is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or (at
+# your option) any later version.
+#
+# Mes is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Mes.  If not, see <http://www.gnu.org/licenses/>.
+
+set -e
+
+if [ -n "$BUILD_DEBUG" ]; then
+    set -x
+fi
+
+export CC32 CPPFLAGS C32FLAGS
+
+CC32=${CC32-$(command -v i686-unknown-linux-gnu-gcc)}
+build-aux/mes-snarf.scm --mes src/gc.c
+build-aux/mes-snarf.scm --mes src/lib.c
+build-aux/mes-snarf.scm --mes src/math.c
+build-aux/mes-snarf.scm --mes src/mes.c
+build-aux/mes-snarf.scm --mes src/posix.c
+build-aux/mes-snarf.scm --mes src/reader.c
+build-aux/mes-snarf.scm --mes src/vector.c
+
+build-aux/mes-snarf.scm src/gc.c
+build-aux/mes-snarf.scm src/lib.c
+build-aux/mes-snarf.scm src/math.c
+build-aux/mes-snarf.scm src/mes.c
+build-aux/mes-snarf.scm src/posix.c
+build-aux/mes-snarf.scm src/reader.c
+build-aux/mes-snarf.scm src/vector.c
+
+CPPFLAGS=${CPPFLAGS-"
+-D VERSION=\"$VERSION\"
+-D MODULEDIR=\"$MODULEDIR\"
+-D PREFIX=\"$PREFIX\"
+-I src
+-I lib
+-I include
+"}
+
+C32FLAGS=${C32FLAGS-"
+--std=gnu99
+-O0
+-fno-stack-protector
+-g
+-m32
+-nostdinc
+-nostdlib
+"}
+
+ARCHDIR=1 NOLINK=1 sh build-aux/cc-mes-gcc.sh lib/crt1
+ARCHDIR=1 NOLINK=1 sh build-aux/cc-mes-gcc.sh lib/libc-mini
+ARCHDIR=1 NOLINK=1 sh build-aux/cc-mes-gcc.sh lib/libc
+ARCHDIR=1 NOLINK=1 sh build-aux/cc-mes-gcc.sh lib/libc+tcc
+
+sh build-aux/cc-mes-gcc.sh scaffold/main
+sh build-aux/cc-mes-gcc.sh scaffold/hello
+sh build-aux/cc-mes-gcc.sh scaffold/argv
+sh build-aux/cc-mes-gcc.sh scaffold/malloc
+sh build-aux/cc-mes-gcc.sh scaffold/micro-mes
+sh build-aux/cc-mes-gcc.sh scaffold/tiny-mes
+sh build-aux/cc-mes-gcc.sh scaffold/mini-mes
+
+sh build-aux/cc-mes-gcc.sh src/mes
index 5ed839617d1697622931c74b2c911824199e8fa5..7166c0e0b20743cc0b1796754b032d636bec22b6 100755 (executable)
@@ -55,24 +55,24 @@ HEX2FLAGS=${HEX2FLAGS-"
 if [ -d "$MES_SEED" ]; then
     $M1\
         $M1FLAGS\
-        -f stage0/x86.M1\
-        -f $MES_SEED/crt1.M1\
-        -o lib/crt1.o
+        -f lib/x86-mes/x86.M1\
+        -f $MES_SEED/x86-mes/crt1.S\
+        -o lib/x86-mes/crt1.o
     $M1\
         $M1FLAGS\
-        -f stage0/x86.M1\
-        -f $MES_SEED/libc-mes.M1\
-        -o lib/libc-mes.o
+        -f lib/x86-mes/x86.M1\
+        -f $MES_SEED/x86-mes/libc.S\
+        -o lib/x86-mes/libc.o
     $M1\
         --LittleEndian\
         --Architecture=1\
-        -f stage0/x86.M1\
-        -f $MES_SEED/mes.M1\
+        -f lib/x86-mes/x86.M1\
+        -f $MES_SEED/x86-mes/mes.S\
         -o src/mes.o
     $BLOOD_ELF\
-        -f stage0/x86.M1\
-        -f $MES_SEED/mes.M1\
-        -f $MES_SEED/libc-mes.M1\
+        -f lib/x86-mes/x86.M1\
+        -f $MES_SEED/x86-mes/mes.S\
+        -f $MES_SEED/x86-mes/libc.S\
         -o src/mes.S.blood-elf
     $M1\
         --LittleEndian\
@@ -81,9 +81,9 @@ if [ -d "$MES_SEED" ]; then
         -o src/mes.o.blood-elf
     $HEX2\
         $HEX2FLAGS\
-        -f stage0/elf32-header.hex2\
-        -f lib/crt1.o\
-        -f lib/libc-mes.o\
+        -f lib/x86-mes/elf32-header.hex2\
+        -f lib/x86-mes/crt1.o\
+        -f lib/x86-mes/libc.o\
         -f src/mes.o\
         -f src/mes.o.blood-elf\
         --exec_enable\
@@ -91,25 +91,20 @@ if [ -d "$MES_SEED" ]; then
     cp src/mes.seed-out src/mes
     $M1\
         $M1FLAGS\
-        -f stage0/x86.M1\
-        -f $MES_SEED/libc+tcc-mes.M1\
-        -o lib/libc+tcc-mes.o
+        -f lib/x86-mes/x86.M1\
+        -f $MES_SEED/x86-mes/libc+tcc.S\
+        -o lib/x86-mes/libc+tcc.o
 fi
 
 PREPROCESS=1
-NOLINK=1 sh build-aux/cc-mes.sh lib/crt1
-NOLINK=1 sh build-aux/cc-mes.sh lib/libc-mini-mes
-NOLINK=1 sh build-aux/cc-mes.sh lib/libc-mes
-NOLINK=1 sh build-aux/cc-mes.sh lib/libc+tcc-mes
-
-cp lib/crt1.mes-o lib/crt1.o
-cp lib/libc-mini-mes.mes-o lib/libc-mini-mes.o
-cp lib/libc-mes.mes-o lib/libc-mes.o
-cp lib/libc+tcc-mes.mes-o lib/libc+tcc-mes.o
+ARCHDIR=1 NOLINK=1 sh build-aux/cc-mes.sh lib/crt1
+ARCHDIR=1 NOLINK=1 sh build-aux/cc-mes.sh lib/libc-mini
+ARCHDIR=1 NOLINK=1 sh build-aux/cc-mes.sh lib/libc
+ARCHDIR=1 NOLINK=1 sh build-aux/cc-mes.sh lib/libc+tcc
 
 [ -n "$SEED" ] && exit 0
 
-MES_ARENA=${MES_ARENA-30000000}
+MES_ARENA=${MES_ARENA-10000000}
 sh build-aux/mes-snarf.scm --mes src/gc.c
 sh build-aux/mes-snarf.scm --mes src/lib.c
 sh build-aux/mes-snarf.scm --mes src/math.c
diff --git a/build-aux/build-mlibc.sh b/build-aux/build-mlibc.sh
deleted file mode 100755 (executable)
index 5b2a215..0000000
+++ /dev/null
@@ -1,78 +0,0 @@
-#! /bin/sh
-
-# Mes --- Maxwell Equations of Software
-# Copyright © 2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
-#
-# This file is part of Mes.
-#
-# Mes is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3 of the License, or (at
-# your option) any later version.
-#
-# Mes is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Mes.  If not, see <http://www.gnu.org/licenses/>.
-
-set -e
-
-if [ -n "$BUILD_DEBUG" ]; then
-    set -x
-fi
-
-export CC32 CPPFLAGS C32FLAGS
-
-CC32=${CC32-$(command -v i686-unknown-linux-gnu-gcc)}
-build-aux/mes-snarf.scm --mes src/gc.c
-build-aux/mes-snarf.scm --mes src/lib.c
-build-aux/mes-snarf.scm --mes src/math.c
-build-aux/mes-snarf.scm --mes src/mes.c
-build-aux/mes-snarf.scm --mes src/posix.c
-build-aux/mes-snarf.scm --mes src/reader.c
-build-aux/mes-snarf.scm --mes src/vector.c
-
-build-aux/mes-snarf.scm src/gc.c
-build-aux/mes-snarf.scm src/lib.c
-build-aux/mes-snarf.scm src/math.c
-build-aux/mes-snarf.scm src/mes.c
-build-aux/mes-snarf.scm src/posix.c
-build-aux/mes-snarf.scm src/reader.c
-build-aux/mes-snarf.scm src/vector.c
-
-CPPFLAGS=${CPPFLAGS-"
--D VERSION=\"$VERSION\"
--D MODULEDIR=\"$MODULEDIR\"
--D PREFIX=\"$PREFIX\"
--I src
--I lib
--I include
-"}
-
-C32FLAGS=${C32FLAGS-"
---std=gnu99
--O0
--fno-stack-protector
--g
--m32
--nostdinc
--nostdlib
-"}
-
-NOLINK=1 sh build-aux/cc-mlibc.sh lib/crt1
-NOLINK=1 sh build-aux/cc-mlibc.sh lib/libc-mini-gcc
-NOLINK=1 sh build-aux/cc-mlibc.sh lib/libc-gcc
-NOLINK=1 sh build-aux/cc-mlibc.sh lib/libc+tcc-gcc
-
-sh build-aux/cc-mlibc.sh scaffold/main
-sh build-aux/cc-mlibc.sh scaffold/hello
-sh build-aux/cc-mlibc.sh scaffold/argv
-sh build-aux/cc-mlibc.sh scaffold/malloc
-sh build-aux/cc-mlibc.sh scaffold/micro-mes
-sh build-aux/cc-mlibc.sh scaffold/tiny-mes
-sh build-aux/cc-mlibc.sh scaffold/mini-mes
-
-sh build-aux/cc-mlibc.sh src/mes
diff --git a/build-aux/cc-mes-gcc.sh b/build-aux/cc-mes-gcc.sh
new file mode 100755 (executable)
index 0000000..f33dab0
--- /dev/null
@@ -0,0 +1,77 @@
+#! /bin/sh
+
+# Mes --- Maxwell Equations of Software
+# Copyright © 2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
+#
+# This file is part of Mes.
+#
+# Mes is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or (at
+# your option) any later version.
+#
+# Mes is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Mes.  If not, see <http://www.gnu.org/licenses/>.
+
+set -e
+
+if [ -n "$BUILD_DEBUG" ]; then
+    set -x
+fi
+
+CPPFLAGS=${CPPFLAGS-"
+-D VERSION=\"$VERSION\"
+-D MODULEDIR=\"$MODULEDIR\"
+-D PREFIX=\"$PREFIX\"
+-I src
+-I lib
+-I include
+"}
+
+C32FLAGS=${C32FLAGS-"
+--std=gnu99
+-O0
+-fno-builtin
+-fno-stack-protector
+-g
+-m32
+-nostdinc
+-nostdlib
+"}
+LIBC=${LIBC-c}
+if [ -n "$LIBC" ]; then
+    CC32LIBS="lib/x86-mes-gcc/lib$LIBC.o"
+fi
+
+c=$1
+
+if [ -z "$ARCHDIR" ]; then
+    o="$c"
+    p="mes-gcc-"
+else
+    b=${c##*/}
+    d=${c%/*}
+    o="$d/x86-mes-gcc/$b"
+    mkdir -p $d/x86-mes-gcc
+fi
+
+$CC32\
+    -c\
+    $CPPFLAGS\
+    $C32FLAGS\
+    -o "$o".${p}o\
+    "$c".c
+
+if [ -z "$NOLINK" ]; then
+    $CC32\
+        $C32FLAGS\
+        -o "$o".${p}out\
+        lib/x86-mes-gcc/crt1.o\
+        "$o".${p}o\
+        $CC32LIBS
+fi
index d1dad87127da909e820a7ee22b77c05b726d5bdd..f93028582f93af546798c13dbfcc7bc260982558 100755 (executable)
@@ -52,21 +52,31 @@ c=$1
 
 set -e
 
+if [ -z "$ARCHDIR" ]; then
+    o="$c"
+    p="mes-"
+else
+    b=${c##*/}
+    d=${c%/*}
+    o="$d/x86-mes/$b"
+    mkdir -p $d/x86-mes
+fi
+
 if [ -n "$PREPROCESS" ]; then
-    sh $MESCC $MESCCFLAGS $CPPFLAGS -E "$c".c
-    sh $MESCC $MESCCFLAGS -S "$c".E
-    sh $MESCC $MESCCFLAGS -c -o "$c".mes-o "$c".S
+    sh $MESCC $MESCCFLAGS $CPPFLAGS -E -o "$o.E" "$c".c
+    sh $MESCC $MESCCFLAGS -S "$o".E
+    sh $MESCC $MESCCFLAGS -c -o "$o".${p}o "$o".S
     if [ -z "$NOLINK" ]; then
-        sh $MESCC $MESCCFLAGS -o "$c".mes-out "$c".mes-o $MESCCLIBS
+        sh $MESCC $MESCCFLAGS -o "$o".${p}out "$o".${p}o $MESCCLIBS
     fi
 elif [ -n "$COMPILE" ]; then
-    sh $MESCC $MESCCFLAGS $CPPFLAGS -S "$c".c
-    sh $MESCC $MESCCFLAGS -c -o "$c".mes-o "$c".S
+    sh $MESCC $MESCCFLAGS $CPPFLAGS -S -o "$o.S" "$c".c
+    sh $MESCC $MESCCFLAGS -c -o "$o".${p}o "$o".S
     if [ -z "$NOLINK" ]; then
-        sh $MESCC $MESCCFLAGS -o "$c".mes-out "$c".mes-o $MESCCLIBS
+        sh $MESCC $MESCCFLAGS -o "$o".${p}out "$o".${p}o $MESCCLIBS
     fi
 elif [ -z "$NOLINK" ]; then
-    sh $MESCC $MESCCFLAGS $CPPFLAGS -o "$c".mes-out "$c".c $MESCCLIBS
+    sh $MESCC $MESCCFLAGS $CPPFLAGS -o "$o".${p}out "$c".c $MESCCLIBS
 else
-    sh $MESCC $MESCCFLAGS $CPPFLAGS -c -o "$c".mes-out "$c".c
+    sh $MESCC $MESCCFLAGS $CPPFLAGS -c -o "$o".${p}out "$c".c
 fi
diff --git a/build-aux/cc-mlibc.sh b/build-aux/cc-mlibc.sh
deleted file mode 100755 (executable)
index 985db1b..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-#! /bin/sh
-
-# Mes --- Maxwell Equations of Software
-# Copyright © 2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
-#
-# This file is part of Mes.
-#
-# Mes is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3 of the License, or (at
-# your option) any later version.
-#
-# Mes is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Mes.  If not, see <http://www.gnu.org/licenses/>.
-
-set -e
-
-if [ -n "$BUILD_DEBUG" ]; then
-    set -x
-fi
-
-CPPFLAGS=${CPPFLAGS-"
--D VERSION=\"$VERSION\"
--D MODULEDIR=\"$MODULEDIR\"
--D PREFIX=\"$PREFIX\"
--I src
--I lib
--I include
-"}
-
-C32FLAGS=${C32FLAGS-"
---std=gnu99
--O0
--fno-builtin
--fno-stack-protector
--g
--m32
--nostdinc
--nostdlib
-"}
-LIBC=${LIBC-lib/libc}
-
-c=$1
-
-$CC32\
-    -c\
-    $CPPFLAGS\
-    $C32FLAGS\
-    -o "$c".mlibc-o\
-    "$c".c
-
-if [ -z "$NOLINK" ]; then
-    $CC32\
-        $C32FLAGS\
-        -o "$c".mlibc-out\
-        lib/crt1.mlibc-o\
-        "$c".mlibc-o\
-        $LIBC-gcc.mlibc-o\
-        $CC32LIBS
-fi
index b85ed2d5778b33956b13255aa720980caa836104..0b4610d6cff7acc1db888e27a886ff4dcceaf1b7 100755 (executable)
@@ -41,18 +41,28 @@ CFLAGS=${CFLAGS-"
 
 c=$1
 
+if [ -z "$ARCHDIR" ]; then
+    o="$c"
+    p="gcc-"
+else
+    b=${c##*/}
+    d=${c%/*}
+    o="$d/gcc/$b"
+    mkdir -p $d/gcc
+fi
+
 $CC\
     -c\
     $CPPFLAGS\
     $CFLAGS\
     -D POSIX=1\
-    -o "$c".gcc-o\
+    -o "$o".${p}o\
     "$c".c
 
 if [ -z "$NOLINK" ]; then
     $CC\
         $CFLAGS\
-        -o "$c".gcc-out\
-        "$c".gcc-o\
-        lib/libc-gcc.gcc-o
+        -o "$o".${p}out\
+        "$o".${p}o\
+        lib/gcc/libmes.o
 fi
index 4546cda0889fea13891649dcc29be8119c78f551..ea4002ed8b8851d2ad259fa6fff17607dfc62135 100755 (executable)
@@ -26,7 +26,7 @@ export BLOOD_ELF GUILE HEX2 M1 MES MESCC
 export M1FLAGS HEX2FLAGS PREPROCESS
 export MES_ARENA MES_PREFIX MES_SEED
 export BUILD_DEBUG
-export CC32LIBS MESCCLIBS
+export LIBC CC32LIBS MESCCLIBS
 
 MES=${MES-src/mes}
 MESCC=${MESCC-scripts/mescc}
@@ -144,17 +144,15 @@ expect=$(echo $broken | wc -w)
 pass=0
 fail=0
 total=0
-MESCCLIBS=
-LIBC=libc/libc
 for t in $tests; do
     if [ -z "${t/[012][0-9]-*/}" ]; then
-        LIBC="lib/libc-mini"
+        LIBC=c-mini
         MESCCLIBS="-l c-mini"
     elif [ -z "${t/8[0-9]-*/}" ]; then
-        LIBC="lib/libc+tcc"
+        LIBC=c+tcc
         MESCCLIBS="-l c+tcc"
     else
-        LIBC=libc/libc
+        LIBC=c
         MESCCLIBS=
     fi
     sh build-aux/test.sh "scaffold/tests/$t" &> scaffold/tests/"$t".log
@@ -251,6 +249,7 @@ broken="$broken
 42_function_pointer
 46_grep
 49_bracket_evaluation
+55_lshift_type
 "
 
 #22_floating_point       ; float
index d8ae6e7a5ed2d1ffba744c58f5bb09cca46907a2..33f5919ead32b9bfa8ad97115c250623fc220ffe 100755 (executable)
@@ -34,21 +34,21 @@ shift
 
 set -e
 
-rm -f "$t".mlibc-out
+rm -f "$t".mes-gcc-out
 if [ -n "$CC32" ]; then
-    sh build-aux/cc-mlibc.sh "$t"
+    sh build-aux/cc-mes-gcc.sh "$t"
 
     r=0
     [ -f "$t".exit ] && r=$(cat "$t".exit)
     set +e
-    "$t".mlibc-out > "$t".mlibc-stdout
+    "$t".mes-gcc-out > "$t".mes-gcc-stdout
     m=$?
-    cat "$t".mlibc-stdout
+    cat "$t".mes-gcc-stdout
     set -e
 
     [ $m = $r ]
     if [ -f "$t".expect ]; then
-        $DIFF -ub "$t".expect "$t".mlibc-stdout;
+        $DIFF -ub "$t".expect "$t".mes-gcc-stdout;
     fi
 fi
 
index f5f89d01be4462319a172ab9207d7e84e7916fad..79ad02d9ccff9ddbfbb8b11a861aeeb86c57afa6 100755 (executable)
--- a/build.sh
+++ b/build.sh
@@ -34,7 +34,7 @@ CC32=${CC32-$(command -v i686-unknown-linux-gnu-gcc)}
 MESCC=${MESCC-$(command -v mescc)}
 MES_SEED=${MES_SEED-../mes-seed}
 GUILE=${GUILE-$(command -v guile)}
-MES_ARENA=${MES_ARENA-300000000}
+MES_ARENA=${MES_ARENA-100000000}
 MES_DEBUG=${MES_DEBUG-1}
 
 PREFIX=${PREFIX-/usr/local}
@@ -86,8 +86,8 @@ if [ -n "$CC" ]; then
 fi
 
 if [ -n "$CC32" ]; then
-    sh build-aux/build-mlibc.sh
-    cp src/mes.mlibc-out src/mes
+    sh build-aux/build-mes-gcc.sh
+    cp src/mes.mes-gcc-out src/mes
 fi
 
 sh build-aux/build-mes.sh
index ce659332295d5bbd8afecef5e39d2ebe70fb2a12..6b721a8aa3b856953415aabdcd5b4c9ff743e52a 100755 (executable)
--- a/check.sh
+++ b/check.sh
@@ -25,7 +25,7 @@ export BUILD_DEBUG
 CC32=${CC32-$(command -v i686-unknown-linux-gnu-gcc)}
 GUILE=${GUILE-guile}
 MES=${MES-src/mes}
-MES_ARENA=${MES_ARENA-300000000}
+MES_ARENA=${MES_ARENA-100000000}
 PREFIX=
 
 if ! command -v $GUILE > /dev/null; then
index 2f638f19fea6294c3b6552bd652cbc41d402a0a4..a9fbdb81bd1ea0e56b7f615c07b35aac9311fa08 100644 (file)
@@ -18,6 +18,8 @@
  * along with Mes.  If not, see <http://www.gnu.org/licenses/>.
  */
 
+#include <libmes.h>
+
 int test ();
 
 int
index f8b24e183d65e252a456ba52db56bf9f5a7b9fd6..6304adb5d74475fef9357b2700aa3ebe41168227 100755 (executable)
@@ -17,7 +17,7 @@ mkdir -p $MES_PREFIX/lib
 cp scripts/mescc $PREFIX/bin/mescc
 
 mkdir -p $MES_PREFIX
-tar -cf- doc guile include lib module scaffold stage0 | tar -xf- -C $MES_PREFIX
+tar -cf- doc guile include lib module scaffold | tar -xf- -C $MES_PREFIX
 
 GUILE_EFFECTIVE_VERSION=${GUILE_EFFECTIVE_VERSION-2.2}
 DATADIR=${MODULEDIR-$PREFIX/share/mes}
index 87bb0ac84625d57d5ae2a7b2528a00d19eb02814..0716a2d49717e8df4dd05714b215586c94bb7023 100644 (file)
 #include <sys/time.h>
 #include <unistd.h>
 
-#include <libc-gcc.c>
-#include <linux+tcc-gcc.c>
-#include <libc+tcc.c>
-#include <getopt.c>
-#include <m4.c>
-
 int errno;
 
 void
index 5537c2880f895fb97f484e98ffd8658a354d72ed..6949cb32e2f58bc4bca397e1a0d28718b5b907b3 100644 (file)
 #include <sys/time.h>
 #include <unistd.h>
 
-#include <libc-mes.c>
-#include <linux+tcc-mes.c>
-#include <libc+tcc.c>
-#include <getopt.c>
-
 int errno;
 
 void
index 1e1e2939e2e82224d033a3799bf63233b0a757e1..1152e72648a30c41c7ca9c4ca88b71a0bdd66540 100644 (file)
 #include <sys/time.h>
 #include <unistd.h>
 
+#include <libc.c>
+
+#if __MESC__
+
+#include <linux+tcc-mes.c>
+#include <libc+tcc-mes.c>
+#include <getopt.c>
+
+#else // !__MESC__
+
+#include <linux+tcc-gcc.c>
+#include <libc+tcc-gcc.c>
+#include <getopt.c>
+#include <m4.c>
+
+#endif // !__MESC__
+
 int
 dlclose (void *handle)
 {
@@ -108,7 +125,10 @@ ftell (FILE *stream)
 int
 fseek (FILE *stream, long offset, int whence)
 {
-  return lseek ((int)stream, offset, whence);
+  int pos = lseek ((int)stream, offset, whence);
+  if (pos >= 0)
+    return 0;
+  return -1;
 }
 
 int
diff --git a/lib/libc-gcc.c b/lib/libc-gcc.c
deleted file mode 100644 (file)
index 95c2266..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-/* -*-comment-start: "//";comment-end:""-*-
- * Mes --- Maxwell Equations of Software
- * Copyright © 2016,2017,2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
- *
- * This file is part of Mes.
- *
- * Mes is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or (at
- * your option) any later version.
- *
- * Mes is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Mes.  If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include <libmes.h>
-#include <stdio.h>
-
-#include <libmes.h>
-#include <stdarg.h>
-#include <stdlib.h>
-#include <unistd.h>
-
-#include <fcntl.h>
-#include <assert.h>
-
-#include <linux-mini-gcc.c>
-#include <libc-mini.c>
-#include <linux-gcc.c>
-#include <libmes.c>
-#include <libc.c>
diff --git a/lib/libc-mes.c b/lib/libc-mes.c
deleted file mode 100644 (file)
index 9c9b08d..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-/* -*-comment-start: "//";comment-end:""-*-
- * Mes --- Maxwell Equations of Software
- * Copyright © 2016,2017,2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
- *
- * This file is part of Mes.
- *
- * Mes is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or (at
- * your option) any later version.
- *
- * Mes is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Mes.  If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include <libmes.h>
-#include <stdarg.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-void _env ();
-
-#include <linux-mini-mes.c>
-#include <libc-mini.c>
-#include <linux-mes.c>
-#include <libmes.c>
-#include <libc.c>
diff --git a/lib/libc-mini-gcc.c b/lib/libc-mini-gcc.c
deleted file mode 100644 (file)
index 5eff7e5..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/* -*-comment-start: "//";comment-end:""-*-
- * Mes --- Maxwell Equations of Software
- * Copyright © 2016,2017 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
- *
- * This file is part of Mes.
- *
- * Mes is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or (at
- * your option) any later version.
- *
- * Mes is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Mes.  If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include <linux-mini-gcc.c>
-#include <libc-mini.c>
diff --git a/lib/libc-mini-mes.c b/lib/libc-mini-mes.c
deleted file mode 100644 (file)
index bc1eadd..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/* -*-comment-start: "//";comment-end:""-*-
- * Mes --- Maxwell Equations of Software
- * Copyright © 2016,2017 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
- *
- * This file is part of Mes.
- *
- * Mes is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or (at
- * your option) any later version.
- *
- * Mes is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Mes.  If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include <linux-mini-mes.c>
-#include <libc-mini.c>
index 23b072548348fd1b76a2b72eaee3a63f89fcb20c..09293ccf1b2aaba7e6e5c6ac00baf12f4a8b175a 100644 (file)
@@ -47,3 +47,13 @@ puts (char const* s)
   write (1, s, i);
   return 0;
 }
+
+#if __MESC__
+
+#include <linux-mini-mes.c>
+
+#else // !__MESC__
+
+#include <linux-mini-gcc.c>
+
+#endif // !__MESC__
index 15afbcda2b225d7153ade8e655895eeb7a010bf6..b50a1126ca787236a95be0b8c6cfabba651ce370 100644 (file)
 #include <sys/ioctl.h>
 #include <stdarg.h>
 #include <stdlib.h>
+#include <libmes.h>
+#include <stdio.h>
+
+#include <libmes.h>
+#include <stdarg.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+#if __MESC__
+
+#include <linux-mes.c>
+
+#else // !__MESC__
+
+#include <fcntl.h>
+#include <assert.h>
+
+#include <linux-gcc.c>
+
+#endif // !__MESC__
+
+#include <libc-mini.c>
+#include <libmes.c>
 
 int g_stdin = 0;
 
 void _env ();
 
 int
-eputc (int c)
+getchar ()
+{
+  return fdgetc (g_stdin);
+}
+
+int
+putchar (int c)
 {
-  return fdputc (c, STDERR);
+  write (STDOUT, (char*)&c, 1);
+  return 0;
 }
 
 int
@@ -62,10 +92,6 @@ fopen (char const* file_name, char const* mode)
     /* Everything else is a read */
     fd = open (file_name, 0, 0);
 
-  /* Negative numbers are error codes */
-  if (fd > 0)
-    return 0;
-
   return (FILE*)fd;
 }
 
index 9f09b6f38c42ab65050472665f643ab8a198c3a5..fa67879dc3759c20346e793570f90de2a3c67031 100644 (file)
@@ -19,6 +19,8 @@
  */
 
 #include <libmes.h>
+#include <string.h>
+#include <unistd.h>
 
 int
 isdigit (int c)
@@ -169,13 +171,6 @@ fdputc (int c, int fd)
   return 0;
 }
 
-int
-putchar (int c)
-{
-  write (STDOUT, (char*)&c, 1);
-  return 0;
-}
-
 int
 fdputs (char const* s, int fd)
 {
@@ -192,8 +187,19 @@ fdungetc (int c, int fd)
   return c;
 }
 
+#if POSIX
+#define STDERR 2
+int
+eputs (char const* s)
+{
+  int i = strlen (s);
+  write (STDERR, s, i);
+  return 0;
+}
+#endif
+
 int
-getchar ()
+eputc (int c)
 {
-  return fdgetc (g_stdin);
+  return fdputc (c, STDERR);
 }
diff --git a/lib/x86-mes/elf-0footer.hex2 b/lib/x86-mes/elf-0footer.hex2
new file mode 100644 (file)
index 0000000..cfae2e9
--- /dev/null
@@ -0,0 +1,26 @@
+### Copyright (C) 2017 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
+### This file is part of stage0.
+###
+### stage0 is free software: you an redistribute it and/or modify
+### it under the terms of the GNU General Public License as published by
+### the Free Software Foundation, either version 3 of the License, or
+### (at your option) any later version.
+###
+### stage0 is distributed in the hope that it will be useful,
+### but WITHOUT ANY WARRANTY; without even the implied warranty of
+### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+### GNU General Public License for more details.
+###
+### You should have received a copy of the GNU General Public License
+### along with stage0.  If not, see <http://www.gnu.org/licenses/>.
+
+### stage0's hex2 format for x86
+###    !<label>          1 byte relative
+###    $<label>          2 byte address
+###    @<label>          2 byte relative
+###    &<label>          4 byte address
+###    %<label>          4 byte relative
+###    local_<label>     function-local
+###    string_<index>    string #<index>
+
+:ELF_end
diff --git a/lib/x86-mes/elf32-0header.hex2 b/lib/x86-mes/elf32-0header.hex2
new file mode 100644 (file)
index 0000000..36e584a
--- /dev/null
@@ -0,0 +1,78 @@
+### Copyright (C) 2016 Jeremiah Orians
+### Copyright (C) 2017 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
+### This file is part of stage0.
+###
+### stage0 is free software: you an redistribute it and/or modify
+### it under the terms of the GNU General Public License as published by
+### the Free Software Foundation, either version 3 of the License, or
+### (at your option) any later version.
+###
+### stage0 is distributed in the hope that it will be useful,
+### but WITHOUT ANY WARRANTY; without even the implied warranty of
+### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+### GNU General Public License for more details.
+###
+### You should have received a copy of the GNU General Public License
+### along with stage0.  If not, see <http://www.gnu.org/licenses/>.
+
+### stage0's hex2 format for x86
+###    !<label>          1 byte relative
+###    $<label>          2 byte address
+###    @<label>          2 byte relative
+###    &<label>          4 byte address
+###    %<label>          4 byte relative
+###    local_<label>     function-local
+###    string_<index>    string #<index>
+
+### elf32-header-exit-42.hex2: 32 bit elf header in hex2 for `exit 42'
+
+:ELF_base
+7F 45 4C 46                    # e_ident[EI_MAG0-3] ELF's magic number
+
+01                             # e_ident[EI_CLASS] Indicating 32 bit
+01                             # e_ident[EI_DATA] Indicating little endianness
+01                             # e_ident[EI_VERSION] Indicating original elf
+
+00                             # e_ident[EI_OSABI] Set at 0 because none cares
+00                             # e_ident[EI_ABIVERSION] See above
+
+00 00 00 00 00 00 00           # e_ident[EI_PAD]
+
+02 00                          # e_type Indicating Executable
+03 00                          # e_machine Indicating AMD64
+01 00 00 00                    # e_version Indicating original elf
+
+&ELF_text                      # e_entry Address of the entry point
+%ELF_program_headers>ELF_base  # e_phoff Address of program header table
+00 00 00 00                    # e_shoff Address of section header table
+
+00 00 00 00                    # e_flags
+
+34 00                          # e_ehsize Indicating our 52 Byte header
+
+20 00                          # e_phentsize size of a program header table
+01 00                          # e_phnum number of entries in program table
+
+00 00                          # e_shentsize size of a section header table
+00 00                          # e_shnum number of entries in section table
+
+00 00                          # e_shstrndx index of the section names
+
+# @34
+00 00 00 00
+00 00 00 00
+00 00 00 00
+
+# @40
+:ELF_program_headers
+:ELF_program_header__text
+01 00 00 00                    # ph_type: PT-LOAD = 1
+00 00 00 00                    # ph_offset
+&ELF_base                      # ph_vaddr
+&ELF_base                      # ph_physaddr
+%ELF_end>ELF_base              # ph_filesz
+%ELF_end>ELF_base              # ph_memsz
+07 00 00 00                    # ph_flags: PF-X|PF-W|PF-R = 7
+01 00 00 00                    # ph_align
+
+:ELF_text
diff --git a/lib/x86-mes/elf32-body-exit-42.hex2 b/lib/x86-mes/elf32-body-exit-42.hex2
new file mode 100644 (file)
index 0000000..130f69b
--- /dev/null
@@ -0,0 +1,48 @@
+### Copyright (C) 2017 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
+### This file is part of stage0.
+###
+### stage0 is free software: you an redistribute it and/or modify
+### it under the terms of the GNU General Public License as published by
+### the Free Software Foundation, either version 3 of the License, or
+### (at your option) any later version.
+###
+### stage0 is distributed in the hope that it will be useful,
+### but WITHOUT ANY WARRANTY; without even the implied warranty of
+### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+### GNU General Public License for more details.
+###
+### You should have received a copy of the GNU General Public License
+### along with stage0.  If not, see <http://www.gnu.org/licenses/>.
+
+### stage0's hex2 format for x86
+###    !<label>          1 byte relative
+###    $<label>          2 byte address
+###    @<label>          2 byte relative
+###    &<label>          4 byte address
+###    %<label>          4 byte relative
+###    local_<label>     function-local
+###    string_<index>    string #<index>
+
+### elf32-body-exit-42.hex2: 32 bit elf body in hex2 for `exit 42'
+
+# @200
+:ELF_text
+:_start
+# exit(42)
+e8 %main                       # call   +11 <main>
+00 00 00
+00 00 00 00
+00 00 00 00
+
+# @210
+:main
+bb 2a 00 00 00                 # mov    $42,%ebx
+b8 01 00 00 00                 # mov    $0x1,%eax
+cd 80                          # int    $0x80
+
+00 00 00 00
+
+# @220
+:ELF_data
+65 78 69 74 34 32 20 64 61 74 61 20 68 65 72 65 # exit42 data here"
+
diff --git a/lib/x86-mes/elf32-footer-single-main.hex2 b/lib/x86-mes/elf32-footer-single-main.hex2
new file mode 100644 (file)
index 0000000..61523a9
--- /dev/null
@@ -0,0 +1,64 @@
+### Copyright (C) 2017 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
+### This file is part of stage0.
+###
+### stage0 is free software: you an redistribute it and/or modify
+### it under the terms of the GNU General Public License as published by
+### the Free Software Foundation, either version 3 of the License, or
+### (at your option) any later version.
+###
+### stage0 is distributed in the hope that it will be useful,
+### but WITHOUT ANY WARRANTY; without even the implied warranty of
+### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+### GNU General Public License for more details.
+###
+### You should have received a copy of the GNU General Public License
+### along with stage0.  If not, see <http://www.gnu.org/licenses/>.
+
+### stage0's hex2 format for x86
+###    !<label>          1 byte relative
+###    $<label>          2 byte address
+###    @<label>          2 byte relative
+###    &<label>          4 byte address
+###    %<label>          4 byte relative
+###    local_<label>     function-local
+###    string_<index>    string #<index>
+
+### elf32-footer-single-main.hex2: 32 bit elf footer in hex2 for single main
+
+# @230
+
+:ELF_str
+00                             # 0
+:ELF_str__start
+5f 73 74 61 72 74 00           # _start
+:ELF_str__main
+6d 61 69 6e 00                 # main
+
+00 00 00
+
+# @240
+:ELF_sym
+00 00 00 00                    # st-name
+00 00 00 00                    # st-offset: &_start - BaseAddress
+00 00 00 00                    # st-len   : &main - _start
+00                             # st-info = stt-func= 2
+00                             # st-other
+01 00                          # st-shndx: 1
+
+# _start
+%ELF_str__start>ELF_str        # st-name
+&_start
+10 00 00 00                    # st-len   : &main - _start
+02                             # st-info = stt-func= 2
+00                             # st-other
+01 00                          # st-shndx: 1
+
+# main
+%ELF_str__main>ELF_str         # st-name
+&main
+10 00 00 00                    # st-len   : &ELF_data - main
+02                             # st-info = stt-func= 2
+00                             # st-other
+01 00                          # st-shndx: 1
+
+:ELF_end
diff --git a/lib/x86-mes/elf32-header.hex2 b/lib/x86-mes/elf32-header.hex2
new file mode 100644 (file)
index 0000000..2279667
--- /dev/null
@@ -0,0 +1,216 @@
+### Copyright (C) 2016 Jeremiah Orians
+### Copyright (C) 2017 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
+### This file is part of stage0.
+###
+### stage0 is free software: you an redistribute it and/or modify
+### it under the terms of the GNU General Public License as published by
+### the Free Software Foundation, either version 3 of the License, or
+### (at your option) any later version.
+###
+### stage0 is distributed in the hope that it will be useful,
+### but WITHOUT ANY WARRANTY; without even the implied warranty of
+### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+### GNU General Public License for more details.
+###
+### You should have received a copy of the GNU General Public License
+### along with stage0.  If not, see <http://www.gnu.org/licenses/>.
+
+### stage0's hex2 format for x86
+###    !<label>          1 byte relative
+###    $<label>          2 byte address
+###    @<label>          2 byte relative
+###    &<label>          4 byte address
+###    %<label>          4 byte relative
+###    local_<label>     function-local
+###    string_<index>    string #<index>
+
+### elf32-header-exit-42.hex2: 32 bit elf header in hex2 for `exit 42'
+
+:ELF_base
+7F 45 4C 46                    # e_ident[EI_MAG0-3] ELF's magic number
+
+01                             # e_ident[EI_CLASS] Indicating 32 bit
+01                             # e_ident[EI_DATA] Indicating little endianness
+01                             # e_ident[EI_VERSION] Indicating original elf
+
+00                             # e_ident[EI_OSABI] Set at 0 because none cares
+00                             # e_ident[EI_ABIVERSION] See above
+
+00 00 00 00 00 00 00           # e_ident[EI_PAD]
+
+02 00                          # e_type Indicating Executable
+03 00                          # e_machine Indicating AMD64
+01 00 00 00                    # e_version Indicating original elf
+
+&ELF_text                      # e_entry Address of the entry point
+%ELF_program_headers>ELF_base  # e_phoff Address of program header table
+%ELF_section_headers>ELF_base  # e_shoff Address of section header table
+
+00 00 00 00                    # e_flags
+
+34 00                          # e_ehsize Indicating our 52 Byte header
+
+20 00                          # e_phentsize size of a program header table
+02 00                          # e_phnum number of entries in program table
+
+28 00                          # e_shentsize size of a section header table
+07 00                          # e_shnum number of entries in section table
+
+04 00                          # e_shstrndx index of the section names
+
+# @34
+00 00 00 00
+00 00 00 00
+00 00 00 00
+
+# @40
+:ELF_program_headers
+:ELF_program_header__text
+01 00 00 00                    # ph_type: PT-LOAD = 1
+00 00 00 00                    # ph_offset
+&ELF_base                      # ph_vaddr
+&ELF_base                      # ph_physaddr
+%ELF_end>ELF_base              # ph_filesz
+%ELF_end>ELF_base              # ph_memsz
+07 00 00 00                    # ph_flags: PF-X|PF-W|PF-R = 7
+01 00 00 00                    # ph_align
+
+# @60
+:ELF_program_header__data
+01 00 00 00                     # ph_type: PT-LOAD = 1
+00 00 00 00                     # ph_offset
+&ELF_base                       # ph_vaddr
+&ELF_base                       # ph_physaddr
+%ELF_end>ELF_base               # ph_filesz
+%ELF_end>ELF_base               # ph_memsz
+07 00 00 00                     # ph_flags: PF-X|PF-W|PF-R = 7
+01 00 00 00                     # ph_align
+
+# @80
+:ELF_comment
+4d 45 53 00                     # MES
+00 00 00 00                     # align
+00 00 00 00
+00 00 00 00
+
+4d 45 53 00                     # MES
+00 00 00 00                     # align
+00 00 00 00
+00 00 00 00
+
+# @a0
+:ELF_shstr
+00
+:ELF_shstr__text
+2e 74 65 78 74 00               # .text
+:ELF_shstr__data
+2e 64 61 74 61 00               # .data
+:ELF_shstr__comment
+2e 63 6f 6d 6d 65 6e 74 00      # .comment
+:ELF_shstr__shstr
+2e 73 68 73 74 72 74 61 62 00   # .shstrtab
+:ELF_shstr__sym
+2e 73 79 6d 74 61 62 00         # .symtab
+:ELF_shstr__str
+2e 73 74 72 74 61 62 00         # .strtab
+
+# @d0
+
+:ELF_section_headers
+00 00 00 00                     # sh_name
+00 00 00 00                     # sh_type
+00 00 00 00                     # sh_flags
+00 00 00 00                     # sh_addr
+00 00 00 00                     # sh_offset
+00 00 00 00                     # sh_length
+00 00 00 00                     # sh_link
+00 00 00 00                     # sh_info
+01 00 00 00                     # sh_1?
+00 00 00 00                     # sh_entsize
+
+## FIXME: M0 for calculations?
+:ELF_section_header_text
+%ELF_shstr__text>ELF_shstr      # sh_name
+01 00 00 00                     # sh_type = SHT_PROGBITS = 1
+06 00 00 00                     # sh_flags = SHF-ALLOC|SHF-EXEC =2 | 4 = 6
+&ELF_text                       # sh_addr
+%ELF_text>ELF_base              # sh_offset
+%ELF_data>ELF_text              # sh_length
+00 00 00 00                     # sh_link
+00 00 00 00                     # sh_info
+01 00 00 00                     # sh_1?
+00 00 00 00                     # sh_entsize
+
+:ELF_section_header_data
+%ELF_shstr__data>ELF_shstr     # sh_name
+01 00 00 00                    # sh_type = SHT_PROGBITS = 1
+03 00 00 00                    # sh_flags = SHF-WRITE|SHF-ALLOC = 1 | 2 = 3
+&ELF_data                      # sh_addr
+%ELF_data>ELF_base             # sh_offset
+%ELF_sym>ELF_data              # sh_length
+00 00 00 00                    # sh_link
+00 00 00 00                    # sh_info
+01 00 00 00                    # sh_1?
+00 00 00 00                    # sh_entsize
+
+:ELF_section_header_comment
+%ELF_shstr__comment>ELF_shstr  # sh_name
+01 00 00 00                    # sh_type = SHT_PROGBITS = 1
+00 00 00 00                    # sh_flags
+&ELF_comment                   # sh_addr
+%ELF_comment>ELF_base          # sh_offset
+%ELF_shstr>ELF_comment         # sh_length
+00 00 00 00                    # sh_link
+00 00 00 00                    # sh_info
+01 00 00 00                    # sh_1?
+00 00 00 00                    # sh_entsize
+
+:ELF_section_header_shstr
+%ELF_shstr__shstr>ELF_shstr    # sh_name
+03 00 00 00                    # sh_type: str-sht-strtab
+00 00 00 00                    # sh_flags
+&ELF_shstr                     # sh_addr
+%ELF_shstr>ELF_base            # sh_offset
+%ELF_section_headers>ELF_shstr # sh_length
+00 00 00 00                    # sh_link
+00 00 00 00                    # sh_info
+01 00 00 00                    # sh_1?
+00 00 00 00                    # sh_entsize
+
+:ELF_section_header_sym
+%ELF_shstr__sym>ELF_shstr      # sh_name
+02 00 00 00                    # sh_type: str-sht-symtab
+00 00 00 00                    # sh_flags
+&ELF_sym                       # sh_addr
+%ELF_sym>ELF_base              # sh_offset
+%ELF_end>ELF_sym               # sh_length
+06 00 00 00                    # sh_link:6
+00 00 00 00                    # sh_info
+01 00 00 00                    # sh_1?
+10 00 00 00                    # sh_entsize
+
+:ELF_section_header_str
+%ELF_shstr__str>ELF_shstr      # sh_name
+03 00 00 00                    # sh_type: str-sht-strtab
+00 00 00 00                    # sh_flags
+&ELF_str                       # sh_addr
+%ELF_str>ELF_base              # sh_offset
+%ELF_sym>ELF_str               # sh_length
+00 00 00 00                    # sh_link
+00 00 00 00                    # sh_info
+01 00 00 00                    # sh_1?
+00 00 00 00                    # sh_entsize
+
+# @1e8
+00 00 00 00  # align
+00 00 00 00
+
+# @1f0
+
+00 00 00 00  # align
+00 00 00 00
+00 00 00 00
+00 00 00 00
+
+# @200
+:ELF_text
diff --git a/lib/x86-mes/exit-42.c b/lib/x86-mes/exit-42.c
new file mode 100644 (file)
index 0000000..f4078b1
--- /dev/null
@@ -0,0 +1,25 @@
+/* -*-comment-start: "//";comment-end:""-*-
+ * Mes --- Maxwell Equations of Software
+ * Copyright © 2017 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
+ *
+ * This file is part of Mes.
+ *
+ * Mes is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or (at
+ * your option) any later version.
+ *
+ * Mes is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Mes.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+int
+main (int argc, char *argv[])
+{
+  return 42;
+}
diff --git a/lib/x86-mes/x86.M1 b/lib/x86-mes/x86.M1
new file mode 100644 (file)
index 0000000..3c1e0f6
--- /dev/null
@@ -0,0 +1,232 @@
+### Mes --- Maxwell Equations of Software
+### Copyright © 2017 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
+###
+### This file is part of Mes.
+###
+### Mes is free software# you can redistribute it and/or modify it
+### under the terms of the GNU General Public License as published by
+### the Free Software Foundation# either version 3 of the License, or (at
+### your option) any later version.
+###
+### Mes is distributed in the hope that it will be useful, but
+### WITHOUT ANY WARRANTY# without even the implied warranty of
+### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+### GNU General Public License for more details.
+###
+### You should have received a copy of the GNU General Public License
+### along with Mes.  If not, see <http://www.gnu.org/licenses/>.
+
+
+DEFINE add____$i32,%eax 05
+DEFINE add____$i32,%ecx 81c1
+DEFINE add____$i32,%edx 81c2
+DEFINE add____$i32,(%eax) 8100
+DEFINE add____$i32,0x32(%eax) 8180
+DEFINE add____$i32,0x32(%ebp) 8185
+DEFINE add____$i8,%eax 83c0
+DEFINE add____$i8,%edx 83c2
+DEFINE add____$i8,%esp 83c4
+DEFINE add____$i8,(%eax) 8300
+DEFINE add____$i8,0x32 8305
+DEFINE add____$i8,0x32(%eax) 8380
+DEFINE add____$i8,0x32(%eax) 8380
+DEFINE add____$i8,0x32(%ebp) 8385
+DEFINE add____$i8,0x8(%eax) 8340
+DEFINE add____$i8,0x8(%ebp) 8345
+DEFINE add____%eax,%eax 01c0
+DEFINE add____%ebp,%eax 01e8
+DEFINE add____%edx,%eax 01d0
+DEFINE add____%edx,%eax 01d0
+DEFINE and____$i32,%eax 25
+DEFINE and____%edx,%eax 21d0
+DEFINE and____(%edx),%eax 2302
+DEFINE call32 e8
+DEFINE call___*%eax ffd0
+DEFINE cmp____$0x32,%eax 3d
+DEFINE cmp____$i32,%eax 3d
+DEFINE cmp____$i32,0x32(%ebp) 81bd
+DEFINE cmp____$i32,0x8(%ebp) 817d
+DEFINE cmp____$i8,%eax 83f8
+DEFINE cmp____$i8,0x32(%ebp) 83bd
+DEFINE cmp____$i8,0x8(%ebp) 837d
+DEFINE cmp____%al,%dl 38c2
+DEFINE cmp____%edx,%eax 39d0
+DEFINE hlt f4
+DEFINE idiv___%ebx f7fb
+DEFINE int cd
+DEFINE int____$0x80 cd80
+DEFINE ja32  0f87
+DEFINE jae32 0f83
+DEFINE jb32  0f82
+DEFINE jbe32 0f86
+DEFINE je32 0f84
+DEFINE je8 74
+DEFINE jg32 0f8f
+DEFINE jge32 0f8d
+DEFINE jl32 0f8c
+DEFINE jle32 0f8e
+DEFINE jmp32 e9
+DEFINE jmp____*%ebx ffe3
+DEFINE jne32 0f85
+DEFINE lahf 9f
+DEFINE lea____0x32(%ebp),%eax 8d85
+DEFINE lea____0x32(%ebp),%edx 8d95
+DEFINE lea____0x8(%ebp),%eax 8d45
+DEFINE lea____0x8(%ebp),%edx 8d55
+DEFINE leave c9
+DEFINE mov____$i32,%eax b8
+DEFINE mov____$i32,%ebx bb
+DEFINE mov____$i32,%ecx b9
+DEFINE mov____$i32,%edx ba
+DEFINE mov____$i32,(%eax) c700
+DEFINE mov____$i32,0x32 c705
+DEFINE mov____$i32,0x8(%eax) c740
+DEFINE mov____$i32,0x8(%ebp) c745
+DEFINE mov____%al,(%edx) 8802
+DEFINE mov____%al,0x8(%edx) 8842
+DEFINE mov____%ax,(%edx) 668902
+DEFINE mov____%ax,0x32(%edx) 668982
+DEFINE mov____%ax,0x8(%edx) 668942
+DEFINE mov____%dl,(%eax) 8810
+DEFINE mov____%dl,0x8(%eax) 8850
+DEFINE mov____%eax,%ebx 89c3
+DEFINE mov____%eax,%edx 89c2
+DEFINE mov____%eax,(%ecx) 8901
+DEFINE mov____%eax,(%edx) 8902
+DEFINE mov____%eax,0x32 a3
+DEFINE mov____%eax,0x32(%ebp) 8985
+DEFINE mov____%eax,0x32(%edx) 8982
+DEFINE mov____%eax,0x8(%ebp) 8945
+DEFINE mov____%eax,0x8(%edx) 8942
+DEFINE mov____%ebp,%eax 89e8
+DEFINE mov____%ebp,%ecx 89e9
+DEFINE mov____%ebp,%edx 89ea
+DEFINE mov____%ebx,0x32 891d
+DEFINE mov____%ebx,0x32(%ebp) 899d
+DEFINE mov____%ebx,0x8(%ebp) 895d
+DEFINE mov____%ebx,0x8(%edx) 895a
+DEFINE mov____%ecx,(%eax) 8908
+DEFINE mov____%ecx,(%edx) 890a
+DEFINE mov____%ecx,0x32(%ebp) 898d
+DEFINE mov____%ecx,0x8(%ebp) 894d
+DEFINE mov____%edx,%eax 89d0
+DEFINE mov____%edx,%ebx 89d3
+DEFINE mov____%edx,%ecx 89d1
+DEFINE mov____%edx,(%eax) 8910
+DEFINE mov____%edx,0x32(%ebp) 8995
+DEFINE mov____%edx,0x8(%ebp) 8955
+DEFINE mov____%esp,%ebp 89e5
+DEFINE mov____(%eax),%eax 8b00
+DEFINE mov____(%eax),%ecx 8b08
+DEFINE mov____(%edx),%eax 8b02
+DEFINE mov____(%edx),%ecx 8b0a
+DEFINE mov____(%edx),%edx 8b12
+DEFINE mov____0x32(%eax),%eax 8b80
+DEFINE mov____0x32(%eax),%ebx 8b98
+DEFINE mov____0x32(%eax),%ecx 8b88
+DEFINE mov____0x32(%ebp),%eax 8b85
+DEFINE mov____0x32(%ebp),%eax 8b85
+DEFINE mov____0x32(%ebp),%ebx 8b9d
+DEFINE mov____0x32(%ebp),%ecx 8b8d
+DEFINE mov____0x32(%ebp),%edx 8b95
+DEFINE mov____0x32(%ebp),%edx 8b95
+DEFINE mov____0x32,%eax a1
+DEFINE mov____0x32,%edx 8b15
+DEFINE mov____0x8(%eax),%eax 8b40
+DEFINE mov____0x8(%eax),%ebx 8b58
+DEFINE mov____0x8(%eax),%ecx 8b48
+DEFINE mov____0x8(%ebp),%eax 8b45
+DEFINE mov____0x8(%ebp),%ebp 8b6d
+DEFINE mov____0x8(%ebp),%ebx 8b5d
+DEFINE mov____0x8(%ebp),%ecx 8b4d
+DEFINE mov____0x8(%ebp),%edx 8b55
+DEFINE mov____0x8(%ebp),%esp 8b65
+DEFINE movsbl_%al,%eax 0fbec0
+DEFINE movswl_%ax,%eax 0fbfc0
+DEFINE movzbl_%al,%eax 0fb6c0
+DEFINE movzbl_%al,%eax 0fb6c0
+DEFINE movzbl_%dl,%edx 0fb6d2
+DEFINE movzbl_(%eax),%eax 0fb600
+DEFINE movzbl_(%eax),%edx 0fb610
+DEFINE movzbl_(%edx),%edx 0fb612
+DEFINE movzbl_0x32(%eax),%eax 0fb680
+DEFINE movzbl_0x8(%eax),%eax 0fb640
+DEFINE movzbl_0x8(%ebp),%eax 0fb645
+DEFINE movzwl_%ax,%eax 0fb7c0
+DEFINE movzwl_(%eax),%eax 0fb700
+DEFINE movzwl_0x32(%eax),%eax 0fb780
+DEFINE movzwl_0x32(%ebp),%eax 0fb785
+DEFINE movzwl_0x8(%eax),%eax 0fb740
+DEFINE mul____%edx f7e2
+DEFINE nop 90
+DEFINE not____%eax f7d0
+DEFINE or_____%edx,%eax 09d0
+DEFINE or_____(%edx),%eax 0b02
+DEFINE pop____%eax 58
+DEFINE pop____%edx 5a
+DEFINE push___$i32 68
+DEFINE push___%eax 50
+DEFINE push___%ebp 55
+DEFINE push___%edx 52
+DEFINE push___(%eax) ff30
+DEFINE push___0x32(%ebp) ffb5
+DEFINE push___0x8(%ebp) ff75
+DEFINE ret c3
+DEFINE sahf 9e
+DEFINE seta___%al 0f97c0
+DEFINE setae__%al 0f93c0
+DEFINE setb___%al 0f92c0
+DEFINE setbe__%al 0f96c0
+DEFINE sete___%al 0f94c0
+DEFINE setg___%al 0f9fc0
+DEFINE setge__%al 0f9dc0
+DEFINE setl___%al 0f9cc0
+DEFINE setle__%al 0f9ec0
+DEFINE setne__%al 0f95c0
+DEFINE shl____$i8,%eax c1e0
+DEFINE shl____%cl,%eax d3e0
+DEFINE shr____%cl,%eax d3e8
+DEFINE sub____%al,%dl 28d0
+DEFINE sub____%dl,%al 28c2
+DEFINE sub____%eax,%edx 29c2
+DEFINE sub____%edx,%eax 29d0
+DEFINE sub____%edx,%eax 29d0
+DEFINE sub____%esp,$i32 81ec
+DEFINE sub____%esp,$i8 83ec
+DEFINE test___%al,%al 84c0
+DEFINE test___%eax,%eax 85c0
+DEFINE xchg___%eax,(%esp) 870424
+DEFINE xor____$i32,%eax 35
+DEFINE xor____$i8,%ah 80f4
+DEFINE xor____%eax,%eax 31c0
+DEFINE xor____%ebx,%ebx 31db
+DEFINE xor____%ecx,%ecx 31c9
+DEFINE xor____%edx,%eax 31d0
+DEFINE xor____%edx,%edx 31d2
+
+# Deprecated.  Remove after 0.14 release.
+DEFINE mov____%al,0x32(%ebp) 8885
+DEFINE mov____%al,0x8(%ebp) 8845
+DEFINE mov____%ax,0x32(%ebp) 668985
+DEFINE mov____%ax,0x8(%ebp) 668945
+DEFINE movzbl_0x32(%ebp),%eax 0fb685
+DEFINE movzbl_0x8(%ebp),%edx 0fb655
+DEFINE movzwl_0x8(%ebp),%eax 0fb745
+DEFINE movzwl_0x8(%ebp),%eax 0fb745
+
+DEFINE SYS_exit   01000000
+DEFINE SYS_fork   02000000
+DEFINE SYS_read   03000000
+DEFINE SYS_write  04000000
+DEFINE SYS_open   05000000
+DEFINE SYS_close  06000000
+DEFINE SYS_waitpid 07000000
+DEFINE SYS_unlink 0a000000
+DEFINE SYS_execve 0b000000
+DEFINE SYS_chmod  0f000000
+DEFINE SYS_lseek  13000000
+DEFINE SYS_access 21000000
+DEFINE SYS_brk    2d000000
+DEFINE SYS_ioctl  36000000
+DEFINE SYS_fsync  76000000
+DEFINE SYS_getcwd b7000000
index 3e5b997cecdc99efdce1b60a3f8bb991c3a39f38..49ee5671efb7fe3dca0fe0bd1baa3b10a1ce71c4 100644 (file)
     hex2-file-name))
 
 (define (mescc:link options)
-  (define (library->hex2 o)
-    (prefix-file options (string-append "lib/lib" o "-mes.o")))
   (let* ((files (option-ref options '() '("a.c")))
          (source-files (filter (disjoin .c? .E?) files))
          (S-files (filter .S? files))
                                  (list (infos->hex2 options hex2-file-name infos)))))
          (libraries (filter-map (multi-opt 'library) options))
          (libraries (if (pair? libraries) libraries '("c")))
-         (hex2-libraries (map library->hex2 libraries))
+         (hex2-libraries (map (cut find-library options ".o" <>) libraries))
          (hex2-files (append hex2-files hex2-libraries))
-         (S-files (append S-files (map (cut replace-suffix <> ".S") hex2-libraries)))
+         (S-files (append S-files (map (cut find-library options ".S" <>)  libraries)))
          (debug-info? (option-ref options 'debug-info #f))
          (S-files (cons (replace-suffix input-file-name ".S") S-files))
          (elf-footer (and debug-info?
          (command `(,M1
                     "--LittleEndian"
                     "--Architecture=1"
-                    "-f" ,(prefix-file options "stage0/x86.M1")
+                    "-f" ,(arch-find options "x86.M1")
                     ,@(append-map (cut list "-f" <>) M1-files)
                     "-o" ,hex2-file-name)))
     (when verbose?
          (elf-file-name (cond ((option-ref options 'output #f))
                               (else (replace-suffix input-file-name ""))))
          (verbose? (option-ref options 'verbose #f))
-         (elf-footer (or elf-footer (prefix-file options "stage0/elf32-footer-single-main.hex2")))
+         (elf-footer (or elf-footer (arch-find options "elf32-footer-single-main.hex2")))
          (hex2 (or (getenv "HEX2") "hex2"))
          (command `(,hex2
                     "--LittleEndian"
                     "--Architecture=1"
                     "--BaseAddress=0x1000000"
-                    "-f" ,(prefix-file options "stage0/elf32-header.hex2")
-                    "-f" ,(prefix-file options "lib/crt1.o")
+                    "-f" ,(arch-find options "elf32-header.hex2")
+                    "-f" ,(arch-find options "crt1.o")
                     ,@(append-map (cut list "-f" <>) hex2-files)
                     "-f" ,elf-footer
                     "--exec_enable"
                     "-o" ,elf-file-name)))
     (when verbose?
-      (stderr "command=~s\n" command)
-      (format (current-error-port) "~a\n" (string-join command)))
+      (stderr "~a\n" (string-join command)))
     (and (zero? (apply system* command))
          elf-file-name)))
 
          (verbose? (option-ref options 'verbose #f))
          (blood-elf (or (getenv "BLOOD_ELF") "blood-elf"))
          (command `(,blood-elf
-                      "-f" ,(prefix-file options "stage0/x86.M1")
+                      "-f" ,(arch-find options "x86.M1")
                       ,@(append-map (cut list "-f" <>) M1-files)
                       "-o" ,M1-blood-elf-footer)))
     (when verbose?
          (base (if (pair? (cdr parts)) (drop-right parts 1))))
     (string-append (string-join base ".") suffix)))
 
+(define (find-library options ext o)
+  (arch-find options (string-append "lib" o ext)))
+
+(define* (arch-find options file-name)
+  (let* ((path (cons (prefix-file options "lib")
+                     (filter-map (multi-opt 'library-dir) options)))
+         (arch-file-name (string-append "x86-mes/" file-name))
+         (verbose? (option-ref options 'verbose #f)))
+    (when verbose?
+      (stderr "arch-find=~s\n" arch-file-name)
+      (stderr "     path=~s\n" path)
+      (stderr "  => ~s\n" (search-path path arch-file-name)))
+    (search-path path arch-file-name)))
+
 (define (prefix-file options file-name)
   (let ((prefix (option-ref options 'prefix "")))
     (define (prefix-file o)
       (if (string-null? prefix) o (string-append prefix "/" o)))
     (prefix-file file-name)))
 
+
 (define (multi-opt option-name) (lambda (o) (and (eq? (car o) option-name) (cdr o))))
 
 (define (.c? o) (or (string-suffix? ".c" o)
index ae7ce6733209358d202c7deb85e6fddf2f364804..d34dc9df4368ac175d89494cab75bef6091febfb 100644 (file)
@@ -57,16 +57,6 @@ add2 (void *ptab)
 
 struct foo *hash_ident[10];
 
-#if !defined (__TINYC__)
-void *
-memset (void *s, int c, size_t n)
-{
-  char *p = s;
-  while (n--) *p++ = c;
-  return s;
-}
-#endif
-
 int
 test ()
 {
index 27802ed2213f133cc7e453e0ae563fb181c12ce9..a59854052fbfdf44ad633ba8a666505acaaabebf 100644 (file)
 #include <stdlib.h>
 #include <string.h>
 
-#if !defined ( __TINYC__)
-unsigned long long
-strtoull (char const *p, char **end, int base)
-{
-  *end = p;
-  return abtoi (end, base);
-}
-#endif
-
 int
 test ()
 {
@@ -43,10 +34,10 @@ test ()
   if (strcmp (p, "foo\n")) return 2;
 
   p = "2azar\n";
-  n = strtoull (p, (char**)&p, 16);  
+  n = strtoull (p, (char**)&p, 16);
   if (n != 42) return 3;
   eputs (p);
   if (strcmp (p, "zar\n")) return 4;
-  
+
   return 0;
 }
index c9d7da92b41af5efa1298853429e0cedca9bd5d5..36c5b01e674977eedfde27c7c97f2dd792f668e9 100755 (executable)
@@ -7,8 +7,10 @@ PREFIX=${PREFIX-@PREFIX@}
 if [ "$PREFIX" = @PREFIX""@ -o ! -d "$PREFIX" ]
 then
     MES_PREFIX=${MES_PREFIX-$(cd $(dirname $0)/.. && pwd)}
-    export MES_PREFIX
+else
+    MES_PREFIX=${MES_PREFIX-$PREFIX/share/mes}
 fi
+export MES_PREFIX
 mes_p=$(command -v mes)
 if [ '(' -z "$mes_p" -a -z "$MES" ')' -o "$MES" = "guile" -o "$MES" = "mes.guile" ]; then
     GODIR=${GODIR-@GODIR@}
@@ -50,7 +52,10 @@ fi
   #:use-module (mescc mescc)
   #:export (main))
 
-(define %prefix (if (string-prefix? "@PREFIX" "@PREFIX@") (or (getenv "MES_PREFIX") "") "@PREFIX@"))
+(define %prefix (or (getenv "MES_PREFIX")
+                    (if (string-prefix? "@PREFIX" "@PREFIX@")
+                        ""
+                        "@PREFIX@/share/mes")))
 
 (define %version (if (string-prefix? "@VERSION" "@VERSION@") "git"
                      "@VERSION@"))
@@ -76,6 +81,7 @@ fi
             (debug-info (single-char #\g))
             (help (single-char #\h))
             (include (single-char #\I) (value #t))
+            (library-dir (single-char #\L) (value #t))
             (library (single-char #\l) (value #t))
             (preprocess (single-char #\E))
             (output (single-char #\o) (value #t))
@@ -99,6 +105,7 @@ Usage: mescc [OPTION]... FILE...
   -g                 add debug info [GDB, objdump] TODO: hex2 footer
   -h, --help         display this help and exit
   -I DIR             append DIR to include path
+  -L DIR             append DIR to library path
   -l LIBNAME         link with LIBNAME
   -o FILE            write output to FILE
   -S                 preprocess and compile only; do not assemble or link
index f2c1e945f3751e823345b3b78f743e0f5ec4527e..d98c613b5214347682a13318cd68d68b064bf77f 100644 (file)
--- a/src/mes.c
+++ b/src/mes.c
 #include <libmes.h>
 
 //#define MES_MINI 1
-#if _POSIX_SOURCE
-int ARENA_SIZE = 300000000; // 32b: 4GiB, 64b: 8 GiB
-#else
 int ARENA_SIZE = 200000; // 32b: 2MiB, 64b: 4 MiB
-#endif
-int MAX_ARENA_SIZE = 300000000;
+int MAX_ARENA_SIZE = 100000000;
 
 int JAM_SIZE = 20000;
 int GC_SAFETY = 2000;
diff --git a/stage0/elf-0footer.hex2 b/stage0/elf-0footer.hex2
deleted file mode 100644 (file)
index cfae2e9..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-### Copyright (C) 2017 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
-### This file is part of stage0.
-###
-### stage0 is free software: you an redistribute it and/or modify
-### it under the terms of the GNU General Public License as published by
-### the Free Software Foundation, either version 3 of the License, or
-### (at your option) any later version.
-###
-### stage0 is distributed in the hope that it will be useful,
-### but WITHOUT ANY WARRANTY; without even the implied warranty of
-### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-### GNU General Public License for more details.
-###
-### You should have received a copy of the GNU General Public License
-### along with stage0.  If not, see <http://www.gnu.org/licenses/>.
-
-### stage0's hex2 format for x86
-###    !<label>          1 byte relative
-###    $<label>          2 byte address
-###    @<label>          2 byte relative
-###    &<label>          4 byte address
-###    %<label>          4 byte relative
-###    local_<label>     function-local
-###    string_<index>    string #<index>
-
-:ELF_end
diff --git a/stage0/elf32-0header.hex2 b/stage0/elf32-0header.hex2
deleted file mode 100644 (file)
index 36e584a..0000000
+++ /dev/null
@@ -1,78 +0,0 @@
-### Copyright (C) 2016 Jeremiah Orians
-### Copyright (C) 2017 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
-### This file is part of stage0.
-###
-### stage0 is free software: you an redistribute it and/or modify
-### it under the terms of the GNU General Public License as published by
-### the Free Software Foundation, either version 3 of the License, or
-### (at your option) any later version.
-###
-### stage0 is distributed in the hope that it will be useful,
-### but WITHOUT ANY WARRANTY; without even the implied warranty of
-### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-### GNU General Public License for more details.
-###
-### You should have received a copy of the GNU General Public License
-### along with stage0.  If not, see <http://www.gnu.org/licenses/>.
-
-### stage0's hex2 format for x86
-###    !<label>          1 byte relative
-###    $<label>          2 byte address
-###    @<label>          2 byte relative
-###    &<label>          4 byte address
-###    %<label>          4 byte relative
-###    local_<label>     function-local
-###    string_<index>    string #<index>
-
-### elf32-header-exit-42.hex2: 32 bit elf header in hex2 for `exit 42'
-
-:ELF_base
-7F 45 4C 46                    # e_ident[EI_MAG0-3] ELF's magic number
-
-01                             # e_ident[EI_CLASS] Indicating 32 bit
-01                             # e_ident[EI_DATA] Indicating little endianness
-01                             # e_ident[EI_VERSION] Indicating original elf
-
-00                             # e_ident[EI_OSABI] Set at 0 because none cares
-00                             # e_ident[EI_ABIVERSION] See above
-
-00 00 00 00 00 00 00           # e_ident[EI_PAD]
-
-02 00                          # e_type Indicating Executable
-03 00                          # e_machine Indicating AMD64
-01 00 00 00                    # e_version Indicating original elf
-
-&ELF_text                      # e_entry Address of the entry point
-%ELF_program_headers>ELF_base  # e_phoff Address of program header table
-00 00 00 00                    # e_shoff Address of section header table
-
-00 00 00 00                    # e_flags
-
-34 00                          # e_ehsize Indicating our 52 Byte header
-
-20 00                          # e_phentsize size of a program header table
-01 00                          # e_phnum number of entries in program table
-
-00 00                          # e_shentsize size of a section header table
-00 00                          # e_shnum number of entries in section table
-
-00 00                          # e_shstrndx index of the section names
-
-# @34
-00 00 00 00
-00 00 00 00
-00 00 00 00
-
-# @40
-:ELF_program_headers
-:ELF_program_header__text
-01 00 00 00                    # ph_type: PT-LOAD = 1
-00 00 00 00                    # ph_offset
-&ELF_base                      # ph_vaddr
-&ELF_base                      # ph_physaddr
-%ELF_end>ELF_base              # ph_filesz
-%ELF_end>ELF_base              # ph_memsz
-07 00 00 00                    # ph_flags: PF-X|PF-W|PF-R = 7
-01 00 00 00                    # ph_align
-
-:ELF_text
diff --git a/stage0/elf32-body-exit-42.hex2 b/stage0/elf32-body-exit-42.hex2
deleted file mode 100644 (file)
index 130f69b..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-### Copyright (C) 2017 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
-### This file is part of stage0.
-###
-### stage0 is free software: you an redistribute it and/or modify
-### it under the terms of the GNU General Public License as published by
-### the Free Software Foundation, either version 3 of the License, or
-### (at your option) any later version.
-###
-### stage0 is distributed in the hope that it will be useful,
-### but WITHOUT ANY WARRANTY; without even the implied warranty of
-### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-### GNU General Public License for more details.
-###
-### You should have received a copy of the GNU General Public License
-### along with stage0.  If not, see <http://www.gnu.org/licenses/>.
-
-### stage0's hex2 format for x86
-###    !<label>          1 byte relative
-###    $<label>          2 byte address
-###    @<label>          2 byte relative
-###    &<label>          4 byte address
-###    %<label>          4 byte relative
-###    local_<label>     function-local
-###    string_<index>    string #<index>
-
-### elf32-body-exit-42.hex2: 32 bit elf body in hex2 for `exit 42'
-
-# @200
-:ELF_text
-:_start
-# exit(42)
-e8 %main                       # call   +11 <main>
-00 00 00
-00 00 00 00
-00 00 00 00
-
-# @210
-:main
-bb 2a 00 00 00                 # mov    $42,%ebx
-b8 01 00 00 00                 # mov    $0x1,%eax
-cd 80                          # int    $0x80
-
-00 00 00 00
-
-# @220
-:ELF_data
-65 78 69 74 34 32 20 64 61 74 61 20 68 65 72 65 # exit42 data here"
-
diff --git a/stage0/elf32-footer-single-main.hex2 b/stage0/elf32-footer-single-main.hex2
deleted file mode 100644 (file)
index 61523a9..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-### Copyright (C) 2017 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
-### This file is part of stage0.
-###
-### stage0 is free software: you an redistribute it and/or modify
-### it under the terms of the GNU General Public License as published by
-### the Free Software Foundation, either version 3 of the License, or
-### (at your option) any later version.
-###
-### stage0 is distributed in the hope that it will be useful,
-### but WITHOUT ANY WARRANTY; without even the implied warranty of
-### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-### GNU General Public License for more details.
-###
-### You should have received a copy of the GNU General Public License
-### along with stage0.  If not, see <http://www.gnu.org/licenses/>.
-
-### stage0's hex2 format for x86
-###    !<label>          1 byte relative
-###    $<label>          2 byte address
-###    @<label>          2 byte relative
-###    &<label>          4 byte address
-###    %<label>          4 byte relative
-###    local_<label>     function-local
-###    string_<index>    string #<index>
-
-### elf32-footer-single-main.hex2: 32 bit elf footer in hex2 for single main
-
-# @230
-
-:ELF_str
-00                             # 0
-:ELF_str__start
-5f 73 74 61 72 74 00           # _start
-:ELF_str__main
-6d 61 69 6e 00                 # main
-
-00 00 00
-
-# @240
-:ELF_sym
-00 00 00 00                    # st-name
-00 00 00 00                    # st-offset: &_start - BaseAddress
-00 00 00 00                    # st-len   : &main - _start
-00                             # st-info = stt-func= 2
-00                             # st-other
-01 00                          # st-shndx: 1
-
-# _start
-%ELF_str__start>ELF_str        # st-name
-&_start
-10 00 00 00                    # st-len   : &main - _start
-02                             # st-info = stt-func= 2
-00                             # st-other
-01 00                          # st-shndx: 1
-
-# main
-%ELF_str__main>ELF_str         # st-name
-&main
-10 00 00 00                    # st-len   : &ELF_data - main
-02                             # st-info = stt-func= 2
-00                             # st-other
-01 00                          # st-shndx: 1
-
-:ELF_end
diff --git a/stage0/elf32-header.hex2 b/stage0/elf32-header.hex2
deleted file mode 100644 (file)
index 2279667..0000000
+++ /dev/null
@@ -1,216 +0,0 @@
-### Copyright (C) 2016 Jeremiah Orians
-### Copyright (C) 2017 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
-### This file is part of stage0.
-###
-### stage0 is free software: you an redistribute it and/or modify
-### it under the terms of the GNU General Public License as published by
-### the Free Software Foundation, either version 3 of the License, or
-### (at your option) any later version.
-###
-### stage0 is distributed in the hope that it will be useful,
-### but WITHOUT ANY WARRANTY; without even the implied warranty of
-### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-### GNU General Public License for more details.
-###
-### You should have received a copy of the GNU General Public License
-### along with stage0.  If not, see <http://www.gnu.org/licenses/>.
-
-### stage0's hex2 format for x86
-###    !<label>          1 byte relative
-###    $<label>          2 byte address
-###    @<label>          2 byte relative
-###    &<label>          4 byte address
-###    %<label>          4 byte relative
-###    local_<label>     function-local
-###    string_<index>    string #<index>
-
-### elf32-header-exit-42.hex2: 32 bit elf header in hex2 for `exit 42'
-
-:ELF_base
-7F 45 4C 46                    # e_ident[EI_MAG0-3] ELF's magic number
-
-01                             # e_ident[EI_CLASS] Indicating 32 bit
-01                             # e_ident[EI_DATA] Indicating little endianness
-01                             # e_ident[EI_VERSION] Indicating original elf
-
-00                             # e_ident[EI_OSABI] Set at 0 because none cares
-00                             # e_ident[EI_ABIVERSION] See above
-
-00 00 00 00 00 00 00           # e_ident[EI_PAD]
-
-02 00                          # e_type Indicating Executable
-03 00                          # e_machine Indicating AMD64
-01 00 00 00                    # e_version Indicating original elf
-
-&ELF_text                      # e_entry Address of the entry point
-%ELF_program_headers>ELF_base  # e_phoff Address of program header table
-%ELF_section_headers>ELF_base  # e_shoff Address of section header table
-
-00 00 00 00                    # e_flags
-
-34 00                          # e_ehsize Indicating our 52 Byte header
-
-20 00                          # e_phentsize size of a program header table
-02 00                          # e_phnum number of entries in program table
-
-28 00                          # e_shentsize size of a section header table
-07 00                          # e_shnum number of entries in section table
-
-04 00                          # e_shstrndx index of the section names
-
-# @34
-00 00 00 00
-00 00 00 00
-00 00 00 00
-
-# @40
-:ELF_program_headers
-:ELF_program_header__text
-01 00 00 00                    # ph_type: PT-LOAD = 1
-00 00 00 00                    # ph_offset
-&ELF_base                      # ph_vaddr
-&ELF_base                      # ph_physaddr
-%ELF_end>ELF_base              # ph_filesz
-%ELF_end>ELF_base              # ph_memsz
-07 00 00 00                    # ph_flags: PF-X|PF-W|PF-R = 7
-01 00 00 00                    # ph_align
-
-# @60
-:ELF_program_header__data
-01 00 00 00                     # ph_type: PT-LOAD = 1
-00 00 00 00                     # ph_offset
-&ELF_base                       # ph_vaddr
-&ELF_base                       # ph_physaddr
-%ELF_end>ELF_base               # ph_filesz
-%ELF_end>ELF_base               # ph_memsz
-07 00 00 00                     # ph_flags: PF-X|PF-W|PF-R = 7
-01 00 00 00                     # ph_align
-
-# @80
-:ELF_comment
-4d 45 53 00                     # MES
-00 00 00 00                     # align
-00 00 00 00
-00 00 00 00
-
-4d 45 53 00                     # MES
-00 00 00 00                     # align
-00 00 00 00
-00 00 00 00
-
-# @a0
-:ELF_shstr
-00
-:ELF_shstr__text
-2e 74 65 78 74 00               # .text
-:ELF_shstr__data
-2e 64 61 74 61 00               # .data
-:ELF_shstr__comment
-2e 63 6f 6d 6d 65 6e 74 00      # .comment
-:ELF_shstr__shstr
-2e 73 68 73 74 72 74 61 62 00   # .shstrtab
-:ELF_shstr__sym
-2e 73 79 6d 74 61 62 00         # .symtab
-:ELF_shstr__str
-2e 73 74 72 74 61 62 00         # .strtab
-
-# @d0
-
-:ELF_section_headers
-00 00 00 00                     # sh_name
-00 00 00 00                     # sh_type
-00 00 00 00                     # sh_flags
-00 00 00 00                     # sh_addr
-00 00 00 00                     # sh_offset
-00 00 00 00                     # sh_length
-00 00 00 00                     # sh_link
-00 00 00 00                     # sh_info
-01 00 00 00                     # sh_1?
-00 00 00 00                     # sh_entsize
-
-## FIXME: M0 for calculations?
-:ELF_section_header_text
-%ELF_shstr__text>ELF_shstr      # sh_name
-01 00 00 00                     # sh_type = SHT_PROGBITS = 1
-06 00 00 00                     # sh_flags = SHF-ALLOC|SHF-EXEC =2 | 4 = 6
-&ELF_text                       # sh_addr
-%ELF_text>ELF_base              # sh_offset
-%ELF_data>ELF_text              # sh_length
-00 00 00 00                     # sh_link
-00 00 00 00                     # sh_info
-01 00 00 00                     # sh_1?
-00 00 00 00                     # sh_entsize
-
-:ELF_section_header_data
-%ELF_shstr__data>ELF_shstr     # sh_name
-01 00 00 00                    # sh_type = SHT_PROGBITS = 1
-03 00 00 00                    # sh_flags = SHF-WRITE|SHF-ALLOC = 1 | 2 = 3
-&ELF_data                      # sh_addr
-%ELF_data>ELF_base             # sh_offset
-%ELF_sym>ELF_data              # sh_length
-00 00 00 00                    # sh_link
-00 00 00 00                    # sh_info
-01 00 00 00                    # sh_1?
-00 00 00 00                    # sh_entsize
-
-:ELF_section_header_comment
-%ELF_shstr__comment>ELF_shstr  # sh_name
-01 00 00 00                    # sh_type = SHT_PROGBITS = 1
-00 00 00 00                    # sh_flags
-&ELF_comment                   # sh_addr
-%ELF_comment>ELF_base          # sh_offset
-%ELF_shstr>ELF_comment         # sh_length
-00 00 00 00                    # sh_link
-00 00 00 00                    # sh_info
-01 00 00 00                    # sh_1?
-00 00 00 00                    # sh_entsize
-
-:ELF_section_header_shstr
-%ELF_shstr__shstr>ELF_shstr    # sh_name
-03 00 00 00                    # sh_type: str-sht-strtab
-00 00 00 00                    # sh_flags
-&ELF_shstr                     # sh_addr
-%ELF_shstr>ELF_base            # sh_offset
-%ELF_section_headers>ELF_shstr # sh_length
-00 00 00 00                    # sh_link
-00 00 00 00                    # sh_info
-01 00 00 00                    # sh_1?
-00 00 00 00                    # sh_entsize
-
-:ELF_section_header_sym
-%ELF_shstr__sym>ELF_shstr      # sh_name
-02 00 00 00                    # sh_type: str-sht-symtab
-00 00 00 00                    # sh_flags
-&ELF_sym                       # sh_addr
-%ELF_sym>ELF_base              # sh_offset
-%ELF_end>ELF_sym               # sh_length
-06 00 00 00                    # sh_link:6
-00 00 00 00                    # sh_info
-01 00 00 00                    # sh_1?
-10 00 00 00                    # sh_entsize
-
-:ELF_section_header_str
-%ELF_shstr__str>ELF_shstr      # sh_name
-03 00 00 00                    # sh_type: str-sht-strtab
-00 00 00 00                    # sh_flags
-&ELF_str                       # sh_addr
-%ELF_str>ELF_base              # sh_offset
-%ELF_sym>ELF_str               # sh_length
-00 00 00 00                    # sh_link
-00 00 00 00                    # sh_info
-01 00 00 00                    # sh_1?
-00 00 00 00                    # sh_entsize
-
-# @1e8
-00 00 00 00  # align
-00 00 00 00
-
-# @1f0
-
-00 00 00 00  # align
-00 00 00 00
-00 00 00 00
-00 00 00 00
-
-# @200
-:ELF_text
diff --git a/stage0/elf32.hex3 b/stage0/elf32.hex3
deleted file mode 100644 (file)
index f937a3c..0000000
+++ /dev/null
@@ -1,86 +0,0 @@
-;;; -*-scheme-*-
-;;; Copyright (C) 2016 Jeremiah Orians
-;;; Copyright (C) 2017 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
-;;; This file is part of stage0.
-;;;
-;;; stage0 is free software: you an redistribute it and/or modify
-;;; it under the terms of the GNU General Public License as published by
-;;; the Free Software Foundation, either version 3 of the License, or
-;;; (at your option) any later version.
-;;;
-;;; stage0 is distributed in the hope that it will be useful,
-;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
-;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-;;; GNU General Public License for more details.
-;;;
-;;; You should have received a copy of the GNU General Public License
-;;; along with stage0.  If not, see <http://www.gnu.org/licenses/>.
-
-;;; elf32.hex3: 32 bit elf header in hex3
-
-;; ELF Header
-("*elf-header*"
-#X7F #x45 #X4C #x46           ; e_ident[EI_MAG0-3] ELF's magic number
-
-#x01                          ; e_ident[EI_CLASS] Indicating 32 bit
-#x01                          ; e_ident[EI_DATA] Indicating little endianness
-#x01                          ; e_ident[EI_VERSION] Indicating original elf
-
-#x00                          ; e_ident[EI_OSABI] Set at 0 because none cares
-#x00                          ; e_ident[EI_ABIVERSION] See above
-
-#x00 #x00 #x00 #x00 #x00 #x00 #x00  ; e_ident[EI_PAD]
-#x02 #x00                     ; e_type Indicating Executable
-#x03 #x00                     ; e_machine Indicating AMD64
-#x01 #x00 #x00 #x00           ; e_version Indicating original elf
-
-#x54 #x80 #x04 #x08           ; e_entry Address of the entry point
-#x34 #x00 #x00 #x00           ; e_phoff Address of program header table
-#x00 #x00 #x00 #x00           ; e_shoff Address of section header table
-
-#x00 #x00 #x00 #x00           ; e_flags
-#x34 #x00                     ; e_ehsize Indicating our 52 Byte header
-
-#x20 #x00                     ; e_phentsize size of a program header table
-#x01 #x00                     ; e_phnum number of entries in program table
-
-#x00 #x00                     ; e_shentsize size of a section header table
-#x00 #x00                     ; e_shnum number of entries in section table
-
-#x00 #x00                     ; e_shstrndx index of the section names
-
-;; Program Header
-#x01 #x00 #x00 #x00           ; p_type
-#x00 #x00 #x00 #x00           ; p_offset
-
-#x00 #x80 #x04 #x08           ; p_vaddr
-#x00 #x80 #x04 #x08           ; p_physaddr
-
-;; FIXME!
-;;#x60 #x00 #x00 #x00           ; p_filesz
-;;#x60 #x00 #x00 #x00           ; p_memsz
-
-;#x65 #x01 #x00 #x00           ; p_filesz
-;#x65 #x01 #x00 #x00           ; p_memsz
-
-#xff #xff #x00 #x00           ; p_filesz
-#xff #xff #x00 #x00           ; p_memsz
-
-
-#x07 #x00 #x00 #x00           ; p_flags
-#x01 #x00 #x00 #x00           ; alignment
-
-;; _start
-; exit (42) -- works!
-;#xbb #x2a #x00 #x00 #x00      ; mov    $42,%ebx
-;#xb8 #x01 #x00 #x00 #x00      ; mov    $0x1,%eax
-;#xcd #x80               ; int    $0x80
-)
-
-("shstr" 0
- #\. #\t #\e #\x #\t 0
- #\. #\d #\a #\t #\a 0
- #\. #\c #\o #\m #\m #\e #\n #\t 0
- #\. #\s #\h #\s #\t #\r #\t #\a #\b 0
- #\. #\s #\y #\m #\t #\a #\b 0
- #\. #\s #\t #\r #\t #\a #\b 0)
diff --git a/stage0/exit-42.c b/stage0/exit-42.c
deleted file mode 100644 (file)
index f4078b1..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-/* -*-comment-start: "//";comment-end:""-*-
- * Mes --- Maxwell Equations of Software
- * Copyright © 2017 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
- *
- * This file is part of Mes.
- *
- * Mes is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or (at
- * your option) any later version.
- *
- * Mes is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Mes.  If not, see <http://www.gnu.org/licenses/>.
- */
-
-int
-main (int argc, char *argv[])
-{
-  return 42;
-}
diff --git a/stage0/x86.M1 b/stage0/x86.M1
deleted file mode 100644 (file)
index 3c1e0f6..0000000
+++ /dev/null
@@ -1,232 +0,0 @@
-### Mes --- Maxwell Equations of Software
-### Copyright © 2017 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
-###
-### This file is part of Mes.
-###
-### Mes is free software# you can redistribute it and/or modify it
-### under the terms of the GNU General Public License as published by
-### the Free Software Foundation# either version 3 of the License, or (at
-### your option) any later version.
-###
-### Mes is distributed in the hope that it will be useful, but
-### WITHOUT ANY WARRANTY# without even the implied warranty of
-### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-### GNU General Public License for more details.
-###
-### You should have received a copy of the GNU General Public License
-### along with Mes.  If not, see <http://www.gnu.org/licenses/>.
-
-
-DEFINE add____$i32,%eax 05
-DEFINE add____$i32,%ecx 81c1
-DEFINE add____$i32,%edx 81c2
-DEFINE add____$i32,(%eax) 8100
-DEFINE add____$i32,0x32(%eax) 8180
-DEFINE add____$i32,0x32(%ebp) 8185
-DEFINE add____$i8,%eax 83c0
-DEFINE add____$i8,%edx 83c2
-DEFINE add____$i8,%esp 83c4
-DEFINE add____$i8,(%eax) 8300
-DEFINE add____$i8,0x32 8305
-DEFINE add____$i8,0x32(%eax) 8380
-DEFINE add____$i8,0x32(%eax) 8380
-DEFINE add____$i8,0x32(%ebp) 8385
-DEFINE add____$i8,0x8(%eax) 8340
-DEFINE add____$i8,0x8(%ebp) 8345
-DEFINE add____%eax,%eax 01c0
-DEFINE add____%ebp,%eax 01e8
-DEFINE add____%edx,%eax 01d0
-DEFINE add____%edx,%eax 01d0
-DEFINE and____$i32,%eax 25
-DEFINE and____%edx,%eax 21d0
-DEFINE and____(%edx),%eax 2302
-DEFINE call32 e8
-DEFINE call___*%eax ffd0
-DEFINE cmp____$0x32,%eax 3d
-DEFINE cmp____$i32,%eax 3d
-DEFINE cmp____$i32,0x32(%ebp) 81bd
-DEFINE cmp____$i32,0x8(%ebp) 817d
-DEFINE cmp____$i8,%eax 83f8
-DEFINE cmp____$i8,0x32(%ebp) 83bd
-DEFINE cmp____$i8,0x8(%ebp) 837d
-DEFINE cmp____%al,%dl 38c2
-DEFINE cmp____%edx,%eax 39d0
-DEFINE hlt f4
-DEFINE idiv___%ebx f7fb
-DEFINE int cd
-DEFINE int____$0x80 cd80
-DEFINE ja32  0f87
-DEFINE jae32 0f83
-DEFINE jb32  0f82
-DEFINE jbe32 0f86
-DEFINE je32 0f84
-DEFINE je8 74
-DEFINE jg32 0f8f
-DEFINE jge32 0f8d
-DEFINE jl32 0f8c
-DEFINE jle32 0f8e
-DEFINE jmp32 e9
-DEFINE jmp____*%ebx ffe3
-DEFINE jne32 0f85
-DEFINE lahf 9f
-DEFINE lea____0x32(%ebp),%eax 8d85
-DEFINE lea____0x32(%ebp),%edx 8d95
-DEFINE lea____0x8(%ebp),%eax 8d45
-DEFINE lea____0x8(%ebp),%edx 8d55
-DEFINE leave c9
-DEFINE mov____$i32,%eax b8
-DEFINE mov____$i32,%ebx bb
-DEFINE mov____$i32,%ecx b9
-DEFINE mov____$i32,%edx ba
-DEFINE mov____$i32,(%eax) c700
-DEFINE mov____$i32,0x32 c705
-DEFINE mov____$i32,0x8(%eax) c740
-DEFINE mov____$i32,0x8(%ebp) c745
-DEFINE mov____%al,(%edx) 8802
-DEFINE mov____%al,0x8(%edx) 8842
-DEFINE mov____%ax,(%edx) 668902
-DEFINE mov____%ax,0x32(%edx) 668982
-DEFINE mov____%ax,0x8(%edx) 668942
-DEFINE mov____%dl,(%eax) 8810
-DEFINE mov____%dl,0x8(%eax) 8850
-DEFINE mov____%eax,%ebx 89c3
-DEFINE mov____%eax,%edx 89c2
-DEFINE mov____%eax,(%ecx) 8901
-DEFINE mov____%eax,(%edx) 8902
-DEFINE mov____%eax,0x32 a3
-DEFINE mov____%eax,0x32(%ebp) 8985
-DEFINE mov____%eax,0x32(%edx) 8982
-DEFINE mov____%eax,0x8(%ebp) 8945
-DEFINE mov____%eax,0x8(%edx) 8942
-DEFINE mov____%ebp,%eax 89e8
-DEFINE mov____%ebp,%ecx 89e9
-DEFINE mov____%ebp,%edx 89ea
-DEFINE mov____%ebx,0x32 891d
-DEFINE mov____%ebx,0x32(%ebp) 899d
-DEFINE mov____%ebx,0x8(%ebp) 895d
-DEFINE mov____%ebx,0x8(%edx) 895a
-DEFINE mov____%ecx,(%eax) 8908
-DEFINE mov____%ecx,(%edx) 890a
-DEFINE mov____%ecx,0x32(%ebp) 898d
-DEFINE mov____%ecx,0x8(%ebp) 894d
-DEFINE mov____%edx,%eax 89d0
-DEFINE mov____%edx,%ebx 89d3
-DEFINE mov____%edx,%ecx 89d1
-DEFINE mov____%edx,(%eax) 8910
-DEFINE mov____%edx,0x32(%ebp) 8995
-DEFINE mov____%edx,0x8(%ebp) 8955
-DEFINE mov____%esp,%ebp 89e5
-DEFINE mov____(%eax),%eax 8b00
-DEFINE mov____(%eax),%ecx 8b08
-DEFINE mov____(%edx),%eax 8b02
-DEFINE mov____(%edx),%ecx 8b0a
-DEFINE mov____(%edx),%edx 8b12
-DEFINE mov____0x32(%eax),%eax 8b80
-DEFINE mov____0x32(%eax),%ebx 8b98
-DEFINE mov____0x32(%eax),%ecx 8b88
-DEFINE mov____0x32(%ebp),%eax 8b85
-DEFINE mov____0x32(%ebp),%eax 8b85
-DEFINE mov____0x32(%ebp),%ebx 8b9d
-DEFINE mov____0x32(%ebp),%ecx 8b8d
-DEFINE mov____0x32(%ebp),%edx 8b95
-DEFINE mov____0x32(%ebp),%edx 8b95
-DEFINE mov____0x32,%eax a1
-DEFINE mov____0x32,%edx 8b15
-DEFINE mov____0x8(%eax),%eax 8b40
-DEFINE mov____0x8(%eax),%ebx 8b58
-DEFINE mov____0x8(%eax),%ecx 8b48
-DEFINE mov____0x8(%ebp),%eax 8b45
-DEFINE mov____0x8(%ebp),%ebp 8b6d
-DEFINE mov____0x8(%ebp),%ebx 8b5d
-DEFINE mov____0x8(%ebp),%ecx 8b4d
-DEFINE mov____0x8(%ebp),%edx 8b55
-DEFINE mov____0x8(%ebp),%esp 8b65
-DEFINE movsbl_%al,%eax 0fbec0
-DEFINE movswl_%ax,%eax 0fbfc0
-DEFINE movzbl_%al,%eax 0fb6c0
-DEFINE movzbl_%al,%eax 0fb6c0
-DEFINE movzbl_%dl,%edx 0fb6d2
-DEFINE movzbl_(%eax),%eax 0fb600
-DEFINE movzbl_(%eax),%edx 0fb610
-DEFINE movzbl_(%edx),%edx 0fb612
-DEFINE movzbl_0x32(%eax),%eax 0fb680
-DEFINE movzbl_0x8(%eax),%eax 0fb640
-DEFINE movzbl_0x8(%ebp),%eax 0fb645
-DEFINE movzwl_%ax,%eax 0fb7c0
-DEFINE movzwl_(%eax),%eax 0fb700
-DEFINE movzwl_0x32(%eax),%eax 0fb780
-DEFINE movzwl_0x32(%ebp),%eax 0fb785
-DEFINE movzwl_0x8(%eax),%eax 0fb740
-DEFINE mul____%edx f7e2
-DEFINE nop 90
-DEFINE not____%eax f7d0
-DEFINE or_____%edx,%eax 09d0
-DEFINE or_____(%edx),%eax 0b02
-DEFINE pop____%eax 58
-DEFINE pop____%edx 5a
-DEFINE push___$i32 68
-DEFINE push___%eax 50
-DEFINE push___%ebp 55
-DEFINE push___%edx 52
-DEFINE push___(%eax) ff30
-DEFINE push___0x32(%ebp) ffb5
-DEFINE push___0x8(%ebp) ff75
-DEFINE ret c3
-DEFINE sahf 9e
-DEFINE seta___%al 0f97c0
-DEFINE setae__%al 0f93c0
-DEFINE setb___%al 0f92c0
-DEFINE setbe__%al 0f96c0
-DEFINE sete___%al 0f94c0
-DEFINE setg___%al 0f9fc0
-DEFINE setge__%al 0f9dc0
-DEFINE setl___%al 0f9cc0
-DEFINE setle__%al 0f9ec0
-DEFINE setne__%al 0f95c0
-DEFINE shl____$i8,%eax c1e0
-DEFINE shl____%cl,%eax d3e0
-DEFINE shr____%cl,%eax d3e8
-DEFINE sub____%al,%dl 28d0
-DEFINE sub____%dl,%al 28c2
-DEFINE sub____%eax,%edx 29c2
-DEFINE sub____%edx,%eax 29d0
-DEFINE sub____%edx,%eax 29d0
-DEFINE sub____%esp,$i32 81ec
-DEFINE sub____%esp,$i8 83ec
-DEFINE test___%al,%al 84c0
-DEFINE test___%eax,%eax 85c0
-DEFINE xchg___%eax,(%esp) 870424
-DEFINE xor____$i32,%eax 35
-DEFINE xor____$i8,%ah 80f4
-DEFINE xor____%eax,%eax 31c0
-DEFINE xor____%ebx,%ebx 31db
-DEFINE xor____%ecx,%ecx 31c9
-DEFINE xor____%edx,%eax 31d0
-DEFINE xor____%edx,%edx 31d2
-
-# Deprecated.  Remove after 0.14 release.
-DEFINE mov____%al,0x32(%ebp) 8885
-DEFINE mov____%al,0x8(%ebp) 8845
-DEFINE mov____%ax,0x32(%ebp) 668985
-DEFINE mov____%ax,0x8(%ebp) 668945
-DEFINE movzbl_0x32(%ebp),%eax 0fb685
-DEFINE movzbl_0x8(%ebp),%edx 0fb655
-DEFINE movzwl_0x8(%ebp),%eax 0fb745
-DEFINE movzwl_0x8(%ebp),%eax 0fb745
-
-DEFINE SYS_exit   01000000
-DEFINE SYS_fork   02000000
-DEFINE SYS_read   03000000
-DEFINE SYS_write  04000000
-DEFINE SYS_open   05000000
-DEFINE SYS_close  06000000
-DEFINE SYS_waitpid 07000000
-DEFINE SYS_unlink 0a000000
-DEFINE SYS_execve 0b000000
-DEFINE SYS_chmod  0f000000
-DEFINE SYS_lseek  13000000
-DEFINE SYS_access 21000000
-DEFINE SYS_brk    2d000000
-DEFINE SYS_ioctl  36000000
-DEFINE SYS_fsync  76000000
-DEFINE SYS_getcwd b7000000