endrazine / wcc

The Witchcraft Compiler Collection
Other
1.84k stars 107 forks source link

ARM Compilation broken #25

Closed unusual-thoughts closed 5 years ago

unusual-thoughts commented 7 years ago

Compilation fails on arm systems unless '-masm=intel' is removed from compile flags in Makefile.

This is an x86-only gcc option apparently: http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20140512/105322.html

Also I need to change src/wsh/script.lds with system version from /usr/lib/ldscripts/armelf_linux_eabi.xc (and probably change some addresses?), or remove the link script entirely from build flags.

Either way, wsh segfaults once built inside of my arm chroot:

wsh /bin/ls
init
open: Cannot allocate memory
WARNING: No binary loaded in memory. Try loadbin(). For help type help("loadbin").
WARNING: No binary loaded in memory. Try loadbin(). For help type help("loadbin").
ERROR: State not recoverable (131)
ERROR: State not recoverable (131)
ERROR: State not recoverable (131)
ERROR: State not recoverable (131)
ERROR: State not recoverable (131)
ERROR: State not recoverable (131)
ERROR: State not recoverable (131)
ERROR: State not recoverable (131)
ERROR: State not recoverable (131)
ERROR: State not recoverable (131)
> loadbin('/bin/sh')�(����r���r���r���r���r���r���r���r�
ERROR: dlopen() /bin/sh: cannot dynamically load executable 
 ** libifying /bin/sh to //tmp/.wsh-29291/sh (697468 bytes)
qemu-arm-static: /build/qemu-VyWqJ2/qemu-2.8+dfsg/translate-all.c:175: tb_lock: Assertion `!have_tb_lock' failed.
qemu-arm-static: /build/qemu-VyWqJ2/qemu-2.8+dfsg/translate-all.c:175: tb_lock: Assertion `!have_tb_lock' failed.
Segmentation fault (core dumped)

I saw you removed the arm-specific makefile, is arm not supported anymore?

endrazine commented 5 years ago

Hi unusual-thoughts, I removed the Makefile until we build generically using libtool. The first errors can be safely ignored : they relate to witchcraft scripts called at boot time that call some syscall that is not supported within the translation via qemu (which is what I assume you're using ?). The final segfault comes from the fact that /bin/sh is a ET_EXEC and not a share library. You would have had to transform it into a share library using wld first. This has been fixed in the latest versions of wsh, that will do this for you automatically. Thanks !