elf32_xlatetom - Man Page

translate 32-bit or 64-bit ELF data from file representation to memory representation elf32_xlatetof, elf64_xlatetof — translate 32-bit or 64-bit ELF data from memory representation to file representation

Synopsis

#include <libelf.h>

int elf32_xlatetom(Elf_Data *dst, const Elf_Data *src, unsigned int encoding);
int elf64_xlatetom(Elf_Data *dst, const Elf_Data *src, unsigned int encoding);

int elf32_xlatetof(Elf_Data *dst, const Elf_Data *src, unsigned int encoding);
int elf64_xlatetof(Elf_Data *dst, const Elf_Data *src, unsigned int encoding);

Description

Translate ELF data from file representation to memory representation or vice versa.  File and memory representations of ELF data can differ in terms of endianness.  Data in file representation normally comes from elf_rawdata while data in memory representation normally comes from elf_getdata. When there is no difference between file and memory representations, these functions simply copy the ELF data from src to dst. Otherwise the encoding will swap between ELFDATA2LSB (two's complement little-endian) and ELFDATA2MSB (two's complement big-endian). The encoding of an ELF file is specified in the Elf32_Ehdr or Elf64_Ehdr e_ident[EI_DATA] member.  To know the memory encoding for a program you can #include <endian.h> and check BYTE_ORDER == LITTLE_ENDIAN (corresponding to ELFDATA2LSB) or BYTE_ORDER == BIG_ENDIAN (corresponding to ELFDATA2MSB).

Parameters

dst

Destination where the translated data will be stored. The d_size of dst should be at least as big as the d_size of src.

src

Source data. For the xlatetom functions, the source data should be in file representation. For the xlatetof functions, the source data should be in memory representation.

encoding

Specifies an encoding.  Can be either ELFDATA2LSB (two's complement little-endian) or ELFDATA2MSB (two's complement big-endian).  For the xlatetom functions, this specifies the encoding of src. For the xlatetof functions, this specifies the encoding of dst.

Return Value

On success, return dst, which will contain the translated data.  If there is no difference between the file and memory representations, dst will contain a copy of the source data.  The d_type and d_size of dst will be set to those of src.

If an error occurs, return NULL and set a libelf error code.

See Also

elf_errno(3), elf_getdata(3), elf_rawdata(3), libelf(3), elf(5)

Attributes

For an explanation of the terms used in this section, see attributes(7).

InterfaceAttributeValue
elf32_xlatetom(), elf64_xlatetom(), elf32_xlatetof(), elf64_xlatetof()Thread safetyMT-Safe

Reporting Bugs

Report bugs to <elfutils-devel@sourceware.org> or https://sourceware.org/bugzilla/.

Referenced By

libelf(3).

The man pages elf32_xlatetof(3), elf64_xlatetof(3) and elf64_xlatetom(3) are aliases of elf32_xlatetom(3).

2024-08-14 Libelf Programmer's Manual