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

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