对于ARM ELF脚本/工具predicate编译为Thumb或ARM [英] Script/Tool predicate for ARM ELF compiled for Thumb OR Arm

查看:188
本文介绍了对于ARM ELF脚本/工具predicate编译为Thumb或ARM的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的根文件系统 klibc 文件系统。我创建制作规则和一些开发商有没有联网间旧的编译器。注1 我试图验证所有的文件遭到内置手臂检测编译器的某个版本,只有当。我已经重新建立了树的好几倍。我使用 readelf -A 并寻找 Tag_THUMB_ISA_use:拇指-1 ,但这似乎是在手臂仅code(但与互通编译器内置),以及拇指 code。我可以手动运行 objdump的-S​​ 并检查汇编程序,以确定是什么用的指令集。

I have rootfs and klibc file systems. I am creating make rules and some developers have an older compiler without inter-networking.note1 I am trying to verify that all the files get built with arm only when a certain version of the compiler is detected. I have re-built the tree's several times. I was using readelf -A and looking for Tag_THUMB_ISA_use: Thumb-1, but this seem to be in arm only code (but was built with the interworking compiler) as well as thumb code. I can manually run objdump -S and examine the assembler to determine what instruction set is in use.

不过,这将是,如果我有一个脚本/工具predicate让查找等可用于通过的阴影搜索更容易的文件系统,以寻找可能已经错过二进制文件。我认为一些这方面的信息将在 ELF 头而且您可以通过 objdump的 readelf ,但我没有发现任何可靠的。

However, it would be much easier if I had a script/tool predicate so that find, etc can be used to search through the shadow file systems to look for binaries that may have been missed. I thought that some of this information would be in the ELF header and accessible via objdump or readelf, but I haven't found anything reliable.

具体来说,我正在寻找,

Specifically I am looking for,


  1. 编译'C',不会没有 CONFIG_ARM_THUMB Linux系统上运行。

  2. 使用该呛非拇指的编译器C编译器的标志。
  3. 制作规则
  1. Compiled 'C' that wouldn't run without a CONFIG_ARM_THUMB Linux system.
  2. make rules that use 'C' compiler flags that choke a non-thumb compilers.

注1:互通让拇指手臂模式之间轻松切换,而编译器会自动生成code支持来自两种模式下调用。

note1: Interworking allow easy switching between thumb and arm modes, and the compiler will automatically generate code to support calling from either mode.

推荐答案

readelf -A 输出没有描述在精灵内容。它只是描述的能力的处理的和或的系统的,预计或饲料的编译器。因为我有一个 ARM926 CPU这是一个可用于ARMv5TEJ 处理器,GCC /劳工处会总是设置 Tag_THUMB_ISA_use:拇指-1 ,因为它只是意味着可用于ARMv5TEJ 被认可为的Thumb-1 能力。它只字未提code本身。

The readelf -A output doesn't describe the elf contents. It just describes the capabilities of the processor and or system that is expected or feed to the compiler. As I have an ARM926 CPU which is an ARMV5TEJ processor, gcc/ld will always set Tag_THUMB_ISA_use: Thumb-1 as it just means that ARMV5TEJ is recognized as being Thumb-1 capable. It says nothing about the code itself.

审视Linux的<一个href=\"https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/tree/arch/arm/kernel/elf.c\"相对=nofollow>弓/ ARM /内核/ elf.c 常规 elf_check_arch()显示了检查 X-GT&; e_entry&安培; 1 。这导致了下面的脚本,

Examining the Linux arch/arm/kernel/elf.c routine elf_check_arch() shows a check for x->e_entry & 1. This leads to the following script,

readelf -h $1 | grep -q Entry.*[13579bdf]$

也就是说,只要看看最初 ELF 项值,看是否低位。这是一个快速检查适合什么,我要寻找的精神。 unixsmurf 好点了里面的code任何 ELF 可以混合和匹配< STRONG> ARM 和拇指。这可能是好的,如果程序动态的 IDS 的CPU和选择合适的程序。也就是说,只是一个拇指presence 指令并不意味着code将被执行。

Ie, just look at the initial ELF entry value and see if the low bit is set. This is a fast check that fits the spirit of what I am looking for. unixsmurf has a good point that the code inside any ELF can mix and match ARM and Thumb. This maybe ok, if the program dynamically ids the CPU and selects an appropriate routine. Ie, just the presence of a Thumb instruction doesn't mean that code will execute.

只是在看输入值也确定 GCC 编译标志被使用,至少在 GCC 版本4.6到4.7。

Just looking at the entry value does determine which gcc compiler flags were used, at least for gcc versions 4.6 to 4.7.

这篇关于对于ARM ELF脚本/工具predicate编译为Thumb或ARM的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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