【发布时间】:2022-01-01 09:39:41
【问题描述】:
我在进行二进制分析时有一个问题。对于已为 ARM 架构识别的给定 ELF 文件 (hello.elf),我如何快速知道此 ELF 是用于 Cortex-A 还是 Cortex-M? 更具体地说,我' m 试图识别 Cortex-M 的整个裸机映像(或 RTOS 映像,如 FreeRTOS)。
来自file hello.elf的结果:
% file hello.elf
hello.elf: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), statically linked, with debug_info, not stripped
我们只能看到这个ELF是给ARM的。
而从readelf -h ./hello.elf的结果来看:
% readelf -h ./hello.elf
ELF Header:
Magic: 7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00
Class: ELF32
Data: 2's complement, little endian
Version: 1 (current)
OS/ABI: UNIX - System V
ABI Version: 0
Type: EXEC (Executable file)
Machine: ARM
Version: 0x1
Entry point address: 0xcb5
Start of program headers: 52 (bytes into file)
Start of section headers: 150896 (bytes into file)
Flags: 0x5000200, Version5 EABI, soft-float ABI
Size of this header: 52 (bytes)
Size of program headers: 32 (bytes)
Number of program headers: 5
Size of section headers: 40 (bytes)
Number of section headers: 19
Section header string table index: 17
它也仅显示此文件适用于 ARM 架构。 那么有没有其他方法可以快速识别ELF文件的目标架构呢?
【问题讨论】:
-
是什么让您认为它必须只适用于其中一个?您可以通过检查存在的部分名称或使用 objdump 反汇编并查找向量表来轻松判断它是否是 Cortex-M 的完整裸机映像,但在操作系统下运行的可执行文件可能更难以区分甚至兼容两者都有。
-
@TomV 你能给我更多关于如何做前一个的细节吗?我正在寻找 Cortex-M 的整个裸机映像(或 RTOS 映像,如 FreeRTOS)。
-
arm-none-eabi-objdump -h hello.elf查找名为.vectors或类似名称的部分。arm-none-eabi-nm hello.elf也可能会告诉您一些有用的信息。
标签: arm executable elf cortex-m cortex-a