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

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