summaryrefslogtreecommitdiff
path: root/libelf/elf_getdata.c
diff options
context:
space:
mode:
Diffstat (limited to 'libelf/elf_getdata.c')
-rw-r--r--libelf/elf_getdata.c27
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