summaryrefslogtreecommitdiffstats
path: root/libelf/elf_getarsym.c
diff options
context:
space:
mode:
Diffstat (limited to 'libelf/elf_getarsym.c')
-rw-r--r--libelf/elf_getarsym.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/libelf/elf_getarsym.c b/libelf/elf_getarsym.c
index 1ab94ca8..65c67cc8 100644
--- a/libelf/elf_getarsym.c
+++ b/libelf/elf_getarsym.c
@@ -201,11 +201,7 @@ elf_getarsym (Elf *elf, size_t *ptr)
elf->state.ar.ar_sym = (Elf_Arsym *) malloc (ar_sym_len);
if (elf->state.ar.ar_sym != NULL)
{
- union
- {
- uint32_t u32[n];
- uint64_t u64[n];
- } *file_data;
+ void *file_data; /* unit32_t[n] or uint64_t[n] */
char *str_data;
size_t sz = n * w;
@@ -267,12 +263,14 @@ elf_getarsym (Elf *elf, size_t *ptr)
/* Now we can build the data structure. */
Elf_Arsym *arsym = elf->state.ar.ar_sym;
+ uint64_t (*u64)[n] = file_data;
+ uint32_t (*u32)[n] = file_data;
for (size_t cnt = 0; cnt < n; ++cnt)
{
arsym[cnt].as_name = str_data;
if (index64_p)
{
- uint64_t tmp = file_data->u64[cnt];
+ uint64_t tmp = (*u64)[cnt];
if (__BYTE_ORDER == __LITTLE_ENDIAN)
tmp = bswap_64 (tmp);
@@ -294,9 +292,9 @@ elf_getarsym (Elf *elf, size_t *ptr)
}
}
else if (__BYTE_ORDER == __LITTLE_ENDIAN)
- arsym[cnt].as_off = bswap_32 (file_data->u32[cnt]);
+ arsym[cnt].as_off = bswap_32 ((*u32)[cnt]);
else
- arsym[cnt].as_off = file_data->u32[cnt];
+ arsym[cnt].as_off = (*u32)[cnt];
arsym[cnt].as_hash = _dl_elf_hash (str_data);
str_data = rawmemchr (str_data, '\0') + 1;