Skip to content

armhf binaries do not have the hard-float ELF flag set

Hi,

binaries produced by fpc on armhf currently lack the hard-float ELF flag.

I've built the following hello world program with fpc hello.pas:

 program Hello;
 begin
   writeln ('Hello, world.');
 end.

The resulting ELF object looks like this, note in particular the value of "Flags", namely "0x5000200, Version5 EABI, soft-float ABI". This should be "0x5000400, Version5 EABI, hard-float ABI" instead.

$ readelf -h hello
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:               0x100ec
  Start of program headers:          52 (bytes into file)
  Start of section headers:          231208 (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:         4
  Size of section headers:           40 (bytes)
  Number of section headers:         10
  Section header string table index: 9

Compare with a C hello world program built with gcc hello.c, and again note the value of Flags: "0x5000400, Version5 EABI, hard-float ABI".

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 (Position-Independent Executable file)
  Machine:                           ARM
  Version:                           0x1
  Entry point address:               0x409
  Start of program headers:          52 (bytes into file)
  Start of section headers:          6692 (bytes into file)
  Flags:                             0x5000400, Version5 EABI, hard-float ABI
  Size of this header:               52 (bytes)
  Size of program headers:           32 (bytes)
  Number of program headers:         9
  Size of section headers:           40 (bytes)
  Number of section headers:         29

Additionally, the attribute "Tag_ABI_VFP_args" should be set to "VFP registers".

$ readelf -A hello
Attribute Section: aeabi
File Attributes
  Tag_CPU_arch: v4T
  Tag_ARM_ISA_use: Yes
  Tag_THUMB_ISA_use: Thumb-1

And compare with the attributes in the ELF file produced by GCC:

$ readelf -A a.out 
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_rounding: Needed
  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_VFP_args: VFP registers
  Tag_CPU_unaligned_access: v6

Here's the output of fpc -vi:

(sid-armhf)root@ariel:/var/tmp# fpc -vi hello.pas 
Free Pascal Compiler version 3.2.2+dfsg-21 [2023/06/17] for arm
Copyright (c) 1993-2021 by Florian Klaempfl and others
Target OS: Linux for ARMHF
Compiling hello.pas
Linking hello
4 lines compiled, 0.3 sec

And fpc -i

(sid-armhf)root@ariel:/var/tmp# fpc -i
Free Pascal Compiler version 3.2.2

Compiler date      : 2023/06/17
Compiler CPU target: arm

Supported targets (targets marked with '{*}' are under development):
  Linux: Linux for ARMHF
  WinCE: WinCE for ARM
  gba: GameBoy Advance
  PalmOS: PalmOS
  nds: Nintendo DS
  embedded: Embedded
  Symbian: Symbian OS for ARM
  iOS: iOS for ARM
  Android: Android for ARMEL
  AROS: AROS for ARM
  NetBSD: NetBSD for ARMHF {*}

Supported CPU instruction sets:
  ARMV3,ARMV4,ARMV4T,ARMV5,ARMV5T,ARMV5TE,ARMV5TEJ,ARMV6,ARMV6K,ARMV6T2
  ARMV6Z,ARMV6M,ARMV7,ARMV7A,ARMV7R,ARMV7M,ARMV7EM

Supported FPU instruction sets:
  SOFT,LIBGCC,FPA,FPA10,FPA11,VFPV2,VFPV3,VFPV3_D16,FPV4_S16,VFPV4

Supported inline assembler modes:
  STANDARD
  DIVIDED
  UNIFIED

Recognized compiler and RTL features:
  HEAP,INITFINAL,RTTI,CLASSES,EXCEPTIONS,EXITCODE,ANSISTRINGS,WIDESTRINGS
  TEXTIO,CONSOLEIO,FILEIO,RANDOM,VARIANTS,OBJECTS,DYNARRAYS,THREADING
  COMMANDARGS,PROCESSES,STACKCHECK,DYNLIBS,SOFTFPU,OBJECTIVEC1,RESOURCES
  UNICODESTRINGS

Supported ABI targets:
  DEFAULT
  EABIHF

Supported Optimizations:
  REGVAR
  STACKFRAME
  PEEPHOLE
  LOOPUNROLL
  TAILREC
  CSE
  DFA
  ORDERFIELDS
  FASTMATH
  REMOVEEMPTYPROCS
  CONSTPROP
  FORCENOSTACKFRAME

Supported Whole Program Optimizations:
  All
  DEVIRTCALLS
  OPTVMTS
  SYMBOLLIVENESS

Supported Microcontroller types:
  LPC810M021FN8,LPC811M001FDH16,LPC812M101FDH16,LPC812M101FD20
  LPC812M101FDH20,LPC1110FD20,LPC1111FDH20_002,LPC1111FHN33_101
  LPC1111FHN33_102,LPC1111FHN33_103,LPC1111FHN33_201,LPC1111FHN33_202
  LPC1111FHN33_203,LPC1112FD20_102,LPC1112FDH20_102,LPC1112FDH28_102
  LPC1112FHN33_101,LPC1112FHN33_102,LPC1112FHN33_103,LPC1112FHN33_201
  LPC1112FHN24_202,LPC1112FHN33_202,LPC1112FHN33_203,LPC1112FHI33_202
  LPC1112FHI33_203,LPC1113FHN33_201,LPC1113FHN33_202,LPC1113FHN33_203
  LPC1113FHN33_301,LPC1113FHN33_302,LPC1113FHN33_303,LPC1113FBD48_301
  LPC1113FBD48_302,LPC1113FBD48_303,LPC1114FDH28_102,LPC1114FN28_102
  LPC1114FHN33_201,LPC1114FHN33_202,LPC1114FHN33_203,LPC1114FHN33_301
  LPC1114FHN33_302,LPC1114FHN33_303,LPC1114FHN33_333,LPC1114FHI33_302
  LPC1114FHI33_303,LPC1114FBD48_301,LPC1114FBD48_302,LPC1114FBD48_303
  LPC1114FBD48_323,LPC1114FBD48_333,LPC1115FBD48_303,LPC11C12FBD48_301
  LPC11C14FBD48_301,LPC11C22FBD48_301,LPC11C24FBD48_301
  LPC11D14FBD100_302,LPC1224FBD48_101,LPC1224FBD48_121,LPC1224FBD64_101
  LPC1224FBD64_121,LPC1225FBD48_301,LPC1225FBD48_321,LPC1225FBD64_301
  LPC1225FBD64_321,LPC1226FBD48_301,LPC1226FBD64_301,LPC1227FBD48_301
  LPC1227FBD64_301,LPC12D27FBD100_301,LPC1311FHN33,LPC1311FHN33_01
  LPC1313FHN33,LPC1313FHN33_01,LPC1313FBD48,LPC1313FBD48_01,LPC1315FHN33
  LPC1315FBD48,LPC1316FHN33,LPC1316FBD48,LPC1317FHN33,LPC1317FBD48
  LPC1317FBD64,LPC1342FHN33,LPC1342FBD48,LPC1343FHN33,LPC1343FBD48
  LPC1345FHN33,LPC1345FBD48,LPC1346FHN33,LPC1346FBD48,LPC1347FHN33
  LPC1347FBD48,LPC1347FBD64,LPC2114,LPC2124,LPC2194,LPC1754,LPC1756
  LPC1758,LPC1764,LPC1766,LPC1768,AT91SAM7S256,AT91SAM7SE256,AT91SAM7X256
  AT91SAM7XC256,STM32F030C6,STM32F030C8,STM32F030F4,STM32F030K6
  STM32F030R8,STM32F050C4,STM32F050C6,STM32F050F4,STM32F050F6,STM32F050G4
  STM32F050G6,STM32F050K4,STM32F050K6,STM32F051C4,STM32F051C6,STM32F051C8
  STM32F051K4,STM32F051K6,STM32F051K8,STM32F051R4,STM32F051R6,STM32F051R8
  STM32F091CC,STM32F091CB,STM32F091RC,STM32F091RB,STM32F091VC,STM32F091VB
  STM32F100X4,STM32F100X6,STM32F100X8,STM32F100XB,STM32F100XC,STM32F100XD
  STM32F100XE,STM32F101X4,STM32F101X6,STM32F101X8,STM32F101XB,STM32F101XC
  STM32F101XD,STM32F101XE,STM32F101XF,STM32F101XG,STM32F102X4,STM32F102X6
  STM32F102X8,STM32F102XB,STM32F103X4,STM32F103X6,STM32F103X8,STM32F103XB
  STM32F103XC,STM32F103XD,STM32F103XE,STM32F103XF,STM32F103XG,STM32F107X8
  STM32F107XB,STM32F107XC,STM32F105R8,STM32F105RB,STM32F105RC,STM32F105V8
  STM32F105VB,STM32F105VC,STM32F107RB,STM32F107RC,STM32F107VB,STM32F107VC
  STM32F401CB,STM32F401RB,STM32F401VB,STM32F401CC,STM32F401RC,STM32F401VC
  DISCOVERYF401VC,STM32F401CD,STM32F401RD,STM32F401VD,STM32F401CE
  STM32F401RE,NUCLEOF401RE,STM32F401VE,STM32F407VG,DISCOVERYF407VG
  STM32F407IG,STM32F407ZG,STM32F407VE,STM32F407ZE,STM32F407IE,STM32F411CC
  STM32F411RC,STM32F411VC,STM32F411CE,STM32F411RE,NUCLEOF411RE
  STM32F411VE,DISCOVERYF411VE,STM32F429VG,STM32F429ZG,STM32F429IG
  STM32F429VI,STM32F429ZI,DISCOVERYF429ZI,STM32F429II,STM32F429VE
  STM32F429ZE,STM32F429IE,STM32F429BG,STM32F429BI,STM32F429BE,STM32F429NG
  STM32F429NI,STM32F429NE,STM32F446MC,STM32F446RC,STM32F446VC,STM32F446ZC
  STM32F446ME,STM32F446RE,NUCLEOF446RE,STM32F446VE,STM32F446ZE
  STM32F745XE,STM32F745XG,STM32F746XE,STM32F746XG,STM32F756XE,STM32F756XG
  LM3S1110,LM3S1133,LM3S1138,LM3S1150,LM3S1162,LM3S1165,LM3S1166,LM3S2110
  LM3S2139,LM3S6100,LM3S6110,LM3S1601,LM3S1608,LM3S1620,LM3S1635,LM3S1636
  LM3S1637,LM3S1651,LM3S2601,LM3S2608,LM3S2620,LM3S2637,LM3S2651,LM3S6610
  LM3S6611,LM3S6618,LM3S6633,LM3S6637,LM3S8630,LM3S1911,LM3S1918,LM3S1937
  LM3S1958,LM3S1960,LM3S1968,LM3S1969,LM3S2911,LM3S2918,LM3S2919,LM3S2939
  LM3S2948,LM3S2950,LM3S2965,LM3S6911,LM3S6918,LM3S6938,LM3S6950,LM3S6952
  LM3S6965,LM3S8930,LM3S8933,LM3S8938,LM3S8962,LM3S8970,LM3S8971,LM3S5951
  LM3S5956,LM3S1B21,LM3S2B93,LM3S5B91,LM3S9B81,LM3S9B90,LM3S9B92,LM3S9B95
  LM3S9B96,LM3S5D51,LM4F120H5,SC32442B,XMC4500X1024,XMC4500X768
  XMC4502X768,XMC4504X512,ALLWINNER_A20,MK20DX128VFM5,MK20DX128VFT5
  MK20DX128VLF5,MK20DX128VLH5,TEENSY30,MK20DX128VMP5,MK20DX32VFM5
  MK20DX32VFT5,MK20DX32VLF5,MK20DX32VLH5,MK20DX32VMP5,MK20DX64VFM5
  MK20DX64VFT5,MK20DX64VLF5,MK20DX64VLH5,MK20DX64VMP5,MK20DX128VLH7
  MK20DX128VLK7,MK20DX128VLL7,MK20DX128VMC7,MK20DX256VLH7,MK20DX256VLK7
  MK20DX256VLL7,MK20DX256VMC7,TEENSY31,TEENSY32,MK20DX64VLH7,MK20DX64VLK7
  MK20DX64VMC7,MK22FN512CAP12,MK22FN512CBP12,MK22FN512VDC12
  MK22FN512VLH12,MK22FN512VLL12,MK22FN512VMP12,FREEDOM_K22F
  MK64FN1M0VDC12,MK64FN1M0VLL12,FREEDOM_K64F,MK64FN1M0VLQ12
  MK64FN1M0VMD12,MK64FX512VDC12,MK64FX512VLL12,MK64FX512VLQ12
  MK64FX512VMD12,ATSAM3X8E,ARDUINO_DUE,FLIP_N_CLICK,NRF51422_XXAA
  NRF51422_XXAB,NRF51422_XXAC,NRF51822_XXAA,NRF51822_XXAB,NRF51822_XXAC
  NRF52832_XXAA,NRF52840_XXAA,THUMB2_BARE

This program comes under the GNU General Public Licence
For more information read COPYING.v2

Please report bugs in our bug tracker on:
                 http://bugs.freepascal.org

More information may be found on our WWW pages (including directions
for mailing lists useful for asking questions or discussing potential
new features, etc.):
                 http://www.freepascal.org
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information