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