将动态链接器与qemu-arm一起使用 [英] Using dynamic linker with qemu-arm
问题描述
我有一个使用 arm-linux-gnueabi
工具链编译的非常简单的arm可执行文件.我可以使用 qemu-arm
执行它,而不会出现任何问题:
I have a very simple arm executable compiled with the arm-linux-gnueabi
toolchain. I can execute it with qemu-arm
without any problem:
$ qemu-arm -L /usr/arm-linux-gnueabi/ ./a.out
Hello world !
运行没有任何参数的链接器似乎也可以:
Running the linker without any argument seems to work as well:
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.
...
但是,如果我希望链接程序运行我的可执行文件,则会发生以下情况:
However if I want the linker to run my executable, here is what happens:
$ 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
Here is the output of strace: https://pastebin.com/uJ7AhBdh
知道为什么会这样吗?
推荐答案
我无法在Ubuntu 20.04上重现该问题:
I can't reproduce the problem on 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
都很好.
您还可以提供确切的发行版吗?
Can you also provide your exact distro version?
Reletated for GDB step debug: How to GDB step debug a dynamically linked executable in QEMU user mode?
这篇关于将动态链接器与qemu-arm一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!