mirror of
https://github.com/sstefani/mtrace.git
synced 2025-12-06 16:56:41 +08:00
fix auxv parser
This commit is contained in:
parent
badc8d24fd
commit
42e3f9ad79
@ -350,29 +350,17 @@ static int (*rdebug_fetcher(struct task *task))(struct task *, arch_addr_t, stru
|
|||||||
return select_32_64(task, fetch_rd32, fetch_rd64);
|
return select_32_64(task, fetch_rd32, fetch_rd64);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int fetch_auxv64_entry(int fd, Elf64_auxv_t *ret)
|
#ifdef _LP64
|
||||||
|
#define Elf_auxv_t Elf64_auxv_t
|
||||||
|
#else
|
||||||
|
#define Elf_auxv_t Elf32_auxv_t
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static int fetch_auxv_entry(int fd, Elf_auxv_t *ret)
|
||||||
{
|
{
|
||||||
/* Reaching EOF is as much problem as not reading whole
|
|
||||||
* entry. */
|
|
||||||
return read(fd, ret, sizeof(*ret)) == sizeof(*ret) ? 0 : -1;
|
return read(fd, ret, sizeof(*ret)) == sizeof(*ret) ? 0 : -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int fetch_auxv32_entry(int fd, Elf64_auxv_t *ret)
|
|
||||||
{
|
|
||||||
Elf32_auxv_t auxv;
|
|
||||||
|
|
||||||
if (read(fd, &auxv, sizeof(auxv)) != sizeof(auxv))
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
ret->a_type = auxv.a_type;
|
|
||||||
ret->a_un.a_val = auxv.a_un.a_val;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int (*auxv_fetcher(struct task *task)) (int, Elf64_auxv_t *) {
|
|
||||||
return select_32_64(task, fetch_auxv32_entry, fetch_auxv64_entry);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void linkmap_add(struct task *task, struct lt_r_debug_64 *dbg)
|
static void linkmap_add(struct task *task, struct lt_r_debug_64 *dbg)
|
||||||
{
|
{
|
||||||
struct library *lib;
|
struct library *lib;
|
||||||
@ -575,8 +563,9 @@ int process_get_entry(struct task *task, unsigned long *entryp, unsigned long *i
|
|||||||
GElf_Addr at_bias = 0;
|
GElf_Addr at_bias = 0;
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
Elf64_auxv_t entry = { };
|
Elf_auxv_t entry = { };
|
||||||
if (auxv_fetcher(task)(fd, &entry) < 0)
|
|
||||||
|
if (fetch_auxv_entry(fd, &entry) < 0)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
if (entry.a_type == AT_NULL)
|
if (entry.a_type == AT_NULL)
|
||||||
@ -589,8 +578,6 @@ int process_get_entry(struct task *task, unsigned long *entryp, unsigned long *i
|
|||||||
case AT_ENTRY:
|
case AT_ENTRY:
|
||||||
at_entry = entry.a_un.a_val;
|
at_entry = entry.a_un.a_val;
|
||||||
break;
|
break;
|
||||||
case AT_NULL:
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user