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

# elf32\_xlatetom(3)

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

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

For an explanation of the terms used in this section, see [**attributes**(7)](/attributes/7.md).

| | | |
| --- | --- | --- |
| **Interface** | **Attribute** | **Value** |
| **elf32\_xlatetom**(), **elf64\_xlatetom**(), **elf32\_xlatetof**(), **elf64\_xlatetof**() | Thread safety | MT-Safe |

## REPORTING BUGS

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