Petr Machata 2128805
From 35742523e3daa0e59de0c1c3fdd8e5ff52891967 Mon Sep 17 00:00:00 2001
Petr Machata 2128805
From: Petr Machata <pmachata@redhat.com>
Petr Machata 2128805
Date: Thu, 9 Jan 2014 23:41:50 +0100
Petr Machata 2128805
Subject: [PATCH] Fix a problem in tracing across fork on PPC64
Petr Machata 2128805
Petr Machata 2128805
In order to avoid single-stepping through large portions of the
Petr Machata 2128805
dynamic linker, ltrace remembers at which address the instruction that
Petr Machata 2128805
resolved a PLT slot is.  It then puts a breakpoint to this address so
Petr Machata 2128805
that it can fast-forward to that address next time it needs to catch a
Petr Machata 2128805
PLT slot being resolved.
Petr Machata 2128805
Petr Machata 2128805
When a process is cloned, the pointer to this breakpoint is simply
Petr Machata 2128805
copied over to the new process, instead of being looked up in the new
Petr Machata 2128805
process structures.  This patches fixes this.
Petr Machata 2128805
---
Petr Machata 2128805
 sysdeps/linux-gnu/ppc/plt.c |   14 +++++++++++++-
Petr Machata 2128805
 1 files changed, 13 insertions(+), 1 deletions(-)
Petr Machata 2128805
Petr Machata 2128805
diff --git a/sysdeps/linux-gnu/ppc/plt.c b/sysdeps/linux-gnu/ppc/plt.c
Petr Machata 2128805
index 3ec1397..8715da6 100644
Petr Machata 2128805
--- a/sysdeps/linux-gnu/ppc/plt.c
Petr Machata 2128805
+++ b/sysdeps/linux-gnu/ppc/plt.c
Petr Machata 2128805
@@ -1,6 +1,6 @@
Petr Machata 2128805
 /*
Petr Machata 2128805
  * This file is part of ltrace.
Petr Machata 2128805
- * Copyright (C) 2012,2013 Petr Machata, Red Hat Inc.
Petr Machata 2128805
+ * Copyright (C) 2012,2013,2014 Petr Machata, Red Hat Inc.
Petr Machata 2128805
  * Copyright (C) 2004,2008,2009 Juan Cespedes
Petr Machata 2128805
  * Copyright (C) 2006 Paul Gilliam
Petr Machata 2128805
  *
Petr Machata 2128805
@@ -1157,6 +1157,18 @@ int
Petr Machata 2128805
 arch_process_clone(struct process *retp, struct process *proc)
Petr Machata 2128805
 {
Petr Machata 2128805
 	retp->arch = proc->arch;
Petr Machata 2128805
+
Petr Machata 2128805
+	if (retp->arch.dl_plt_update_bp != NULL) {
Petr Machata 2128805
+		/* Point it to the corresponding breakpoint in RETP.
Petr Machata 2128805
+		 * It must be there, this part of PROC has already
Petr Machata 2128805
+		 * been cloned to RETP.  */
Petr Machata 2128805
+		retp->arch.dl_plt_update_bp
Petr Machata 2128805
+			= address2bpstruct(retp,
Petr Machata 2128805
+					   retp->arch.dl_plt_update_bp->addr);
Petr Machata 2128805
+
Petr Machata 2128805
+		assert(retp->arch.dl_plt_update_bp != NULL);
Petr Machata 2128805
+	}
Petr Machata 2128805
+
Petr Machata 2128805
 	return 0;
Petr Machata 2128805
 }
Petr Machata 2128805
 
Petr Machata 2128805
-- 
Petr Machata 2128805
1.7.6.5
Petr Machata 2128805