switch (bits)
{
case 32:;
- Elf32_Word val32;
- reg_desc = gelf_convert (core, ELF_T_WORD, ELF_T_WORD, &val32,
- reg_desc);
- /* NULL REG_DESC is caught below. */
+ uint32_t val32 = *(const uint32_t *) reg_desc;
+ reg_desc += sizeof (val32);
+ val32 = (elf_getident (core, NULL)[EI_DATA] == ELFDATA2MSB
+ ? be32toh (val32) : le32toh (val32));
/* Do a host width conversion. */
val = val32;
break;
case 64:;
- Elf64_Xword val64;
- reg_desc = gelf_convert (core, ELF_T_XWORD, ELF_T_XWORD, &val64,
- reg_desc);
- /* NULL REG_DESC is caught below. */
+ uint64_t val64 = *(const uint64_t *) reg_desc;
+ reg_desc += sizeof (val64);
+ val64 = (elf_getident (core, NULL)[EI_DATA] == ELFDATA2MSB
+ ? be64toh (val64) : le64toh (val64));
val = val64;
break;
default:
abort ();
}
- if (reg_desc == NULL)
- continue;
*core_pc = val;
return true;
}
for (item = items; item < items + nitems; item++)
if (strcmp (item->name, "pid") == 0)
break;
- Elf32_Sword val32s;
- if (item == items + nitems
- || gelf_convert (core, ELF_T_SWORD, item->type, &val32s,
- desc + item->offset)
- == NULL)
+ if (item == items + nitems)
{
process_free (process);
__libdwfl_seterrno (DWFL_E_BADELF);
return NULL;
}
- pid_t tid = val32s;
- eu_static_assert (sizeof val32s <= sizeof tid);
+ uint32_t val32 = *(const uint32_t *) (desc + item->offset);
+ val32 = (elf_getident (core, NULL)[EI_DATA] == ELFDATA2MSB
+ ? be32toh (val32) : le32toh (val32));
+ pid_t tid = (int32_t) val32;
+ eu_static_assert (sizeof val32 <= sizeof tid);
if (thread)
{
/* Delay initialization of THREAD till all notes for it have
switch (regloc->bits)
{
case 32:;
- Elf32_Word val32;
- reg_desc = gelf_convert (core, ELF_T_WORD, ELF_T_WORD,
- &val32, reg_desc);
- /* NULL REG_DESC is caught below. */
+ uint32_t val32 = *(const uint32_t *) reg_desc;
+ val32 = (elf_getident (core, NULL)[EI_DATA] == ELFDATA2MSB
+ ? be32toh (val32) : le32toh (val32));
/* Do a host width conversion. */
val = val32;
break;
case 64:;
- Elf64_Xword val64;
- reg_desc = gelf_convert (core, ELF_T_XWORD, ELF_T_XWORD,
- &val64, reg_desc);
- /* NULL REG_DESC is caught below. */
+ uint64_t val64 = *(const uint64_t *) reg_desc;
+ val64 = (elf_getident (core, NULL)[EI_DATA] == ELFDATA2MSB
+ ? be64toh (val64) : le64toh (val64));
assert (sizeof (*state->regs) == sizeof (val64));
val = val64;
break;
default:
abort ();
}
- if (reg_desc == NULL)
- {
- process_free (process);
- __libdwfl_seterrno (DWFL_E_BADELF);
- return NULL;
- }
/* Registers not valid for CFI are just ignored. */
dwfl_frame_state_reg_set (state, regno, val);
reg_desc += regloc->pad;
elf32_offscn.c elf64_offscn.c gelf_offscn.c \
elf_getaroff.c \
elf_gnu_hash.c \
- elf_scnshndx.c gelf_convert.c
+ elf_scnshndx.c
if !MUDFLAP
libelf_pic_a_SOURCES =
+++ /dev/null
-/* Convert DATA from ELF to VALUE in host memory.
- Copyright (C) 2012 Red Hat, Inc.
- This file is part of elfutils.
-
- This file is free software; you can redistribute it and/or modify
- it under the terms of either
-
- * the GNU Lesser General Public License as published by the Free
- Software Foundation; either version 3 of the License, or (at
- your option) any later version
-
- or
-
- * the GNU General Public License as published by the Free
- Software Foundation; either version 2 of the License, or (at
- your option) any later version
-
- or both in parallel, as here.
-
- elfutils is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received copies of the GNU General Public License and
- the GNU Lesser General Public License along with this program. If
- not, see <http://www.gnu.org/licenses/>. */
-
-#include "libelfP.h"
-
-const void *
-gelf_convert (Elf *elf, Elf_Type valuetype, Elf_Type datatype, void *value,
- const void *data)
-{
- Elf_Data valuedata =
- {
- .d_type = valuetype,
- .d_buf = value,
- .d_size = gelf_fsize (elf, valuetype, 1, EV_CURRENT),
- .d_version = EV_CURRENT,
- };
- Elf_Data indata =
- {
- .d_type = datatype,
- .d_buf = (void *) data,
- .d_size = valuedata.d_size,
- .d_version = EV_CURRENT,
- };
-
- Elf_Data *d = gelf_xlatetom (elf, &valuedata, &indata,
- elf_getident (elf, NULL)[EI_DATA]);
- if (d == NULL)
- return NULL;
-
- return data + indata.d_size;
-}
extern unsigned long int elf_gnu_hash (const char *__string)
__attribute__ ((__pure__));
-/* Convert DATA from ELF to VALUE in host memory. Return NULL on error,
- otherwise th updated DATA pointer. */
-extern const void *gelf_convert (Elf *elf, Elf_Type valuetype,
- Elf_Type datatype, void *value,
- const void *data);
-
/* Compute simple checksum from permanent parts of the ELF file. */
extern long int elf32_checksum (Elf *__elf);
global:
elf_getphdrnum;
} ELFUTILS_1.5;
-
-ELFUTILS_0.155 {
- global:
- gelf_convert;
-} ELFUTILS_1.6;