Hi,
I am having problems linking statically using the RISCV linux/glibc toolchain.
I then used clang to compile a simple program:
> echo "void main() {}" > a.c
> clang -target riscv32 a.c -nostdlib -static
Here's my link line:
> GCC=<Path to RISCV linux/glibc toolchain>
> "$GCC/bin/riscv32-ld" --sysroot=$GCC/sysroot $GCC/sysroot/usr/lib32/ilp32/crt1.o $GCC/lib/gcc/riscv32-unknown-linux-gnu/7.2.0/crtbegin.o -L$GCC/sysroot/usr/lib32/ilp32 -L$GCC/lib/gcc/riscv32/7.2.0 -L$GCC/sysroot/lib a.o --start-group -lc --end-group -lgcc $GCC/lib/gcc/riscv32-unknown-linux-gnu/7.2.0/crtend.o -o a.out
This always produces a dynamic exe.
> file a.out
a.out: ELF 32-bit LSB executable, UCB RISC-V, version 1 (SYSV), dynamically linked, interpreter /lib32/ld.so.1, for GNU/Linux 3.0.0, not stripped
Forcing -static on the link line produces undefined reference errors:
> "$GCC/bin/riscv32-ld" -static --sysroot=$GCC/sysroot $GCC/sysroot/usr/lib32/ilp32/crt1.o $GCC/lib/gcc/riscv32-unknown-linux-gnu/7.2.0/crtbegin.o -L$GCC/sysroot/usr/lib32/ilp32 -L$GCC/lib/gcc/riscv32/7.2.0 -L$GCC/sysroot/lib a.o --start-group -lc --end-group -lgcc $GCC/lib/gcc/riscv32-unknown-linux-gnu/7.2.0/crtend.o -o a.out
ERROR: riscv-gnu-toolchain/riscv-glibc/libio/iofclose.c:73: undefined reference to `_Unwind_Resume'
However, with the RISCV elf/newlib toolchain I am able to link statically without problems.
Can someone please help?
--Mandeep