gpt4 book ai didi

linux - 使用带有 qemu-arm 的动态链接器

转载 作者:行者123 更新时间:2023-12-04 17:40:20 24 4
gpt4 key购买 nike

我有一个使用 arm-linux-gnueabi 编译的非常简单的 arm 可执行文件工具链。我可以用 qemu-arm 执行它没有任何问题:

$ qemu-arm -L /usr/arm-linux-gnueabi/ ./a.out
Hello world !

不带任何参数运行链接器似乎也能正常工作:
qemu-arm /usr/arm-linux-gnueabi/lib/ld-linux.so.3
Usage: ld.so [OPTION]... EXECUTABLE-FILE [ARGS-FOR-PROGRAM...]
You have invoked `ld.so', the helper program for shared library executables.
...

但是,如果我希望链接器运行我的可执行文件,则会发生以下情况:
$ qemu-arm -L /usr/arm-linux-gnueabi/ /usr/arm-linux-gnueabi/lib/ld-linux.so.3 a.out
a.out: error while loading shared libraries: a.out: cannot open shared object file

这是 strace 的输出: https://pastebin.com/uJ7AhBdh

知道为什么会这样吗?

最佳答案

我无法在 Ubuntu 20.04 上重现该问题:

sudo apt install gcc-arm-linux-gnueabihf qemu-user
printf '
#include <stdio.h>
#include <stdlib.h>

int main() {
puts("hello world");
return EXIT_SUCCESS;
}
' > hello_world.c
qemu-arm -L /usr/arm-linux-gnueabihf ./hello_world
和 aarch64:
sudo apt install gcc-aarch64-linux-gnu qemu-user
aarch64-linux-gnu-gcc -ggdb3 -static -o hello_world hello_world.c
qemu-aarch64 -L /usr/aarch64-linux-gnu ./hello_world
两者都运行良好。
您还可以提供您的确切发行版吗?
与 GDB 步骤调试相关: How to GDB step debug a dynamically linked executable in QEMU user mode?

关于linux - 使用带有 qemu-arm 的动态链接器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54802670/

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