ABI incompatibility with C++ dynamic library

Hello!

I'm currently trying to link a Rust executable with a shared library written in C++ and C. The dynamic loading of the shared library works perfectly on amd64 architectures but I am running into segmentation fault errors when the executable tries to load the shared library on an aarch64 linux machine [Ubuntu 18.04.2 LTS (GNU/Linux 4.15.0-1033-raspi2 aarch64)].

I am using the Linaro aarch64 toolchain (http://releases.linaro.org/components/toolchain/binaries/latest-7/aarch64-linux-gnu/gcc-linaro-7.4.1-2019.02-x86_64_aarch64-linux-gnu.tar.xz) to cross-compile the shared library (combination of C++ and C code).

On inspection using file/readelf, the resultant shared library has the GNU/Linux ABI which seems to be because of the use of g++ to build the C++ code in the library whereas the ABI of the Rust executable is SYSV (cross compiled for aarch64 using the https://github.com/rust-embedded/cross project)

I’ve noticed that manually editing the .so file of the shared library to change the ABI flag from GNU/Linux to SYSV resolves the problem.

Is it possible to make either the executable or the library target a specific ABI? Ideally, I would like to build the Rust executable in a way so that it can link to the shared library irrespective of the library's ABI.

Please let me know if any additional details are required.

1 Like