在运行 64 位 linux 的 Armv8 (aarch64) 上编译并运行 32 位二进制文​​件

问题描述

我正在尝试使用 gcc 编译器在 Cortex-A72 Armv8 上编译和运行 32 位二进制文​​件,但我无法做到。我遵循了这个先前的线程 Having trouble compiling 32-bit binary on 64-bit linux armv8 machine 并且我也意识到 -m32 标志在 ARMv8 linux 机器上不受支持。
查看 https://gcc.gnu.org/onlinedocs/gcc/AArch64-Options.html 我没有发现任何有趣的东西。

根据 https://linux.die.net/man/1/arm-linux-gnu-gcc,AArch64 gcc 选项是:

-mbig-endian -mlittle-endian -mgeneral-regs-only -mcmodel=tiny -mcmodel=small -mcmodel=large -mstrict-align -momit-leaf-frame-pointer -mno-omit-leaf-frame-pointer -mtls-dialect=desc -mtls-dialect=traditional -march=name -mcpu=name -mtune=name

所以我的问题是:是否可以在 64 位 linux Armv8 机器上编译和运行 32 位二进制文​​件?是这样,怎么办?

谢谢。

编辑:https://jensd.be/1126/linux/cross-compiling-for-arm-or-aarch64-on-debian-or-ubuntu对我有用

解决方法

您可以从 Cortex-A toolchain Arm site 下载带有硬浮点 (arm-none-linux-gnueabihf) 工具链的 AArch32 目标。

存档文件名为 gcc-arm-10.2-2020.11-aarch64-arm-none-linux-gnueabihf.tar.xz,位于 AArch64 Linux 托管交叉编译器部分。

您可能需要在 Aarch64 系统上安装其他软件包 - 搜索如何在 64 位 (arm64) 上运行 32 位 (armhf) 二进制文件和您的 Linux 发行版名称。

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...