简体   繁体   English

具有“System V”和“Linux”ABI 的 ELF 二进制文件是否相互兼容?

[英]Are ELF binaries with ABIs of 'System V' and 'Linux' mutually compatible?

TL;DR: My binary is unable to load /lib64/libm.so, and I don't know why. TL;DR:我的二进制文件无法加载 /lib64/libm.so,我不知道为什么。 Peering at the elves' fuzzy little headers, the only thing that looks like an incompatibility is the ABI number.看着精灵们模糊的小标题,唯一看起来不兼容的就是 ABI 编号。

Long form: Test run bombs claiming the binary is not found - but it exists.长格式:未找到声称二进制文件的试运行炸弹 - 但它存在。

[aardvark@aardvark-burrow ~/project-src] ldd  /data/users/aardvark/project-src/buck-out/gen/arvr/libraries/perception/calib/metrics/metrics_test
/data/users/aardvark/project-src/buck-out/gen/arvr/libraries/perception/calib/metrics/metrics_test: error while loading shared libraries: /lib64/libc.so: invalid ELF header

cat-ing /lib64/libm.so reveals: cat-ing /lib64/libm.so 显示:

/* GNU ld script
*/
OUTPUT_FORMAT(elf64-x86-64)
GROUP ( /lib64/libm.so.6  AS_NEEDED ( /usr/lib64/libmvec_nonshared.a /lib64/libmvec.so.1 ) )

Following the links to the bitter end, I get an ELF file.在链接到苦涩的结尾之后,我得到了一个 ELF 文件。 I read the header for that and for the binary which needs it, stuff 'em into text files, and diff those:我为此阅读了 header 以及需要它的二进制文件,将它们填充到文本文件中,然后区分它们:

[aardvark@aardvark-burrow ~/project-src] diff ~/logs/elf.ray_transport_test.txt ~/logs/elf.libm.txt 
--- /home/aardvark/logs/elf.ray_transport_test.txt  2021-12-06 11:34:40.843179878 -0800
+++ /home/aardvark/logs/elf.libm.txt    2021-12-06 11:33:50.264101198 -0800
@@ -1,20 +1,20 @@
 ELF Header:
-  Magic:   7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00 
+  Magic:   7f 45 4c 46 02 01 01 03 00 00 00 00 00 00 00 00 
   Class:                             ELF64
   Data:                              2's complement, little endian
   Version:                           1 (current)
-  OS/ABI:                            UNIX - System V
+  OS/ABI:                            UNIX - GNU 
   ABI Version:                       0
   Type:                              DYN (Shared object file)
   Machine:                           Advanced Micro Devices X86-64
   Version:                           0x1
-  Entry point address:               0x13220
+  Entry point address:               0xc520
   Start of program headers:          64 (bytes into file)
-  Start of section headers:          15936800 (bytes into file)
+  Start of section headers:          2189472 (bytes into file)
   Flags:                             0x0
   Size of this header:               64 (bytes)
   Size of program headers:           56 (bytes)
   Number of program headers:         9
   Size of section headers:           64 (bytes)
-  Number of section headers:         40
-  Section header string table index: 39
+  Number of section headers:         37
+  Section header string table index: 36

My VM id's itself through uname -a thus:我的 VM id 本身通过 uname -a 因此:

Linux aardvark-burrow.zoo.com 5.6.13-0_fbk17_hardened_5815_gc01d8dbd2635 #1 SMP Fri Jul 9 10:54:31 PDT 2021 x86_64 x86_64 x86_64 GNU/Linux

Is this why my executable is failing?这就是我的可执行文件失败的原因吗?

What else could be the problem?还有什么问题?

Your error message refers to /lib64/libc.so , not /lib64/libm.so .您的错误消息是指/lib64/libc.so ,而不是/lib64/libm.so

It looks like something is trying to load libc.so (and libm.so ) instead of loading libc.so.6 (and libm.so.6 ).看起来有些东西正在尝试加载libc.so (和libm.so而不是加载libc.so.6 (和libm.so.6 )。

Since the .so files are not ELF (they are linker scripts), of course trying to load them fails.由于.so文件不是ELF(它们是 linker 脚本),因此尝试加载它们当然会失败。

Assuming that the load is happening because readelf -d metrics_test | grep NEEDED | egrep 'lib(c|m)\.so$假设负载正在发生,因为readelf -d metrics_test | grep NEEDED | egrep 'lib(c|m)\.so$ readelf -d metrics_test | grep NEEDED | egrep 'lib(c|m)\.so$ readelf -d metrics_test | grep NEEDED | egrep 'lib(c|m)\.so$ is non-empty, the problem is that metrics_test is not linked correctly. readelf -d metrics_test | grep NEEDED | egrep 'lib(c|m)\.so$是非空的,问题是metrics_test没有正确链接。

In particular, when metrics_test was linked, it picked up some non-linker-script version of libc.so and libm.so .特别是,当metrics_test被链接时,它选择了一些非链接器脚本版本的libc.solibm.so

You can use -Wl,-t at link time to find out which libc.so and libm.so the linker picked up.您可以在链接时使用-Wl -Wl,-t来找出libc.so拾取的 libc.so 和libm.so

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM