[Ltrace-devel] [PATCH] Avoid error during address translation in PPC backend

Andreas Schwab schwab at linux-m68k.org
Fri Jul 24 17:08:20 UTC 2015


Ignore addresses that are outside the bounds of .opd instead of returning
an error.
---
This has been tested on openSUSE 13.2.  Now I have to find out why
attach-process-dlopen.exp hangs on ppc64 and ppc64le when using gcc5.

Andreas.
---
 sysdeps/linux-gnu/ppc/plt.c | 22 +++++++++++++++-------
 1 file changed, 15 insertions(+), 7 deletions(-)

diff --git a/sysdeps/linux-gnu/ppc/plt.c b/sysdeps/linux-gnu/ppc/plt.c
index 5f81889..ee37a5e 100644
--- a/sysdeps/linux-gnu/ppc/plt.c
+++ b/sysdeps/linux-gnu/ppc/plt.c
@@ -324,10 +324,21 @@ int
 arch_translate_address(struct ltelf *lte,
 		       arch_addr_t addr, arch_addr_t *ret)
 {
-	if (lte->ehdr.e_machine == EM_PPC64
-	    && !lte->arch.elfv2_abi) {
-		/* XXX The double cast should be removed when
-		 * arch_addr_t becomes integral type.  */
+	/* Address translation is only needed on ppc64 with ELFv1 ABI.  */
+	if (lte->ehdr.e_machine != EM_PPC64 || lte->arch.elfv2_abi) {
+		*ret = addr;
+		return 0;
+	}
+
+	/* XXX The double cast should be removed when
+	 * arch_addr_t becomes integral type.  */
+	if ((GElf_Addr)(uintptr_t)addr < lte->arch.opd_base
+	    || ((GElf_Addr)(uintptr_t)addr
+		>= lte->arch.opd_base + lte->arch.opd_size - sizeof(uint64_t)))
+		/* If the address is outside the range of .opd
+		   return it unmodified.  */
+		*ret = addr;
+	else {
 		GElf_Xword offset
 			= (GElf_Addr)(uintptr_t)addr - lte->arch.opd_base;
 		uint64_t value;
@@ -337,10 +348,7 @@ arch_translate_address(struct ltelf *lte,
 			return -1;
 		}
 		*ret = (arch_addr_t)(uintptr_t)(value + lte->bias);
-		return 0;
 	}
-
-	*ret = addr;
 	return 0;
 }
 
-- 
2.4.6

-- 
Andreas Schwab, schwab at linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."



More information about the Ltrace-devel mailing list