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

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