.TH GELF_XLATETOM 3 2025-12-28 "Libelf" "Libelf Programmer's Manual" .SH 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 .SH SYNOPSIS .nf .B #include .BI "Elf_Data gelf_xlatetom (Elf *" elf ", Elf_Data *" dest ", const Elf_Data *" src ", unsigned int " encode ");" .BI "Elf_Data gelf_xlatetof (Elf *" elf ", Elf_Data *" dest ", const Elf_Data *" src ", unsigned int " encode ");" .SH 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. .BR gelf_xlatetom () acts as a wrapper around .BR elf32_xlatetom () and .BR elf64_xlatetom (). .BR gelf_xlatetof () acts as a wrapper around .BR elf32_xlatetof () and .BR elf64_xlatetof (). The binary class (\fBELFCLASS32\fP or \fBELFCLASS64\fP) of .I elf is used to automatically select between the elf32 and elf64 version of each function. Data in file representation normally comes from .B elf_rawdata while data in memory representation normally comes from .BR elf_getdata . When there is no difference between file and memory representations, these functions simply copy the ELF data from .I src to .IR dest . Otherwise the encoding will swap between .B ELFDATA2LSB (two's complement little-endian) and .B ELFDATA2MSB (two's complement big-endian). The encoding of an ELF file is specified in the .B Elf32_Ehdr or .B Elf64_Ehdr e_ident[EI_DATA] member. To know the memory encoding for a program you can .B #include and check BYTE_ORDER == LITTLE_ENDIAN (corresponding to .BR ELFDATA2LSB ) or BYTE_ORDER == BIG_ENDIAN (corresponding to .BR ELFDATA2MSB ). .SH PARAMETERS .TP .I elf The ELF descriptor that determines the binary class (\fBELFCLASS32\fP or \fBELFCLASS64\fP) used to translate between file and memory representation. .TP .I dest Destination where the translated data will be stored. The .B d_size of .I dest should be at least as big as the .B d_size of .IR src . .TP .I src Source data. For the .B xlatetom functions, the source data should be in file representation. For the .B xlatetof functions, the source data should be in memory representation. .TP .I encode Specifies an encoding. Can be either .B ELFDATA2LSB (two's complement little-endian) or .B ELFDATA2MSB (two's complement big-endian). For the .B xlatetom functions, this specifies the encoding of .IR src . For the .B xlatetof functions, this specifies the encoding of .IR dest . .SH RETURN VALUE On success, return .IR dest , which will contain the translated data. If there is no difference between the file and memory representations, .I dest will contain a copy of the source data. The .B d_type and .B d_size of .I dest will be set to those of .IR src . On failure, return NULL and set elf_errno. If .IR elf , .I src or .I dest is NULL, then NULL is returned without setting elf_errno. .SH SEE ALSO .BR elf32_xlatetof (3), .BR elf32_xlatetom (3), .BR elf64_xlatetof (3), .BR elf64_xlatetom (3), .BR elf_getdata (3), .BR elf_rawdata (3), .BR libelf (3), .BR elf (5) .SH ATTRIBUTES .TS allbox; lbx lb lb l l l. Interface Attribute Value T{ .na .nh .BR gelf_xlatetom () .BR gelf_xlatetof () T} Thread safety MT-Safe .TE .SH REPORTING BUGS Report bugs to or https://sourceware.org/bugzilla/.