mirror of
https://github.com/openharmony/third_party_elfutils.git
synced 2026-07-01 06:41:51 -04:00
5ddb50af4a
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>
34 lines
865 B
C
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);
|
|
}
|