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