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

Ser*_*ins 21 c++ gcc arm

我无法访问build命令,我只在系统中安装了库.

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

Mar*_*han 21

执行readelf -A library.so:如果打印的标签列表包含Tag_ABI_VFP_args: VFP registers,那么它是hardfp二进制,否则假设softfp.

例如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
Run Code Online (Sandbox Code Playgroud)

另一方面,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
Run Code Online (Sandbox Code Playgroud)

  • AMD64 ELF不定义特定于arch的属性部分 (2认同)

Col*_*lin 6

使用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
Run Code Online (Sandbox Code Playgroud)

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

在软浮动库中,标志行如下所示:

Flags: 0x5000202, has entry point, Version5 EABI, soft-float ABI
Run Code Online (Sandbox Code Playgroud)

  • `hardfp` /`softfp`标志最近才添加,只有最新的工具链支持它们.较旧的工具链仅在EABI属性部分中指示浮点ABI. (2认同)