Re: ELF binary type "0" not known. (while compiling buildworld on risc-v/qemu)

From: Jessica Clarke <jrtc27_at_freebsd.org>
Date: Mon, 27 Sep 2021 19:24:48 UTC
On 27 Sep 2021, at 20:22, John Baldwin <jhb@FreeBSD.org> wrote:
> 
> On 9/27/21 7:40 AM, Karel Gardas wrote:
>> Hello,
>> I'm playing with compiling freebsd 13 (releng/13.0 2 days ago) and
>> current (git HEAD as of today) on qemu-5.1.0/qemu-6.1.0 on risv64
>> platform. The emulator invocation is:
>> qemu-system-riscv64 -machine virt -smp 8 -m 16G -nographic -device
>> virtio-blk-device,drive=hd -drive
>> file=FreeBSD-14.0-CURRENT-riscv-riscv64.qcow2,if=none,id=hd -device
>> virtio-net-device,netdev=net -netdev user,id=net,hostfwd=tcp::2233-:22
>> -bios /usr/lib/riscv64-linux-gnu/opensbi/generic/fw_jump.elf -kernel
>> /usr/lib/u-boot/qemu-riscv64_smode/uboot.elf -object
>> rng-random,filename=/dev/urandom,id=rng -device
>> virtio-rng-device,rng=rng -nographic -append "root=LABEL=rootfs
>> console=ttyS0"
>> and the host is Ubuntu 20.04.x LTS. Both qemu 5.1.0 and qemu 6.1.0 are
>> compiled from, source, but both OpenSBI and u-boot for risc-v are Ubuntu
>> packages provided (to accompany ubuntu provided qemu 4.2.1)
>> My issue while compiling both 13 and current is that compilation after
>> some time fails with:
>> root@freebsd:/usr/src # time make -j8 buildworld > /tmp/build-j8-2.txt
>> ELF binary type "0" not known.
>> 17784.134u 21388.907s 1:50:13.83 592.2% 30721+572k 10+2177io 0pf+0w
>> I'm curious if this is a know issue either in Qemu or in FreeBSD for
>> risc-v or if I'm doing anything wrong here?
> 
> It is a known issue with how we brand FreeBSD/riscv binaries.  Jess
> (cc'd) has a WIP review with a possible fix IIRC.

https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=258358 and
https://reviews.freebsd.org/D31323. The latter needs reworking because
GCC doesn’t use all of our CSU files and instead provides its own that
we have no control over. The bug report documents a one-line workaround.

Jess