diff options
author | Petr Machata <pmachata@redhat.com> | 2013-10-25 23:50:18 +0200 |
---|---|---|
committer | Petr Machata <pmachata@redhat.com> | 2013-10-25 23:59:11 +0200 |
commit | b061bae322edd4894f14ea2aea6baec36d32eda8 (patch) | |
tree | 5272e984f3680940cb0149fc0e7bf75fea7a4a98 | |
parent | 673ff510953b65b844a58478aa434120f457c014 (diff) | |
download | ltrace-b061bae322edd4894f14ea2aea6baec36d32eda8.tar.gz |
Split linux_elf_find_irelative_name out of linux_elf_add_plt_entry_irelative
-rw-r--r-- | sysdeps/linux-gnu/trace.c | 24 | ||||
-rw-r--r-- | sysdeps/linux-gnu/trace.h | 6 |
2 files changed, 21 insertions, 9 deletions
diff --git a/sysdeps/linux-gnu/trace.c b/sysdeps/linux-gnu/trace.c index 8c6bdfb..dfdd55b 100644 --- a/sysdeps/linux-gnu/trace.c +++ b/sysdeps/linux-gnu/trace.c @@ -1252,17 +1252,14 @@ irelative_name_cb(GElf_Sym *symbol, const char *name, void *d) return CBS_CONT; } -enum plt_status -linux_elf_add_plt_entry_irelative(struct process *proc, struct ltelf *lte, - GElf_Rela *rela, size_t ndx, - struct library_symbol **ret) - +char * +linux_elf_find_irelative_name(struct ltelf *lte, GElf_Rela *rela) { struct irelative_name_data_t data = { rela->r_addend, NULL }; if (rela->r_addend != 0 && elf_each_symbol(lte, 0, irelative_name_cb, &data).status < 0) - return -1; + return NULL; const char *name; if (data.found_name != NULL) { @@ -1277,8 +1274,17 @@ linux_elf_add_plt_entry_irelative(struct process *proc, struct ltelf *lte, #undef NAME } - if (default_elf_add_plt_entry(proc, lte, name, rela, ndx, ret) < 0) - return PLT_FAIL; + return strdup(name); +} - return PLT_OK; +enum plt_status +linux_elf_add_plt_entry_irelative(struct process *proc, struct ltelf *lte, + GElf_Rela *rela, size_t ndx, + struct library_symbol **ret) + +{ + char *name = linux_elf_find_irelative_name(lte, rela); + int i = default_elf_add_plt_entry(proc, lte, name, rela, ndx, ret); + free(name); + return i < 0 ? PLT_FAIL : PLT_OK; } diff --git a/sysdeps/linux-gnu/trace.h b/sysdeps/linux-gnu/trace.h index bb52122..d2740ac 100644 --- a/sysdeps/linux-gnu/trace.h +++ b/sysdeps/linux-gnu/trace.h @@ -136,4 +136,10 @@ enum plt_status linux_elf_add_plt_entry_irelative(struct process *proc, GElf_Rela *rela, size_t ndx, struct library_symbol **ret); +/* Service routine of the above. Determines a name corresponding to + * RELA, or invents a new one. Returns NULL on failures, otherwise it + * returns a malloc'd pointer that the caller is responsible for + * freeing. */ +char *linux_elf_find_irelative_name(struct ltelf *lte, GElf_Rela *rela); + #endif /* _LTRACE_LINUX_TRACE_H_ */ |