GELF\_XLATETOM(3) Libelf Programmer's Manual GELF\_XLATETOM(3)

# [NAME](#NAME)

gelf\_xlatetom - Translate class-independent ELF data from file representation to memory representation

gelf\_xlatetof - Translate class-independent ELF data from memory representation to file representation

# [SYNOPSIS](#SYNOPSIS)

```
#include <gelf.h>
Elf_Data gelf_xlatetom (Elf *elf, Elf_Data *dest, const Elf_Data *src, unsigned int encode);
Elf_Data gelf_xlatetof (Elf *elf, Elf_Data *dest, const Elf_Data *src, unsigned int encode);
```

# [DESCRIPTION](#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. **gelf\_xlatetom**() acts as a wrapper around **elf32\_xlatetom**() and **elf64\_xlatetom**(). **gelf\_xlatetof**() acts as a wrapper around **elf32\_xlatetof**() and **elf64\_xlatetof**(). The binary class (**ELFCLASS32** or **ELFCLASS64**) of *elf* is used to automatically select between the elf32 and elf64 version of each function.

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 *dest*. 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 &lt;endian.h&gt;** and check BYTE\_ORDER == LITTLE\_ENDIAN (corresponding to **ELFDATA2LSB**) or BYTE\_ORDER == BIG\_ENDIAN (corresponding to **ELFDATA2MSB**).

# [PARAMETERS](#PARAMETERS)

[*elf*](#elf)

The ELF descriptor that determines the binary class (**ELFCLASS32** or **ELFCLASS64**) used to translate between file and memory representation.

[*dest*](#dest)

Destination where the translated data will be stored. The **d\_size** of *dest* should be at least as big as the **d\_size** of *src*.

[*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.

[*encode*](#encode)

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 *dest*.

# [RETURN VALUE](#RETURN_VALUE)

On success, return *dest*, which will contain the translated data. If there is no difference between the file and memory representations, *dest* will contain a copy of the source data. The **d\_type** and **d\_size** of *dest* will be set to those of *src*.

On failure, return NULL and set elf\_errno. If *elf*, *src* or *dest* is NULL, then NULL is returned without setting elf\_errno.

# [SEE ALSO](#SEE_ALSO)

[**elf32\_xlatetof**(3)](/man/os/elfutils/elf32_xlatetof.3), [**elf32\_xlatetom**(3)](/man/os/elfutils/elf32_xlatetom.3), [**elf64\_xlatetof**(3)](/man/os/elfutils/elf64_xlatetof.3), [**elf64\_xlatetom**(3)](/man/os/elfutils/elf64_xlatetom.3), [**elf\_getdata**(3)](/man/os/elfutils/elf_getdata.3), [**elf\_rawdata**(3)](/man/os/elfutils/elf_rawdata.3), [**libelf**(3)](/man/os/elfutils/libelf.3), [**elf**(5)](/man/os/elfutils/elf.5)

# [ATTRIBUTES](#ATTRIBUTES)

**Interface** **Attribute** **Value** gelf\_xlatetom () gelf\_xlatetof () Thread safety MT-Safe

# [REPORTING BUGS](#REPORTING_BUGS)

Report bugs to &lt;elfutils-devel@sourceware.org&gt; or https://sourceware.org/bugzilla/.

2025-12-28 Libelf

---

Document: gelf_xlatetof(3) from elfutils 0.197-r0 (Chainguard OS)
Source: https://sourceware.org/git/elfutils.git
