IRC channel logs
2023-05-19.log
back to list of logs
<stikonas>janneke: got some partial success with scaffold/hello.c <stikonas>it compiles, runs and exists with 42 but didn't print anything <stikonas>so I will have to debug what went wrong with printing <stikonas>hmm, printing works if I comment out environ = envp in __init_io <stikonas>probably something wrong with crt1.c then... <stikonas>oh, it's actually variable padding that is broken... <stikonas>!0x00 is encoded to .00000000 which ends up being empty in binary <oriansj>stikonas, janneke wouldn't the syscall numbers be best defined in the C library and thus asm ("li_____%a7,SYS_write"); would become asm ("rd_a7 !" SYSCALL_WRITE " addi"); <oriansj>Irvise_: well rain1 did a bit of work with TCC to get it into a state where it could compile GCC again (it for a bit there lost that ability) <stikonas>oriansj: we do have them in syscall library <stikonas>oriansj: though at the moment C library defines them as #defines <stikonas>anyway, I don't think I'll resolve that mescc global variable padding issue today <stikonas>there is a hack to replace ! with % and overpad everything <oriansj>stikonas: no you missed what I am pointing out <oriansj>you just do #DEFINE SYSCALL_WRITE "64" <oriansj>inside of #ifdef block to determine what architecture uses which values <stikonas[m]>oriansj: anyway, the bigger issue is global variable padding with zeroes <oriansj>well we could switch it to the padding in M1 (aka <100 does 100 null bytes) <oriansj>but if the goal is to padd to alignment < will work <oriansj>but alignment support is required in hex2 and padding support is required in M1 <stikonas[m]>But it will print wither sizeof(var) of !0x00 or register size of !0x00 <oriansj>but it would probably simplify things as no need to loop to produce a block of !0x00 <stikonas[m]>And there is another function that converts numbers to M1... <stikonas[m]>Quite a bit different from how M2-Planet emits code... <stikonas[m]>Though after a few days it's getting a bit easier to write lisp... <oriansj>yeah, the hardest bit of using Lisp is just remembering the names and the varargs behavior of functions <sam_>glad it's not just me :) <janneke>"<stikonas> [23:45:25] janneke: got some partial success with scaffold/hello.c" <muurkha>hi joeyh_, thanks for writing git-annex and like a third of Debian <stikonas>oriansj, janneke: I think I found a reasonably nice way to write out those riscv syscalls <stikonas>oriansj's way didn't work I think because in mescc multiple strings are not concatenated, it has to be a single line string <stikonas>but I managed to sort it out using macros <stikonas>e.g. now it looks like asm(RISCV_SYSCALL(SYS_write)); <stikonas>#define MAKESTRING2(str) MAKESTRING(rd_a7 ! ## str addi) <stikonas>#define RISCV_SYSCALL(str) MAKESTRING2(str <stikonas>so this way we only need to have one canonical place for syscall numbers (just in syscall.h) <stikonas>well, there is probably another copy in m2 folder but that's unavoidable, M2-Planet is not capable of parsing such complex macros <stikonas>still need to deal with the other problem... <stikonas>that is adding zeroes to store global variables <stikonas>hmm, I think I should actually more or less port M2-Planet's padding/global variable initialization code to mescc...