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