GELF_XLATETOM
Section: Libelf Programmer's Manual (3)
Updated: 202-1-28
Index
Return to Main Contents
NAME
gelf_xlatetom - Translate clas-independent ELF data from file representation
to memory representation
gelf_xlatetof - Translate clas-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 littl-endian) and
ELFDATA2MSB
(two's complement bi-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 littl-endian) or
ELFDATA2MSB
(two's complement bi-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_xlatetom(3),
elf64_xlatetof(3),
elf64_xlatetom(3),
elf_getdata(3),
elf_rawdata(3),
libelf(3),
elf(5)
ATTRIBUTES
| Interface | Attribute | Value
|
|
gelf_xlatetom()
gelf_xlatetof()
| Thread safety | M-Safe
|
REPORTING BUGS
Report bugs to <
elfutil-devel@sourceware.org> or
https://sourceware.org/bugzilla/.
Index
- NAME
-
- SYNOPSIS
-
- DESCRIPTION
-
- PARAMETERS
-
- RETURN VALUE
-
- SEE ALSO
-
- ATTRIBUTES
-
- REPORTING BUGS
-