From 198d4a652dc53f014f5a3c57d727400a392e9786 Mon Sep 17 00:00:00 2001 From: Jan Nieuwenhuizen Date: Sun, 26 May 2019 09:36:57 +0200 Subject: [PATCH] mescc: Mes C Library: Fixes for x86_64 crt1.c * lib/linux/x86_64-mes/crt1.c (_start): Write only 4 bytes to int variables __stdin, __stdout, __stderr. --- lib/linux/x86_64-mes-gcc/crt1.c | 12 ++++++------ lib/linux/x86_64-mes/crt1.c | 6 +++--- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/linux/x86_64-mes-gcc/crt1.c b/lib/linux/x86_64-mes-gcc/crt1.c index fa066950..0000d7bf 100644 --- a/lib/linux/x86_64-mes-gcc/crt1.c +++ b/lib/linux/x86_64-mes-gcc/crt1.c @@ -29,22 +29,22 @@ void _start () { asm ( - "mov $0,%%rax\n\t" - "mov %%rax,%0\n" + "mov $0,%%eax\n\t" + "mov %%eax,%0\n" : "=r" (__stdin) : //no inputs "" ); asm ( - "mov $1,%%rax\n\t" - "mov %%rax,%0\n" + "mov $1,%%eax\n\t" + "mov %%eax,%0\n" : "=r" (__stdout) : //no inputs "" ); asm ( - "mov $2,%%rax\n\t" - "mov %%rax,%0\n" + "mov $2,%%eax\n\t" + "mov %%eax,%0\n" : "=r" (__stderr) : //no inputs "" ); diff --git a/lib/linux/x86_64-mes/crt1.c b/lib/linux/x86_64-mes/crt1.c index 0161c93b..35d33c27 100644 --- a/lib/linux/x86_64-mes/crt1.c +++ b/lib/linux/x86_64-mes/crt1.c @@ -25,13 +25,13 @@ int _start () { asm ("mov____$i8,%rax !0"); - asm ("mov____%rax,0x32 &__stdin"); + asm ("movl___%eax,0x32 &__stdin"); asm ("mov____$i8,%rax !1"); - asm ("mov____%rax,0x32 &__stdout"); + asm ("movl___%eax,0x32 &__stdout"); asm ("mov____$i8,%rax !2"); - asm ("mov____%rax,0x32 &__stderr"); + asm ("movl___%eax,0x32 &__stderr"); #if 0 //MES_CCAMD64 asm ("add____$i32,%rbp %0x80"); // FIXME: corresponds to x86_64/as.scm function-preamble-fu