Files
Mark Wielaard 5ddb50af4a libelf: Add elf32_getchdr, elf64_getchdr and gelf_getchdr.
Elf_Data of a compressed section has type ELF_T_CHDR. This type can be
xlated to the file or memory representation. This will make sure the Chdr
is in the correct endianess. The compressed data following the Chdr isn't
translated.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
2016-01-06 14:27:10 +01:00

34 lines
865 B
C

#include "common.h"
/* These functions convert a while section, one Chdr plus compression data. */
static void
Elf32_cvt_chdr (void *dest, const void *src, size_t len, int encode)
{
if (len == 0)
return;
/* Move everything over, if necessary, we only need to xlate the
header, not the compressed data following it. */
if (dest != src)
memmove (dest, src, len);
if (len >= sizeof (Elf32_Chdr))
Elf32_cvt_Chdr (dest, src, sizeof (Elf32_Chdr), encode);
}
static void
Elf64_cvt_chdr (void *dest, const void *src, size_t len, int encode)
{
if (len == 0)
return;
/* Move everything over, if necessary, we only need to xlate the
header, not the compressed data following it. */
if (dest != src)
memmove (dest, src, len);
if (len >= sizeof (Elf64_Chdr))
Elf64_cvt_Chdr (dest, src, sizeof (Elf64_Chdr), encode);
}