diff options
| author | Mark Wielaard <[email protected]> | 2015-12-19 01:29:54 +0100 |
|---|---|---|
| committer | Mark Wielaard <[email protected]> | 2016-01-06 14:27:10 +0100 |
| commit | 272018bba1f253bae00b5ba280ad0e0f18c04006 (patch) | |
| tree | f0b20b43f9caf6d193ae9c05f5583699f34bc59d /libelf/elf_getdata.c | |
| parent | b7105b40ccd73a8e6b7fce6c11d2088eb1298b33 (diff) | |
libelf: Add elf_compress and elf_compress_gnu.
Signed-off-by: Mark Wielaard <[email protected]>
Diffstat (limited to 'libelf/elf_getdata.c')
| -rw-r--r-- | libelf/elf_getdata.c | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/libelf/elf_getdata.c b/libelf/elf_getdata.c index bd1f0682..4ec94b98 100644 --- a/libelf/elf_getdata.c +++ b/libelf/elf_getdata.c @@ -118,6 +118,22 @@ const uint_fast8_t __libelf_type_aligns[EV_NUM - 1][ELFCLASSNUM - 1][ELF_T_NUM] #endif +Elf_Type +internal_function +__libelf_data_type (Elf *elf, int sh_type) +{ + /* Some broken ELF ABI for 64-bit machines use the wrong hash table + entry size. See elf-knowledge.h for more information. */ + if (sh_type == SHT_HASH && elf->class == ELFCLASS64) + { + GElf_Ehdr ehdr_mem; + GElf_Ehdr *ehdr = __gelf_getehdr_rdlock (elf, &ehdr_mem); + return (SH_ENTSIZE_HASH (ehdr) == 4 ? ELF_T_WORD : ELF_T_XWORD); + } + else + return shtype_map[LIBELF_EV_IDX][TYPEIDX (sh_type)]; +} + /* Convert the data in the current section. */ static void convert_data (Elf_Scn *scn, int version __attribute__ ((unused)), int eclass, @@ -332,17 +348,8 @@ __libelf_set_rawdata_wrlock (Elf_Scn *scn) section type. */ if ((flags & SHF_COMPRESSED) != 0) scn->rawdata.d.d_type = ELF_T_CHDR; - else if (type == SHT_HASH && elf->class == ELFCLASS64) - { - /* Some broken ELF ABI for 64-bit machines use the wrong hash table - entry size. See elf-knowledge.h for more information. */ - GElf_Ehdr ehdr_mem; - GElf_Ehdr *ehdr = __gelf_getehdr_rdlock (elf, &ehdr_mem); - scn->rawdata.d.d_type - = (SH_ENTSIZE_HASH (ehdr) == 4 ? ELF_T_WORD : ELF_T_XWORD); - } else - scn->rawdata.d.d_type = shtype_map[LIBELF_EV_IDX][TYPEIDX (type)]; + scn->rawdata.d.d_type = __libelf_data_type (elf, type); scn->rawdata.d.d_off = 0; /* Make sure the alignment makes sense. d_align should be aligned both |
