This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH, MIPS] Support shared library debug with MIPS PIE (glibc)


Following on from binutils submission of DT_MIPS_RLD_MAP2:

http://sourceware.org/ml/binutils/2015-06/msg00226.html


It is not currently possible to extract dynamic linker maps for MIPS position
independent executables. MIPS does not use the DT_DEBUG tag as MIPS has a
read-only dynamic section and the MIPS specific DT_MIPS_RLD_MAP tag stores an
absolute address of the debug map pointer which is unusable for a PIE.
Following previous discussions we are introducing a new dynamic tag as defined
below.

New dynamic tag:

DT_MIPS_RLD_MAP2 - 0x70000035

Definition:

This member is used by debugging.  It contains a relative offset from the tag's
runtime location of a 32-bit word in the .data section which is supplied by the
compilation environment. The word's contents are not specified and programs
using this value are not ABI - compliant.

Manually tested with pre and post DT_MIPS_RLD_MAP2 executables alongside
Updated GDB.

OK to commit?

Thanks,
Matthew

	* elf/elf.h (DT_MIPS_RLD_MAP2): New macro.
	(DT_MIPS_NUM): Update.
	* sysdeps/mips/dl-machine.h (ELF_MACHINE_DEBUG_SETUP): Handle
	DT_MIPS_RLD_MAP2.

---
 elf/elf.h                 |  6 +++++-
 sysdeps/mips/dl-machine.h | 13 ++++++++++---
 2 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/elf/elf.h b/elf/elf.h
index 12feb91..51446f5 100644
--- a/elf/elf.h
+++ b/elf/elf.h
@@ -1727,7 +1727,11 @@ typedef struct
    PLT is writable.  For a non-writable PLT, this is omitted or has a zero
    value.  */
 #define DT_MIPS_RWPLT        0x70000034
-#define DT_MIPS_NUM	     0x35
+/* An alternative description of the classic MIPS RLD_MAP that is usable
+   in a PIE as it stores a relative offset from the address of the tag
+   rather than an absolute address.  */
+#define DT_MIPS_RLD_MAP2     0x70000035
+#define DT_MIPS_NUM	     0x36
 
 /* Legal values for DT_MIPS_FLAGS Elf32_Dyn entry.  */
 
diff --git a/sysdeps/mips/dl-machine.h b/sysdeps/mips/dl-machine.h
index d63238a..3677b64 100644
--- a/sysdeps/mips/dl-machine.h
+++ b/sysdeps/mips/dl-machine.h
@@ -68,10 +68,17 @@
    in l_info array.  */
 #define DT_MIPS(x) (DT_MIPS_##x - DT_LOPROC + DT_NUM)
 
-/* If there is a DT_MIPS_RLD_MAP entry in the dynamic section, fill it in
-   with the run-time address of the r_debug structure  */
+/* If there is a DT_MIPS_RLD_MAP2 or DT_MIPS_RLD_MAP entry in the dynamic
+   section, fill in the debug map pointer with the run-time address of the
+   r_debug structure.  */
 #define ELF_MACHINE_DEBUG_SETUP(l,r) \
-do { if ((l)->l_info[DT_MIPS (RLD_MAP)]) \
+do { if ((l)->l_info[DT_MIPS (RLD_MAP2)]) \
+       { \
+	 char *ptr = (char *)(l)->l_info[DT_MIPS (RLD_MAP2)]; \
+	 ptr += (l)->l_info[DT_MIPS (RLD_MAP2)]->d_un.d_val; \
+	 *(ElfW(Addr) *)ptr = (ElfW(Addr)) (r); \
+       } \
+     else if ((l)->l_info[DT_MIPS (RLD_MAP)]) \
        *(ElfW(Addr) *)((l)->l_info[DT_MIPS (RLD_MAP)]->d_un.d_ptr) = \
        (ElfW(Addr)) (r); \
    } while (0)
-- 
2.2.1


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]