logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

elf32_xlatetom, elf64_xlatetom - translate 32-bit or 64-bit ELF data from file

Attributes

For an explanation of the terms used in this section, see attributes(7). ┌─────────────────────────────────────────────────────────────────────────────┬───────────────┬─────────┐ │ InterfaceAttributeValue │ ├─────────────────────────────────────────────────────────────────────────────┼───────────────┼─────────┤ │ elf32_xlatetom(), elf64_xlatetom(), elf32_xlatetof(), elf64_xlatetof() │ Thread safety │ MT-Safe │ └─────────────────────────────────────────────────────────────────────────────┴───────────────┴─────────┘

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_Ehdre_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).

Name

elf32_xlatetom, elf64_xlatetom - 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

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.

Reporting Bugs

Report bugs to <elfutils-devel@sourceware.org> or https://sourceware.org/bugzilla/. Libelf 2024-08-14 ELF32_XLATETOM(3)

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)

Synopsis

#include<libelf.h>intelf32_xlatetom(Elf_Data*dst,constElf_Data*src,unsignedintencoding);intelf64_xlatetom(Elf_Data*dst,constElf_Data*src,unsignedintencoding);intelf32_xlatetof(Elf_Data*dst,constElf_Data*src,unsignedintencoding);intelf64_xlatetof(Elf_Data*dst,constElf_Data*src,unsignedintencoding);

See Also