Blame SOURCES/ltrace-0.7.91-ppc64-fork.patch

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