Blame SOURCES/ltrace-0.7.91-ppc-bias.patch

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