RISC-V 64bit and 32bit binaries on the same system

Andreas K. Hüttel dilfridge@gentoo.org
Mon Sep 7 13:32:39 GMT 2020


Hi all, 

as you probably know, the gcc multilib settings for riscv build and install 4 
ABI (rv64/lp64d, rv64/lp64, rv32/ilp32d, rv32/ilp32). Now that rv32 support is 
in glibc, I gave this a try (*) in qemu-user. 

gcc and glibc build and install fine. However, there's a fundamental problem 
with this configuration. ld.so does not filter by ELFCLASS (as it does, e.g., 
for x64-64 vs i686), and the order of directories in the dynamic linker config 
determines e.g. which libstdc++ a binary sees first. [#]

Which means, either rv32 or rv64 binaries will terminate with a "wrong 
ELFCLASS" fatal error.

Now, what to do?

* Introduce a special cache flag as for x86-64 FLAG_X8664_LIB64?

* Make ld.so ignore wrong-ELFCLASS binaries instead of producing an error? 
(Same result handled at different point...)

* Propose to change the gcc multilib profiles so we don't pretend that this 
works?

Cheers, 
Andreas


(*) I know that there is no real hardware that can run both rv64 and rv32 at 
the moment. However, it would be useful for me to bootstrap different single-
ABI environments.

[#]
(riscv-main chroot) farino /lib # ldconfig -p|grep c++
        libstdc++.so.6 (libc6,double-float) => /usr/lib/gcc/riscv64-unknown-
linux-gnu/10.2.0/lib64/lp64d/libstdc++.so.6
        libstdc++.so.6 (libc6,double-float) => /usr/lib/gcc/riscv64-unknown-
linux-gnu/10.2.0/lib32/ilp32d/libstdc++.so.6
        libstdc++.so.6 (libc6,soft-float) => /usr/lib/gcc/riscv64-unknown-
linux-gnu/10.2.0/lib64/lp64/libstdc++.so.6
        libstdc++.so.6 (libc6,soft-float) => /usr/lib/gcc/riscv64-unknown-
linux-gnu/10.2.0/lib32/ilp32/libstdc++.so.6
        libstdc++.so (libc6,double-float) => /usr/lib/gcc/riscv64-unknown-
linux-gnu/10.2.0/lib64/lp64d/libstdc++.so
        libstdc++.so (libc6,double-float) => /usr/lib/gcc/riscv64-unknown-
linux-gnu/10.2.0/lib32/ilp32d/libstdc++.so
        libstdc++.so (libc6,soft-float) => /usr/lib/gcc/riscv64-unknown-linux-
gnu/10.2.0/lib64/lp64/libstdc++.so
        libstdc++.so (libc6,soft-float) => /usr/lib/gcc/riscv64-unknown-linux-
gnu/10.2.0/lib32/ilp32/libstdc++.so

versus

farino ~ # ldconfig -p |grep c++
        libstdc++.so.6 (libc6,x86-64) => /usr/lib/gcc/x86_64-pc-linux-gnu/
9.3.0/libstdc++.so.6
        libstdc++.so.6 (libc6) => /usr/lib/gcc/x86_64-pc-linux-gnu/9.3.0/32/
libstdc++.so.6
        libstdc++.so (libc6,x86-64) => /usr/lib/gcc/x86_64-pc-linux-gnu/9.3.0/
libstdc++.so
        libstdc++.so (libc6) => /usr/lib/gcc/x86_64-pc-linux-gnu/9.3.0/32/
libstdc++.so
        libnetcdf_c++.so.4 (libc6,x86-64) => /usr/lib64/libnetcdf_c++.so.4
        libnetcdf_c++.so (libc6,x86-64) => /usr/lib64/libnetcdf_c++.so


-- 
Andreas K. Hüttel
dilfridge@gentoo.org
Gentoo Linux developer 
(council, qa, toolchain, base-system, perl, libreoffice)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 963 bytes
Desc: This is a digitally signed message part.
URL: <https://sourceware.org/pipermail/libc-alpha/attachments/20200907/4fcb3be9/attachment.sig>


More information about the Libc-alpha mailing list