|
|
39d69a |
diff --git a/sysdeps/linux-gnu/ppc/plt.c b/sysdeps/linux-gnu/ppc/plt.c
|
|
|
39d69a |
index 45ed7fb..5f81889 100644
|
|
|
39d69a |
--- a/sysdeps/linux-gnu/ppc/plt.c
|
|
|
39d69a |
+++ b/sysdeps/linux-gnu/ppc/plt.c
|
|
|
39d69a |
@@ -274,14 +274,15 @@ arch_plt_sym_val(struct ltelf *lte, size_t ndx, GElf_Rela *rela)
|
|
|
39d69a |
|
|
|
39d69a |
assert(rela->r_addend != 0);
|
|
|
39d69a |
/* XXX double cast */
|
|
|
39d69a |
- arch_addr_t res_addr = (arch_addr_t) (uintptr_t) rela->r_addend;
|
|
|
39d69a |
+ arch_addr_t res_addr
|
|
|
39d69a |
+ = (arch_addr_t) (uintptr_t) (rela->r_addend + lte->bias);
|
|
|
39d69a |
if (arch_translate_address(lte, res_addr, &res_addr) < 0) {
|
|
|
39d69a |
fprintf(stderr, "Couldn't OPD-translate IRELATIVE "
|
|
|
39d69a |
"resolver address.\n");
|
|
|
39d69a |
return 0;
|
|
|
39d69a |
}
|
|
|
39d69a |
/* XXX double cast */
|
|
|
39d69a |
- return (GElf_Addr) (uintptr_t) res_addr;
|
|
|
39d69a |
+ return (GElf_Addr) (uintptr_t) (res_addr - lte->bias);
|
|
|
39d69a |
|
|
|
39d69a |
} else {
|
|
|
39d69a |
/* We put brakpoints to PLT entries the same as the
|
|
|
39d69a |
@@ -453,7 +454,7 @@ arch_elf_init(struct ltelf *lte, struct library *lib)
|
|
|
39d69a |
#ifndef EF_PPC64_ABI
|
|
|
39d69a |
assert (! (lte->ehdr.e_flags & 3 ) == 2)
|
|
|
39d69a |
#else
|
|
|
39d69a |
- lte->arch.elfv2_abi=((lte->ehdr.e_flags & EF_PPC64_ABI) == 2) ;
|
|
|
39d69a |
+ lte->arch.elfv2_abi = ((lte->ehdr.e_flags & EF_PPC64_ABI) == 2);
|
|
|
39d69a |
#endif
|
|
|
39d69a |
|
|
|
39d69a |
if (lte->ehdr.e_machine == EM_PPC64
|
|
|
39d69a |
@@ -827,15 +828,15 @@ arch_elf_add_plt_entry(struct process *proc, struct ltelf *lte,
|
|
|
39d69a |
assert(plt_slot_addr >= lte->plt_addr
|
|
|
39d69a |
|| plt_slot_addr < lte->plt_addr + lte->plt_size);
|
|
|
39d69a |
|
|
|
39d69a |
+ plt_entry_addr += lte->bias;
|
|
|
39d69a |
+ plt_slot_addr += lte->bias;
|
|
|
39d69a |
+
|
|
|
39d69a |
/* Should avoid to do read if dynamic linker hasn't run yet
|
|
|
39d69a |
* or allow -1 a valid return code. */
|
|
|
39d69a |
GElf_Addr plt_slot_value;
|
|
|
39d69a |
- if (read_plt_slot_value(proc, plt_slot_addr, &plt_slot_value) < 0) {
|
|
|
39d69a |
- if (!lte->arch.elfv2_abi)
|
|
|
39d69a |
- goto fail;
|
|
|
39d69a |
- else
|
|
|
39d69a |
- return PPC_PLT_UNRESOLVED;
|
|
|
39d69a |
- }
|
|
|
39d69a |
+ int rc = read_plt_slot_value(proc, plt_slot_addr, &plt_slot_value);
|
|
|
39d69a |
+ if (rc < 0 && !lte->arch.elfv2_abi)
|
|
|
39d69a |
+ goto fail;
|
|
|
39d69a |
|
|
|
39d69a |
struct library_symbol *libsym = malloc(sizeof(*libsym));
|
|
|
39d69a |
if (libsym == NULL) {
|
|
|
39d69a |
@@ -854,8 +855,9 @@ arch_elf_add_plt_entry(struct process *proc, struct ltelf *lte,
|
|
|
39d69a |
goto fail2;
|
|
|
39d69a |
libsym->arch.plt_slot_addr = plt_slot_addr;
|
|
|
39d69a |
|
|
|
39d69a |
- if (! is_irelative
|
|
|
39d69a |
- && (plt_slot_value == plt_entry_addr || plt_slot_value == 0)) {
|
|
|
39d69a |
+ if (rc < 0 || (! is_irelative
|
|
|
39d69a |
+ && (plt_slot_value == plt_entry_addr
|
|
|
39d69a |
+ || plt_slot_value == 0))) {
|
|
|
39d69a |
libsym->arch.type = PPC_PLT_UNRESOLVED;
|
|
|
39d69a |
libsym->arch.resolved_value = plt_entry_addr;
|
|
|
39d69a |
} else {
|
|
|
39d69a |
@@ -1166,8 +1168,8 @@ ppc_plt_bp_install(struct breakpoint *bp, struct process *proc)
|
|
|
39d69a |
libsym->arch.resolved_value = plt_entry_addr;
|
|
|
39d69a |
}
|
|
|
39d69a |
} else {
|
|
|
39d69a |
- fprintf(stderr, "Couldn't unresolve %s@%p. Not tracing"
|
|
|
39d69a |
- " this symbol.\n",
|
|
|
39d69a |
+ fprintf(stderr, "Couldn't unresolve %s@%p. Will not"
|
|
|
39d69a |
+ " trace this symbol.\n",
|
|
|
39d69a |
breakpoint_name(bp), bp->addr);
|
|
|
39d69a |
proc_remove_breakpoint(proc, bp);
|
|
|
39d69a |
}
|
|
|
39d69a |
@@ -1222,6 +1224,14 @@ arch_library_symbol_clone(struct library_symbol *retp,
|
|
|
39d69a |
struct library_symbol *libsym)
|
|
|
39d69a |
{
|
|
|
39d69a |
retp->arch = libsym->arch;
|
|
|
39d69a |
+ if (libsym->arch.type == PPC_PLT_NEED_UNRESOLVE) {
|
|
|
39d69a |
+ assert(libsym->arch.data->self == libsym->arch.data);
|
|
|
39d69a |
+ retp->arch.data = malloc(sizeof *retp->arch.data);
|
|
|
39d69a |
+ if (retp->arch.data == NULL)
|
|
|
39d69a |
+ return -1;
|
|
|
39d69a |
+ *retp->arch.data = *libsym->arch.data;
|
|
|
39d69a |
+ retp->arch.data->self = retp->arch.data;
|
|
|
39d69a |
+ }
|
|
|
39d69a |
return 0;
|
|
|
39d69a |
}
|
|
|
39d69a |
|