commit: b929dc84b46e45ece903a331883e06ae4f16493c
parent 9961c4b75fdd9dfd5f91288076418138c98b38ae
Author: Paul Dersey <pdersey@gmail.com>
Date: Tue, 2 Feb 2021 09:28:19 -0500
Fix mes-libc crt1 to allow commands with greater than 255 arguments to run
Also reverse order of tcc-patched and mes-libc-patched stages.
Diffstat:
4 files changed, 34 insertions(+), 10 deletions(-)
diff --git a/README.md b/README.md
@@ -208,7 +208,12 @@ is required later for autotools.
more complex edits, including just changes to lines. Luckily, we are able to
patch patch using sed only.
-#### Part 13: patched tinycc
+#### Part 13: patched mes-libc
+
+Since patch is available at this point, we can apply additional fixes to
+mes-libc that are not included in the wip-m2 branch and recompile libc.
+
+#### Part 14: patched tinycc
In Guix, tinycc is patched to force static linking. Prior to this step, we have
been forced to manually specify static linking for each tool. Now that we have
@@ -217,11 +222,6 @@ patch, we can patch tinycc to force static linking and then recompile it.
Note that we have to do this using tinycc 0.9.26, as tinycc 0.9.27 cannot
recompile itself for unknown reasons.
-#### Part 14: patched mes-libc
-
-Since patch is available at this point, we can apply additional fixes to
-mes-libc that are not included in the wip-m2 branch and recompile libc.
-
#### Part 15: make 3.80
GNU `make` is now built so we have a more robust building system. `make` allows
diff --git a/sysa/after.kaem.run b/sysa/after.kaem.run
@@ -101,14 +101,14 @@ cd ${pkg}
kaem --file ${pkg}.kaem
cd ..
-# Part 13: tcc-patched
+# Part 13: mes-libc-patched
cd tcc-0.9.27
-kaem --file tcc-patched.kaem
+kaem --file mes-libc-patched.kaem
cd ..
-# Part 14: mes-libc-patched
+# Part 14: tcc-patched
cd tcc-0.9.27
-kaem --file mes-libc-patched.kaem
+kaem --file tcc-patched.kaem
cd ..
# Part 15: make
diff --git a/sysa/tcc-0.9.27/mes-libc-patched.kaem b/sysa/tcc-0.9.27/mes-libc-patched.kaem
@@ -6,6 +6,7 @@ cd src/mes-libc
# Patch
patch -Np0 -i ../../patches/mes-libc-qsort.patch
+patch -Np0 -i ../../patches/mes-libc-crt1.patch
# Recompile libc
cd ../tcc-0.9.27
diff --git a/sysa/tcc-0.9.27/patches/mes-libc-crt1.patch b/sysa/tcc-0.9.27/patches/mes-libc-crt1.patch
@@ -0,0 +1,23 @@
+Fix issue in mes-libc crt where argc was getting truncated to lower byte and
+prevented programs with more than 255 arguments from working correctly.
+
+--- lib/linux/x86-mes-gcc/crt1.c
++++ lib/linux/x86-mes-gcc/crt1.c
+@@ -48,7 +48,7 @@ _start ()
+ asm (
+ "mov %%ebp,%%eax\n\t"
+ "add $4,%%eax\n\t"
+- "movzbl (%%eax),%%eax\n\t"
++ "mov (%%eax),%%eax\n\t"
+ "add $3,%%eax\n\t"
+ "shl $2,%%eax\n\t"
+ "add %%ebp,%%eax\n\t"
+@@ -64,7 +64,7 @@ _start ()
+
+ "mov %ebp,%eax\n\t"
+ "add $4,%eax\n\t"
+- "movzbl (%eax),%eax\n\t"
++ "mov (%eax),%eax\n\t"
+ "push %eax\n\t"
+
+ "call main\n\t"