Adding a MACHINE_ARCH note

Warner Losh imp at bsdimp.com
Wed Jul 10 03:03:00 UTC 2013


On Jul 9, 2013, at 4:48 PM, Andrew Turner wrote:

> On Tue, 9 Jul 2013 08:19:46 -0600
> Warner Losh <imp at bsdimp.com> wrote:
>> I thought that the ELF headers gave us all the data we needed to know
>> how things were built...
> 
> It will tell us if it was for e.g. an ARM or MIPS ELF file, but I'm not
> sure how we can tell the difference between an arm and an armv6 ELF.
> 
> With armv6 there are a few changes in the userland/kernel
> interface, e.g. reading the thread local storage pointer is different
> such that an armv6 static binary would not run on an ARMv5 core as it
> uses newer instructions.

On MIPS I know all that is encoded in the ELF headers for sure, so I went looking for ARM.

OK. Found the ARM elf spec.
http://infocenter.arm.com/help/topic/com.arm.doc.dui0101a/DUI0101A_Elf.pdf which is updated by http://infocenter.arm.com/help/topic/com.arm.doc.ihi0044e/IHI0044E_aaelf.pdf

For big endian vs little endian: ei_data is set to ELFDATA2LSB or ELFDATA2MSB.

EABI is denoted by setting EI_OSABI to ELFOSABI_ARM_AEABI.

e_flags will have some info as well:
EF_ARM_ABIMASK 0xFF000000 (value of 5 for EABI for armv6)
EF_ARM_BE8 0x00800000 - The ELF file contains BE-8 code, suitable for execution on an ARM 
Architecture v6 processor
EF_ARM_ABI_FLOAT_HARD 0x00000400 - Set in executable file headers (e_type = ET_EXEC or ET_DYN) to note that 
the executable file was built to conform to the hardware floating-point 
procedure-call standard.
Compatible with legacy (pre version 5) gcc use as EF_ARM_VFP_FLOAT.
EF_ARM_ABI_FLOAT_SOFT 0x00000200 - Set in executable file headers (e_type = ET_EXEC or ET_DYN) to note 
explicitly that the executable file was built to conform to the software 
floating-point procedure-call standard (the base standard). If both 
EF_ARM_ABI_FLOAT_XXXX bits are clear, conformance to the base 
procedure-call standard is implied.
Compatible with legacy (pre version 5) gcc use as EF_ARM_SOFT_FLOAT

What else is needed?

Warner




More information about the freebsd-arch mailing list