---
name: "gelf_xlatetof"
section: "3"
platform: "linux"
package: "libelf"
version: "0.197-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux", "freebsd"]
url: "https://new.carta.tech/gelf_xlatetom"
---

# gelf\_xlatetof(3)

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

Part of [gelf\_xlatetom(3)](/gelf_xlatetom/3.md).

## 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

```
#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

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

## PARAMETERS

- *elf*

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

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

  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*

  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

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

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

## ATTRIBUTES

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

## REPORTING BUGS

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