如何知道ARM库是否正在使用hardfp?

时间:2013-12-12 22:28:54

标签: c++ gcc arm

我无法访问构建命令,我只在系统中安装了库。

我想我可以构建一个连接它并测试的hardfp可执行文件,但我想知道是否有更简单的方法。

3 个答案:

答案 0 :(得分:19)

执行readelf -A library.so:如果打印的代码列表包含Tag_ABI_VFP_args: VFP registers,则它是hardfp二进制文件,否则为softfp

E.g。 readelf -A /lib/arm-linux-gnueabihf/libm.so.6将生成

Attribute Section: aeabi
File Attributes
  Tag_CPU_name: "7-A"
  Tag_CPU_arch: v7
  Tag_CPU_arch_profile: Application
  Tag_ARM_ISA_use: Yes
  Tag_THUMB_ISA_use: Thumb-2
  Tag_FP_arch: VFPv3-D16
  Tag_ABI_PCS_wchar_t: 4
  Tag_ABI_FP_denormal: Needed
  Tag_ABI_FP_exceptions: Needed
  Tag_ABI_FP_number_model: IEEE 754
  Tag_ABI_align_needed: 8-byte
  Tag_ABI_align_preserved: 8-byte, except leaf SP
  Tag_ABI_enum_size: int
  Tag_ABI_HardFP_use: SP and DP
  Tag_ABI_VFP_args: VFP registers
  Tag_ABI_optimization_goals: Aggressive Speed
  Tag_CPU_unaligned_access: v6

另一方面,readelf -A /lib/arm-linux-gnueabi/libm.so.6产生

Attribute Section: aeabi
File Attributes
  Tag_CPU_name: "7-A"
  Tag_CPU_arch: v7
  Tag_CPU_arch_profile: Application
  Tag_ARM_ISA_use: Yes
  Tag_THUMB_ISA_use: Thumb-2
  Tag_FP_arch: VFPv3-D16
  Tag_ABI_PCS_wchar_t: 4
  Tag_ABI_FP_denormal: Needed
  Tag_ABI_FP_exceptions: Needed
  Tag_ABI_FP_number_model: IEEE 754
  Tag_ABI_align_needed: 8-byte
  Tag_ABI_align_preserved: 8-byte, except leaf SP
  Tag_ABI_enum_size: int
  Tag_ABI_optimization_goals: Aggressive Speed
  Tag_CPU_unaligned_access: v6

答案 1 :(得分:5)

使用readelf

以下是来自Poco的ARM构建的一些示例输出:

$ readelf libPocoFoundation.so -h
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:                              DYN (Shared object file)
  Machine:                           ARM
  Version:                           0x1
  Entry point address:               0x61e50
  Start of program headers:          52 (bytes into file)
  Start of section headers:          1078048 (bytes into file)
  Flags:                             0x5000402, has entry point, Version5 EABI, hard-float ABI
  Size of this header:               52 (bytes)
  Size of program headers:           32 (bytes)
  Number of program headers:         7
  Size of section headers:           40 (bytes)
  Number of section headers:         28
  Section header string table index: 27

在flags部分,它将列出有关elf文件的数据。这些在ARM ELF Specification中定义,检查表4-2。在我的例子中,这是使用硬浮点编译器构建的,因此hard-float被列为标志。

在软浮点库上,标志行如下所示:

Flags: 0x5000202, has entry point, Version5 EABI, soft-float ABI

答案 2 :(得分:-2)

使用objdump -d进行反汇编,然后使用grep查找某些浮点命令。我不确定objdump是否会生成符合UAL的程序集,所以也尝试使用旧的语法。观察寄存器名称而不是命令助记符可能更容易,但可能存在误报。