[PATCH] D13140: [ELF2] Fix binaries so they actually run on FreeBSD.

Ed Maste via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 24 11:00:31 PDT 2015


emaste added a comment.

Note that by default on FreeBSD/arm64 we currently set OS/ABI to NONE (aka SYSV) and rely on the ELF note:

  root at cavium:/zoo/emaste/freebsd # readelf -hn /bin/ls                           
  ELF Header:
    Magic:   7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00 
    Class:                             ELF64
    Data:                              2's complement, little endian
    Version:                           1 (current)
    OS/ABI:                            SYSV
    ABI Version:                       0
    Type:                              EXEC (Executable file)
    Machine:                           AArch64
    Version:                           0x1
    Entry point address:               0x4020e0
    Start of program headers:          64 (bytes into file)
    Start of section headers:          27528 (bytes into file)
    Flags:                             0
    Size of this header:               64 (bytes)
    Size of program headers:           56 (bytes)
    Number of program headers:         7
    Size of section headers:           64 (bytes)
    Number of section headers:         28
    Section header string table index: 27
  
  Notes at offset 0x000001e0 with length 0x00000030:
    Owner         Data size       Description
    FreeBSD       0x00000004      NT_FREEBSD_ABI_TAG
    FreeBSD       0x00000004      NT_FREEBSD_NOINIT_TAG

while on amd64 we require OS/ABI == FreeBSD (but also have the ELF note):

  feynman% readelf -hn /bin/ls
  ELF Header:
    Magic:   7f 45 4c 46 02 01 01 09 00 00 00 00 00 00 00 00 
    Class:                             ELF64
    Data:                              2's complement, little endian
    Version:                           1 (current)
    OS/ABI:                            UNIX - FreeBSD
    ABI Version:                       0
    Type:                              EXEC (Executable file)
    Machine:                           Advanced Micro Devices X86-64
    Version:                           0x1
    Entry point address:               0x401d40
    Start of program headers:          64 (bytes into file)
    Start of section headers:          30160 (bytes into file)
    Flags:                             0x0
    Size of this header:               64 (bytes)
    Size of program headers:           56 (bytes)
    Number of program headers:         8
    Size of section headers:           64 (bytes)
    Number of section headers:         29
    Section header string table index: 28
  
  Notes at offset 0x00000218 with length 0x00000030:
    Owner         Data size       Description
    FreeBSD       0x00000004      NT_FREEBSD_ABI_TAG
    FreeBSD       0x00000004      NT_FREEBSD_NOINIT_TAG


http://reviews.llvm.org/D13140





More information about the llvm-commits mailing list