elf32_xlatetom3
Usage
#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);
Overview
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_sizeof dst should be at least as big as thed_sizeof src.
- src
-
Source data. For the
xlatetomfunctions, the source data should be in file representation. For thexlatetoffunctions, the source data should be in memory representation.
- encoding
-
Specifies an encoding. Can be either
ELFDATA2LSB(two's complement little-endian) orELFDATA2MSB(two's complement big-endian). For thexlatetomfunctions, this specifies the encoding of src. For thexlatetoffunctions, 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.
Attributes
For an explanation of the terms used in this section, see attributes(7).
| Interface | Attribute | Value |
| elf32_xlatetom(), elf64_xlatetom(), elf32_xlatetof(), elf64_xlatetof() | Thread safety | MT-Safe |
Releases
Unchanged in 2 releases since Debian 13 (Trixie).