bug-mes
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug when using -- command line option


From: Gabriel Wicki
Subject: bug when using -- command line option
Date: Tue, 21 Dec 2021 14:52:03 +0100

hello


i'm (still) working on the riscv64 port of GNU MEScc but i think i've
stumbled upon a bug (but maybe i'm just doing it wrong).

i follow the steps described in live-bootstrap to build mes-m2, compile
crt1, libc-mini, libmescc, libc (see here:
https://github.com/fosslinux/live-bootstrap/blob/master/sysa/mes/mes.kaem#L43).

live-bootstrap alias-es the following:

alias mescc="${MES} --no-auto-compile -e main ${bindir}/mescc.scm -- -D 
HAVE_CONFIG_H=1 -I include -I include/linux/x86 -c"

when i use this alias (adapted to use for rv64) to compile for example
crt1.c the following (somewhat suspicious) things happen (i inserted
indicative comments at the very beginning and the very end):

 1. the first resulting file is called "-D.s", mescc then goes on to try
 to create a "-D.o" file from it (which of course fails)

 2. the header (i mean the part between the :_start label and the
 beginning of actual crt1.c code) and the footer (the part after crt1.c
 code ends until end of file) mysteriously are taken from x86's as.scm
 (or so i believe).  check the bottom for the (gory) details

 3. when compiling with "--" mescc tries to actually assemble a binary
 file (which of course fails because RV64 M1 and x86 M1 code are mixed).
 this doesn't happen when "--" is omitted.  the "--" option does not
 seem to be documented (?) and i seem to be unable to find it in the
 codebase.


i will happily provide patches/merge requests as soon as i've figured
out what's actually going on (and how to resolve it).

thanks for all kinds of indications/pointers/(helpful) comments and
such!

best wishes/kind regards and TIA
gabriel




my mescc compilation alias/script:
<<EOF
#/bin/env sh

RV64=/root/stage0-posix/riscv64
M2LIBC=/root/stage0-posix/M2libc/riscv64
# we need M1 binary in PATH (but not M2-Planet) and also guile (which ain't 
part of stage0)
PATH=$RV64/bin:$PATH
MESC_DEBUG=1

guile \
    -L /root/nyacc/module/               \
    -L /root/mes-m2/module/              \
    -e main                              \
    scripts/mescc.scm --                 \
    -D HAVE_CONFIG_H=1                   \
    -I include/                          \
    -I include/linux/riscv64/            \
    --arch=riscv64 --verbose             \
    -c $1
EOF


content of file "-D.s" (crt1.c compiled with -- command-line-option)
<<EOF
<
:_start
        push___%ebp
        mov____%esp,%ebp
        sub____$i32,%esp %0x1054
        # beginning of crt1.c
        RD_T0 $i16_000 @0 ADDI
        RD_T1 $i32 &__stdin ADDI
        RD_T0 RS1_T1 SW
        RD_T0 $i16_000 @1 ADDI
        RD_T0 !16 SRAI
        RD_T1 $i32 &__stdout ADDI
        RD_T0 RS1_T1 SW
        RD_T0 $i16_000 @2 ADDI
        RD_T0 !16 SRAI
        RD_T1 $i32 &__stderr ADDI
        RD_T0 RS1_T1 SW
        RS1_FP RD_T1 ADDI
        RD_T1 RS1_T1 $i8_8 !0x1 ADDI
        RD_T5 RS1_FP $i8_0 !0x1 ADDI
        RD_T0 RS1_T5 LD
        RD_T0 RS1_T0 !1 ADDI
        RD_T5 $i32 %0x3 ADDI
        RD_T0 RS1_T0 RS2_T5 SLL
        RD_T0 RS1_T0 RS2_T1 ADD
        RD_SP RS1_SP !-8 ADDI
        RD_T0 RS1_SP SD
        RD_SP RS1_SP !-8 ADDI
        RD_T1 RS1_SP SD
        RD_T1 $i32 &environ ADDI
        RD_T0 RS1_T1 SD
        RD_T5 RS1_FP $i8_0 !0x1 ADDI
        RD_T0 RS1_T5 LD
        RD_SP RS1_SP !-8 ADDI
        RD_T0 RS1_SP SD
        call32 %main
        add____$i8,%esp !0x0
        test___%eax,%eax
        RS1_T0 RD_A0 ADDI
        RD_A7 $SYS_exit ADDI
        RETURN
        #end of crt1.c
        leave
        ret
EOF

content of "crt1.s" (compiled without -- command-line-option)
<<EOF
<
:_start
        RD_SP RS1_SP !-24 ADDI
        RS1_SP RS2_FP SD
        RS1_SP RS2_RA @8 SD
        RS1_SP RS2_TP @16 SD
        RD_S0 RS1_SP !24 ADDI
        RD_SP %0x1054 ADDI
        # beginning of crt1.c
        RD_T0 $i16_000 @0 ADDI
        RD_T1 $i32 &__stdin ADDI
        RD_T0 RS1_T1 SW
        RD_T0 $i16_000 @1 ADDI
        RD_T0 !16 SRAI
        RD_T1 $i32 &__stdout ADDI
        RD_T0 RS1_T1 SW
        RD_T0 $i16_000 @2 ADDI
        RD_T0 !16 SRAI
        RD_T1 $i32 &__stderr ADDI
        RD_T0 RS1_T1 SW
        RS1_FP RD_T1 ADDI
        RD_T1 RS1_T1 $i8_8 !0x1 ADDI
        RD_T5 RS1_FP $i8_0 !0x1 ADDI
        RD_T0 RS1_T5 LD
        RD_T0 RS1_T0 !1 ADDI
        RD_T5 $i32 %0x3 ADDI
        RD_T0 RS1_T0 RS2_T5 SLL
        RD_T0 RS1_T0 RS2_T1 ADD
        RD_SP RS1_SP !-8 ADDI
        RD_T0 RS1_SP SD
        RD_SP RS1_SP !-8 ADDI
        RD_T1 RS1_SP SD
        RD_T1 $i32 &environ ADDI
        RD_T0 RS1_T1 SD
        RD_T5 RS1_FP $i8_0 !0x1 ADDI
        RD_T0 RS1_T5 LD
        RD_SP RS1_SP !-8 ADDI
        RD_T0 RS1_SP SD
        RD_A7 %main ADDI
        JAL
        RS1_T0 RD_T6 SLTIU
        RS1_T0 RD_A0 ADDI
        RD_A7 $SYS_exit ADDI
        RETURN
        #end of crt1.c
        RETURN
EOF



reply via email to

[Prev in Thread] Current Thread [Next in Thread]