在 aarch64 上运行 32 位精灵 [英] run 32bit elf on aarch64

查看:82
本文介绍了在 aarch64 上运行 32 位精灵的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在 qemu 64 位 ARM 上安装了 Debian (遵循本教程)

uname -a

<块引用>

Linux 测试 4.9.0-7-arm64 #1 SMP Debian 4.9.110-1 (2018-07-05) aarch64 GNU/Linux

我正在尝试在其上运行 32 位 elf 文件,但有些工作不能:

<块引用>

bash: ./file_2: 无法执行二进制文件:Exec 格式错误

在运行的文件上运行文件命令,我得到:

<块引用>

file_1:ELF 32 位 LSB 可执行文件,ARM,EABI4 版本 1 (SYSV),静态链接,未剥离

和不运行的那个:

<块引用>

file_2:ELF 32 位 LSB 可执行文件,ARM,版本 1 (ARM),静态链接,剥离

并且都适用于 32 位系统(armv7l)

唯一的区别是SYSV/ARM版本.

不重新编译内核有什么解决办法吗?(阅读这篇文章)

解决方案

正如链接的帖子所暗示的那样,这需要在内核中启用 CONFIG_COMPAT.另一方面,如果您的内核没有它,我会感到惊讶——我在该教程中获得的 Debian 4.9.0-4 内核确实设置了 CONFIG_COMPAT.您可以通过查看它的配置文件来检查您的内核是否启用了它,该文件将位于来宾的/boot/中.如果它丢失了,那么您需要一个新内核,没有其他任何帮助.

但是在您的情况下,您确实有 CONFIG_COMPAT,并且一些可执行文件可以工作.有效和无效的区别在于,有效的是 EABI,非有效的是 OABI.OABI 是用于 32 位 Arm Linux 二进制文件的旧的和过时的 ABI(O"代表旧的",十多年来它一直是一个糟糕的选择......)并且它不受 64 位的支持内核的 CONFIG_COMPAT.如果您想在 64 位内核下运行这些二进制文件,则需要将这些二进制文件从源代码重建为 EABI 二进制文件.

I have installed Debian on qemu 64-bit ARM (followed this tutorial)

uname -a

Linux test 4.9.0-7-arm64 #1 SMP Debian 4.9.110-1 (2018-07-05) aarch64 GNU/Linux

and I am trying to run 32 bit elf files on it, but some work some don't:

bash: ./file_2: cannot execute binary file: Exec format error

running file command on the file that runs, I get:

file_1: ELF 32-bit LSB executable, ARM, EABI4 version 1 (SYSV), statically linked, not stripped

and the one that does not run:

file_2: ELF 32-bit LSB executable, ARM, version 1 (ARM), statically linked, stripped

and both work on 32bit system(armv7l)

the only difference is that SYSV/ARM version.

is there any work around without recompiling the kernel?(read this post)

解决方案

As the linked post suggests, this requires CONFIG_COMPAT to be enabled in the kernel. On the other hand I would be surprised if your kernel didn't have it -- the Debian 4.9.0-4 kernel I have from doing that tutorial does set CONFIG_COMPAT. You can check whether your kernel has it enabled by looking at the config file for it which will be in /boot/ in the guest. If it's missing then you need a new kernel, and nothing else will help.

However in your case you do have CONFIG_COMPAT, and some executables work. The difference between the ones that work and the ones that don't is that the working ones are EABI, and the non-working ones are OABI. OABI is an old and obsolete ABI for 32-bit Arm Linux binaries (the "O" stands for "old", and it's been a bad choice for a decade or so...) and it is not supported by the 64-bit kernel's CONFIG_COMPAT. You'll need to rebuild those binaries from source as EABI binaries if you want to run them under a 64-bit kernel.

这篇关于在 aarch64 上运行 32 位精灵的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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