ELF32_XLATETOM(3)
💖 ELF32_XLATETOM 💖
okay bestie, welcome to the libelf programmer's manual, page ELF32_XLATETOM(3) — yes it's giving "why is the title in all caps" energy but that's just how manpages are, we don't question it 🎀
✨ 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 ✨
So basically 💅 these functions translate ELF data from file representation to memory representation, or the other way around. Flip it, reverse it, we love a two-way street.
File and memory representations of ELF data can differ in terms of endianness — yeah, the whole "which byte comes first" drama. Data in file representation normally comes from elf_rawdata, while data in memory representation normally comes from elf_getdata. iykyk 🔥
When there is no difference between file and memory representations, these functions simply copy the ELF data from src to dst. No thoughts, just vibes, just a copy. 🫶
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. And 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). Iconic little preprocessor moment, honestly. 👑
✨ PARAMETERS ✨
dst— Destination where the translated data will be stored. Thed_sizeofdstshould be at least as big as thed_sizeofsrc. like bestie, give it room to breathe 😭src— Source data. For thexlatetomfunctions, the source data should be in file representation. For thexlatetoffunctions, the source data should be in memory representation. read the room, know your direction 💫encoding— Specifies an encoding. Can be eitherELFDATA2LSB(two's complement little-endian) orELFDATA2MSB(two's complement big-endian). For thexlatetomfunctions, this specifies the encoding ofsrc. For thexlatetoffunctions, this specifies the encoding ofdst. yes the direction matters, this is not a drill 🎀
✨ 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. slay, it literally hands you the thing you asked for ✨
If an error occurs, return NULL and set a libelf error code. 💀
✨ SEE ALSO ✨
the friend group 🫶 go read them, they're all part of the same cinematic universe 🌈
✨ ATTRIBUTES ✨
For an explanation of the terms used in this section, see attributes(7).
- Interface:
elf32_xlatetom(),elf64_xlatetom(),elf32_xlatetof(),elf64_xlatetof() - Attribute: Thread safety
- Value:
MT-Safe
translation girlies stay MT-Safe, periodt. no cap. 💅
✨ REPORTING BUGS ✨
Report bugs to <elfutils-devel@sourceware.org> or https://sourceware.org/bugzilla/.
not me asking you to file a bug report but like... if it's broken, tell the devs, they wanna know 💜
and that's the whole page, bestie!! this was page ELF32_XLATETOM(3) from the Libelf Programmer's Manual, dated 2024-08-14 — mwah, go translate something, you're doing amazing sweetie 🧚✨
📦 where this page comes from
- alpine 3.22: elfutils-doc 0.193-r0 · GPL-3.0-or-later AND ( GPL-2.0-or-later OR LGPL-3.0-or-later )
- alpine 3.23: elfutils-doc 0.194-r0 · GPL-3.0-or-later AND ( GPL-2.0-or-later OR LGPL-3.0-or-later )
- alpine 3.24: elfutils-doc 0.195-r0 · GPL-3.0-or-later AND ( GPL-2.0-or-later OR LGPL-3.0-or-later )
- arch rolling: libelf 0.196-1
- arch rolling: libelf 0.197-1 · GPL-2.0-or-later OR LGPL-3.0-or-later
- centos-stream 10: elfutils-libelf-devel 0.197-1.el10 · GPL-2.0-or-later OR LGPL-3.0-or-later
- centos-stream 9: elfutils-libelf-devel 0.197-1.el9 · GPL-2.0-or-later OR LGPL-3.0-or-later
- centos-stream 9: elfutils-libelf-devel 0.197-1.el9 · GPL-2.0-or-later OR LGPL-3.0-or-later
- debian trixie: libelf-dev 0.192-4 · GPL-3.0-or-later
- fedora 43: elfutils-libelf-devel 0.193-3.fc43 · GPL-2.0-or-later OR LGPL-3.0-or-later
- fedora 43: elfutils-libelf-devel 0.193-3.fc43 · GPL-2.0-or-later OR LGPL-3.0-or-later
- fedora 43: elfutils-libelf-devel 0.196-1.fc43
- fedora 43: elfutils-libelf-devel 0.196-1.fc43
- fedora 43: elfutils-libelf-devel 0.197-1.fc43 · GPL-2.0-or-later OR LGPL-3.0-or-later
- fedora 43: elfutils-libelf-devel 0.197-1.fc43 · GPL-2.0-or-later OR LGPL-3.0-or-later
- fedora 44: elfutils-libelf-devel 0.194-5.fc44 · GPL-2.0-or-later OR LGPL-3.0-or-later
- fedora 44: elfutils-libelf-devel 0.194-5.fc44 · GPL-2.0-or-later OR LGPL-3.0-or-later
- fedora 44: elfutils-libelf-devel 0.196-1.fc44
- fedora 44: elfutils-libelf-devel 0.196-1.fc44
- fedora 44: elfutils-libelf-devel 0.197-1.fc44 · GPL-2.0-or-later OR LGPL-3.0-or-later
- fedora 44: elfutils-libelf-devel 0.197-1.fc44 · GPL-2.0-or-later OR LGPL-3.0-or-later
- nixos 26.05: elfutils 0.194
- nixpkgs unstable: elfutils 0.195
- opensuse-leap 16.0: libelf-devel 0.192-160000.3.1 · GPL-2.0-or-later OR LGPL-3.0-or-later
- opensuse-leap 16.0: libelf-devel 0.192-160000.3.1 · GPL-2.0-or-later OR LGPL-3.0-or-later
- opensuse-leap 16.0: libelf-devel 0.192-160000.3.1 · GPL-2.0-or-later OR LGPL-3.0-or-later
- opensuse-leap 16.0: libelf-devel 0.192-160000.3.1 · GPL-2.0-or-later OR LGPL-3.0-or-later
- ubuntu questing: libelf-dev 0.193-1
- ubuntu resolute: libelf-dev 0.194-4 · GPL-3.0-or-later
- ubuntu stonking: libelf-dev 0.196-1 · GPL-3.0-or-later
- 💖 girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms