/* Internal interfaces for libelf.
- Copyright (C) 1998-2010 Red Hat, Inc.
+ Copyright (C) 1998-2010, 2015 Red Hat, Inc.
This file is part of elfutils.
Contributed by Ulrich Drepper <drepper@redhat.com>, 1998.
#include <gelf.h>
#include <errno.h>
+#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
ELF_E_INVALID_PHDR,
ELF_E_NO_PHDR,
ELF_E_INVALID_OFFSET,
+ ELF_E_INVALID_SECTION_TYPE,
+ ELF_E_INVALID_SECTION_FLAGS,
+ ELF_E_NOT_COMPRESSED,
+ ELF_E_ALREADY_COMPRESSED,
+ ELF_E_UNKNOWN_COMPRESSION_TYPE,
+ ELF_E_COMPRESS_ERROR,
+ ELF_E_DECOMPRESS_ERROR,
/* Keep this as the last entry. */
ELF_E_NUM
};
char *rawdata_base; /* The unmodified data of the section. */
char *data_base; /* The converted data of the section. */
+ char *zdata_base; /* The uncompressed data of the section. */
+ size_t zdata_size; /* If zdata_base != NULL, the size of data. */
+ size_t zdata_align; /* If zdata_base != NULL, the addralign. */
+
struct Elf_ScnList *list; /* Pointer to the section list element the
data is in. */
};
int ehdr_flags; /* Flags (dirty) for ELF header. */
int phdr_flags; /* Flags (dirty|malloc) for program header. */
int shdr_malloced; /* Nonzero if shdr array was allocated. */
- off64_t sizestr_offset; /* Offset of the size string in the parent
+ off_t sizestr_offset; /* Offset of the size string in the parent
if this is an archive member. */
} elf;
int ehdr_flags; /* Flags (dirty) for ELF header. */
int phdr_flags; /* Flags (dirty|malloc) for program header. */
int shdr_malloced; /* Nonzero if shdr array was allocated. */
- off64_t sizestr_offset; /* Offset of the size string in the parent
+ off_t sizestr_offset; /* Offset of the size string in the parent
if this is an archive member. */
Elf32_Ehdr ehdr_mem; /* Memory used for ELF header when not
mmaped. */
int ehdr_flags; /* Flags (dirty) for ELF header. */
int phdr_flags; /* Flags (dirty|malloc) for program header. */
int shdr_malloced; /* Nonzero if shdr array was allocated. */
- off64_t sizestr_offset; /* Offset of the size string in the parent
+ off_t sizestr_offset; /* Offset of the size string in the parent
if this is an archive member. */
Elf64_Ehdr ehdr_mem; /* Memory used for ELF header when not
mmaped. */
# define __libelf_type_align(class, type) 1
#endif
+/* Given an Elf handle and a section type returns the Elf_Data d_type.
+ Should not be called when SHF_COMPRESSED is set, the d_type should
+ be ELF_T_BYTE. */
+extern Elf_Type __libelf_data_type (Elf *elf, int sh_type) internal_function;
+
/* The libelf API does not have such a function but it is still useful.
Get the memory size for the given type.
attribute_hidden;
extern int __elf_getphdrnum_rdlock (Elf *__elf, size_t *__dst)
internal_function;
+extern int __elf_getphdrnum_chk_rdlock (Elf *__elf, size_t *__dst)
+ internal_function;
extern int __elf_getshdrnum_rdlock (Elf *__elf, size_t *__dst)
internal_function;
extern int __elf_getshdrstrndx_internal (Elf *__elf, size_t *__dst)
internal_function;
extern Elf_Data *__elf_rawdata_internal (Elf_Scn *__scn, Elf_Data *__data)
attribute_hidden;
+/* Should be called to setup first section data element if
+ data_list_rear is NULL and we know data_read is set and there is
+ raw data available. Might upgrade the ELF lock from a read to a
+ write lock. If the lock is already a write lock set wrlocked. */
+extern void __libelf_set_data_list_rdlock (Elf_Scn *scn, int wrlocked)
+ internal_function;
extern char *__elf_strptr_internal (Elf *__elf, size_t __index,
size_t __offset) attribute_hidden;
extern Elf_Data *__elf32_xlatetom_internal (Elf_Data *__dest,
extern uint32_t __libelf_crc32 (uint32_t crc, unsigned char *buf, size_t len)
attribute_hidden;
+extern void * __libelf_compress (Elf_Scn *scn, size_t hsize, int ei_data,
+ size_t *orig_size, size_t *orig_addralign,
+ size_t *size, bool force)
+ internal_function;
+
+extern void * __libelf_decompress (void *buf_in, size_t size_in,
+ size_t size_out) internal_function;
+extern void * __libelf_decompress_elf (Elf_Scn *scn,
+ size_t *size_out, size_t *addralign)
+ internal_function;
+
+
+extern void __libelf_reset_rawdata (Elf_Scn *scn, void *buf, size_t size,
+ size_t align, Elf_Type type)
+ internal_function;
+
/* We often have to update a flag iff a value changed. Make this
convenient. */