run 32bit elf on aarch64

老子叫甜甜 提交于 2021-02-07 18:17:21

问题


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)


回答1:


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.



来源:https://stackoverflow.com/questions/51660401/run-32bit-elf-on-aarch64

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!