使用带有 qemu-arm 的动态链接器 [英] Using dynamic linker with qemu-arm

查看:28
本文介绍了使用带有 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?

GDB 步骤调试相关:如何在 QEMU 用户模式下 GDB 逐步调试动态链接的可执行文件?

Reletated for GDB step debug: How to GDB step debug a dynamically linked executable in QEMU user mode?

这篇关于使用带有 qemu-arm 的动态链接器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆