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