[Ltrace-devel] [PATCH v1 3/6] Make finding the dynamic linkers debug area arch specfic

edgar.iglesias at gmail.com edgar.iglesias at gmail.com
Tue Oct 9 12:50:32 UTC 2012


From: "Edgar E. Iglesias" <edgar at axis.com>

Make it possible for archs to override the lookup of the
dynamic linkers debug area.

Signed-off-by: Edgar E. Iglesias <edgar at axis.com>
---
 backend.h                |   11 +++++++++++
 sysdeps/linux-gnu/proc.c |   12 ++++++++++--
 2 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/backend.h b/backend.h
index 8b4e8fa..bf0d850 100644
--- a/backend.h
+++ b/backend.h
@@ -312,6 +312,17 @@ void arch_dynlink_done(struct Process *proc);
  * ARCH_HAVE_SYMBOL_RET.  It is called after a traced call returns.  */
 void arch_symbol_ret(struct Process *proc, struct library_symbol *libsym);
 
+
+/* This callback needs to be implemented if arch.h defines
+ * ARCH_HAVE_FIND_DL_DEBUG.
+ * It is called by generic code to find the address of the dynamic
+ * linkers debug structure.
+ * DYN_ADDR holds the address of the dynamic section.
+ * If the debug area is found, return 0 and fill in the address in *RET.
+ * If the debug area is not found, return a negative value.  */
+int arch_find_dl_debug(struct Process *proc, arch_addr_t dyn_addr,
+		       arch_addr_t *ret);
+
 /* If arch.h defines ARCH_HAVE_FETCH_ARG, the following callbacks have
  * to be implemented: arch_fetch_arg_init, arch_fetch_arg_clone,
  * arch_fetch_arg_done, arch_fetch_arg_next and arch_fetch_retval.
diff --git a/sysdeps/linux-gnu/proc.c b/sysdeps/linux-gnu/proc.c
index cc322fa..1dfcc7e 100644
--- a/sysdeps/linux-gnu/proc.c
+++ b/sysdeps/linux-gnu/proc.c
@@ -560,6 +560,15 @@ rdebug_bp_on_hit(struct breakpoint *bp, struct Process *proc)
 	debug->state = rdbg.r_state;
 }
 
+#ifndef ARCH_HAVE_FIND_DL_DEBUG
+int
+arch_find_dl_debug(struct Process *proc, arch_addr_t dyn_addr,
+		   arch_addr_t *ret)
+{
+	return proc_find_dynamic_entry_addr(proc, dyn_addr, DT_DEBUG, ret);
+}
+#endif
+
 int
 linkmap_init(struct Process *proc, arch_addr_t dyn_addr)
 {
@@ -576,8 +585,7 @@ linkmap_init(struct Process *proc, arch_addr_t dyn_addr)
 	}
 	proc->debug = debug;
 
-	if (find_dynamic_entry_addr(proc, dyn_addr, DT_DEBUG,
-				    &debug->debug_addr) == -1) {
+	if (arch_find_dl_debug(proc, dyn_addr, &debug->debug_addr) == -1) {
 		debug(2, "Couldn't find debug structure!");
 		goto fail;
 	}
-- 
1.7.8.6




More information about the Ltrace-devel mailing list