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.
This commit is contained in:
Paul Dersey 2021-02-02 09:28:19 -05:00
parent 9961c4b75f
commit b929dc84b4
4 changed files with 36 additions and 12 deletions

View file

@ -101,16 +101,16 @@ cd ${pkg}
kaem --file ${pkg}.kaem
cd ..
# Part 13: tcc-patched
cd tcc-0.9.27
kaem --file tcc-patched.kaem
cd ..
# Part 14: mes-libc-patched
# Part 13: mes-libc-patched
cd tcc-0.9.27
kaem --file mes-libc-patched.kaem
cd ..
# Part 14: tcc-patched
cd tcc-0.9.27
kaem --file tcc-patched.kaem
cd ..
# Part 15: make
pkg="make-3.80"
cd ${pkg}

View file

@ -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

View file

@ -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"