mipsel: Add a MIPS specific find_dl_debug

MIPS dynamic loaders put the address of their debug areas
into an DT_MIPS_RLD_MAP entry instead of into the DT_DEBUG
entry.

Signed-off-by: Edgar E. Iglesias <edgar@axis.com>
diff --git a/sysdeps/linux-gnu/mipsel/arch.h b/sysdeps/linux-gnu/mipsel/arch.h
index e9a8962..4fa3a93 100644
--- a/sysdeps/linux-gnu/mipsel/arch.h
+++ b/sysdeps/linux-gnu/mipsel/arch.h
@@ -39,6 +39,7 @@
 	size_t mips_gotsym;
 };
 
+#define ARCH_HAVE_FIND_DL_DEBUG
 #define ARCH_HAVE_GET_SYMINFO
 #define ARCH_HAVE_DYNLINK_DONE
 #define ARCH_HAVE_ADD_PLT_ENTRY
diff --git a/sysdeps/linux-gnu/mipsel/plt.c b/sysdeps/linux-gnu/mipsel/plt.c
index 6684867..f49f04f 100644
--- a/sysdeps/linux-gnu/mipsel/plt.c
+++ b/sysdeps/linux-gnu/mipsel/plt.c
@@ -84,6 +84,29 @@
     return (void *)ret;;
 }
 
+/* Address of run time loader map, used for debugging.  */
+#define DT_MIPS_RLD_MAP         0x70000016
+int
+arch_find_dl_debug(struct Process *proc, arch_addr_t dyn_addr,
+		   arch_addr_t *ret)
+{
+	arch_addr_t rld_addr;
+	int r;
+
+	/* MIPS puts the address of the r_debug structure into the
+	 * DT_MIPS_RLD_MAP entry instead of into the DT_DEBUG entry.  */
+	r = proc_find_dynamic_entry_addr(proc, dyn_addr,
+					 DT_MIPS_RLD_MAP, &rld_addr);
+	if (r == 0) {
+		if (umovebytes(proc, rld_addr,
+			       ret, sizeof *ret) != sizeof *ret) {
+			r = -1;
+		}
+	}
+	return r;
+}
+
+
 /*
  * MIPS doesn't have traditional got.plt entries with corresponding
  * relocations.