gpt4 book ai didi

linux - 运行动态链接的 ARM 可执行文件时出现 "No such file or directory"错误

转载 作者:塔克拉玛干 更新时间:2023-11-03 01:18:39 37 4
gpt4 key购买 nike

我正在为运行 Ubuntu 15.04 的 ARM 嵌入式 Linux 平台进行交叉编译。该程序以前的静态链接版本运行良好。最近我需要链接 libproprietary(针对这个问题更改了 lib 名称),它只能作为 .so 提供。

libproprietary.so 有效;我能够运行依赖于它的不同程序。

$ uname -a
Linux <hostname> 3.10.92-71 #1 SMP PREEMPT Fri Dec 18 00:38:54 BRST 2015 armv7l armv7l armv7l GNU/Linux

问题:

$ ./myprogram
-bash: ./myprogram: No such file or directory

我尝试过的:

$ ldd ./myprogram
libproprietary.so.2 => /usr/lib/libproprietary.so.2 (0xb6bbc000)
librt.so.1 => /lib/arm-linux-gnueabihf/librt.so.1 (0xb6ba6000)
libpthread.so.0 => /lib/arm-linux-gnueabihf/libpthread.so.0 (0xb6b92000)
libusb-1.0.so.0 => /lib/arm-linux-gnueabihf/libusb-1.0.so.0 (0xb6b72000)
libstdc++.so.6 => /usr/lib/arm-linux-gnueabihf/libstdc++.so.6 (0xb6ab8000)
libm.so.6 => /lib/arm-linux-gnueabihf/libm.so.6 (0xb6a43000)
libc.so.6 => /lib/arm-linux-gnueabihf/libc.so.6 (0xb6955000)
/usr/lib/ld.so.1 => /lib/ld-linux-armhf.so.3 (0xb6f28000)
libgcc_s.so.1 => /lib/arm-linux-gnueabihf/libgcc_s.so.1 (0xb692c000)
libudev.so.1 => /lib/arm-linux-gnueabihf/libudev.so.1 (0xb690f000)

$ file ./myprogram
./myprogram: ELF 32-bit LSB executable, ARM, EABI5 version 1 (GNU/Linux), dynamically linked (uses shared libs), for GNU/Linux 2.6.32, BuildID[sha1]=881d76b2ce20f32aef95796b4fee9f01e492a7d2, not stripped
$ file /bin/ls
/bin/ls: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.32, BuildID[sha1]=a687c2baf9963c62c6abd209863d360dd0863686, stripped

$ readelf -l myprogram| grep interpreter
[Requesting program interpreter: /usr/lib/ld.so.1]

$ strace ./myprogram
execve("./myprogram", ["./myprogram"...], [/* 21 vars */]) = -1 ENOENT (No such file or directory)
write(2, "strace: exec: No such file or di"..., 40strace: exec: No such file or directory
) = 40
exit_group(1) = ?
+++ exited with 1 +++

$ ls -l myprogram
-rwxrwxr-x [details snipped]

$ file /usr/lib/libproprietary.so.<version>
/usr/lib/libproprietary.so.<version>: ELF 32-bit LSB shared object, ARM, EABI5 version 1 (SYSV), dynamically linked, BuildID[sha1]=d9b4ba3b9ec03779792984bc8a89ceede5737455, stripped

似乎解释器/usr/lib/ld.so.1 不存在。我猜它应该类似于/bin/ls 正在使用的内容:

$ readelf -l /bin/ls | grep interpreter
[Requesting program interpreter: /lib/ld-linux-armhf.so.3]

但是我不知道如何在我的链接步骤中解决这个问题。

ccache arm-linux-gnueabihf-g++ -o myprogram -static -Wl,--whole-archive -lpthread -Wl,--no-whole-archive -Wl,-no-undefined -pthread -Wl,-Bdynamic -lproprietary -Wl,-rpath-link=result/debug/lib -Wl,-rpath=\$ORIGIN/../../../../result/debug/lib variant-dir/debug/core-.o -Lresult/debug/lib -Wl,-Bstatic -l<other libs> 

我确实尝试在 core-.o 词之后移动 -Wl,-Bdynamic -lproprietary,但这并没有改变任何东西。

最佳答案

It appears that the interpreter, /usr/lib/ld.so.1, does not exist. I'm going to guess that it should be similar to what /bin/ls is using:

正确。您可以通过在链接时添加 -Wl,--dynamic-linker=/lib/ld-linux-armhf.so.3 标志来更改解释器。

但是,

  • 您的工具链所针对的 libc 版本可能与您实际安装的版本不同(在这种情况下,程序可能会崩溃)。
  • 如果它 以正确的 libc 为目标,那么您的工具链配置错误。

关于linux - 运行动态链接的 ARM 可执行文件时出现 "No such file or directory"错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47144933/

37 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com