proot-me / proot

chroot, mount --bind, and binfmt_misc without privilege/setup for Linux
https://proot-me.github.io
GNU General Public License v2.0
1.96k stars 369 forks source link

loongarch: add loongarch64 support for proot #382

Open lrzlin opened 2 months ago

lrzlin commented 2 months ago

add loongarch64 support.

To make it function correctly, we need to disable -O2 optimization in GNUmakefile or using __attribute__((optimize("O2"))) in loader.c _start function, same as the riscv64 port. Also, we can not using gdb in proot, it will crash directly on kernel version 6.x, or failed to run on kernel 4.19.

Update: After fixingassembly-loongarch.h according the way nolibc build its syscall macro, which is add $t0~$t8 to clobber list and make result from =r (read-only) to +r (read write), now proot can run correctly under O2 optimize level.

Reference: LoongArch nolibc header: https://github.com/torvalds/linux/blob/master/tools/include/nolibc/arch-loongarch.h