Reference

elftc_bfd_find_target(3)

binary object descriptor handling

NAME

elftc_bfd_find_target, elftc_bfd_target_byteorder, elftc_bfd_target_class, elftc_bfd_target_flavor, elftc_bfd_target_machine – binary object descriptor handling

LIBRARY

library “libelftc”

SYNOPSIS

#include <libelftc.h>

struct Elftc_Bfd_Target;

Elftc_Bfd_Target *

elftc_bfd_find_target(const char *target_name);

unsigned int

elftc_bfd_target_class(Elftc_Bfd_Target *target);

unsigned int

elftc_bfd_target_byteorder(Elftc_Bfd_Target *target);

Elftc_Bfd_Target_Flavor

elftc_bfd_target_flavor(Elftc_Bfd_Target *target);

unsigned int

elftc_bfd_target_machine(Elftc_Bfd_Target *target);

unsigned int

elftc_bfd_target_osabi(Elftc_Bfd_Target *target);

DESCRIPTION

Function elftc_bfd_find_target() locates a binary object descriptor corresponding to the descriptor name in argument target_name. Binary object descriptors encapsulate properties of an object format such as its file representation, ELF class, and byte endianness.

Known descriptor names and their properties include:

NameObject FormatByte OrderBit Width
binaryBinary--
efi-app-ia32PELSB32
efi-app-x86_64PELSB64
elf32-avrELFLSB32
elf32-bigELFMSB32
elf32-bigarmELFMSB32
elf32-bigmipsELFMSB32
elf32-i386ELFLSB32
elf32-i386-freebsdELFLSB32
elf32-ia64-bigELFMSB32
elf32-littleELFLSB32
elf32-littlearmELFLSB32
elf32-littlemipsELFLSB32
elf32-powerpcELFMSB32
elf32-powerpc-freebsdELFMSB32
elf32-powerpcleELFLSB32
elf32-riscvELFLSB32
elf64-riscvELFLSB64
elf64-riscv-freebsdELFLSB64
elf32-shELFMSB32
elf32-shlELFLSB32
elf32-sh-nbsdELFMSB32
elf32-shl-nbsdELFLSB32
elf32-shbig-linuxELFMSB32
elf32-shl-linuxELFLSB32
elf32-sparcELFMSB32
elf32-tradbigmipsELFMSB32
elf32-tradlittlemipsELFLSB32
elf64-alphaELFLSB64
elf64-alpha-freebsdELFLSB64
elf64-bigELFMSB64
elf64-bigmipsELFMSB64
elf64-ia64-bigELFMSB64
elf64-ia64-littleELFLSB64
elf64-littleELFLSB64
elf64-littleaarch64ELFLSB64
elf64-littlemipsELFLSB64
elf64-powerpcELFMSB64
elf64-powerpc-freebsdELFMSB64
elf64-powerpcleELFLSB64
elf64-sh64ELFMSB64
elf64-sh64lELFLSB64
elf64-sh64-nbsdELFMSB64
elf64-sh64l-nbsdELFLSB64
elf64-sh64big-linuxELFMSB64
elf64-sh64-linuxELFLSB64
elf64-sparcELFMSB64
elf64-sparc-freebsdELFMSB64
elf64-tradbigmipsELFMSB64
elf64-tradlittlemipsELFLSB64
elf64-x86-64ELFLSB64
elf64-x86-64-freebsdELFLSB64
ihexIHEX--
pei-i386PELSB32
pei-x86-64PELSB64
srecSREC--
symbolsrecSREC--

Function elftc_bfd_target_byteorder() returns the ELF byte order associated with target descriptor target.

Function elftc_bfd_target_class() returns the ELF class associated with target descriptor target.

Function elftc_bfd_target_flavor() returns the object format associated with target descriptor target. The known object formats are:

ETF_ELF

An ELF object.

ETF_BINARY

Raw binary.

ETF_IHEX

An object encoded in Intel hex format.

ETF_NONE

An unknown object format.

ETF_SREC

An object encoded as S-records.

RETURN VALUES

Function elftc_bfd_find_target() returns a valid pointer to an opaque binary target descriptor if successful, or NULL in case of an error.

Function elftc_bfd_target_byteorder() returns the ELF byte order associated with the target descriptor; one of ELFDATA2MSB or ELFDATA2LSB.

Function elftc_bfd_target_class() returns the ELF class associated with the target descriptor; one of ELFCLASS32 or ELFCLASS64.

Function elftc_bfd_target_machine() returns the ELF architecture associated with the target descriptor.

Function elftc_bfd_target_flavor() returns one of ETF_BINARY, ETF_ELF, ETF_IHEX or ETF_SREC if successful or ETF_NONE in case of error.

EXAMPLES

To return descriptor information associated with target name “elf64-big” use:

struct Elftc_Bfd_Target *t;
if ((t = elftc_bfd_find_target("elf64-big")) == NULL)
	errx(EXIT_FAILURE, "Cannot find target descriptor");
printf("Class: %s\n", elftc_bfd_target_class(t) == ELFCLASS32 ?
    "ELFCLASS32" : "ELFCLASS64");
printf("Byteorder: %s\n",
    elftc_bfd_target_byteorder(t) == ELFDATA2LSB ? "LSB" : "MSB");
printf("Flavor: %d\n", elftc_bfd_target_flavor(t));

SEE ALSO

elf(3)

History