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