ldso: fix GDB dynamic linker info on MIPS
authorFelix Fietkau <nbd@openwrt.org>
Sat, 30 Jan 2016 20:14:05 +0000 (21:14 +0100)
committerRich Felker <dalias@aerifal.cx>
Sun, 31 Jan 2016 01:55:22 +0000 (20:55 -0500)
GDB is looking for a pointer to the ldso debug info in the data of the
..rld_map section.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
arch/mips/reloc.h
ldso/dynlink.c
src/internal/dynlink.h

index 9b40e3da74b66f9978ddc0ca09a5a64f6420d2d9..8c52df091c72c94867f6fcbc0ba8869cdbf64715 100644 (file)
@@ -24,7 +24,7 @@
 #define REL_TPOFF       R_MIPS_TLS_TPREL32
 
 #define NEED_MIPS_GOT_RELOCS 1
-#define DYNAMIC_IS_RO 1
+#define DT_DEBUG_INDIRECT DT_MIPS_RLD_MAP
 #define ARCH_SYM_REJECT_UND(s) (!((s)->st_other & STO_MIPS_PLT))
 
 #define CRTJMP(pc,sp) __asm__ __volatile__( \
index f497542e96a68d5373c40057831a14cc62fbfcfa..87f3b7f8cd47bc3bc6e358e22c7411bf281e1c08 100644 (file)
@@ -1582,11 +1582,14 @@ _Noreturn void __dls3(size_t *sp)
        load_deps(&app);
        make_global(&app);
 
-#ifndef DYNAMIC_IS_RO
-       for (i=0; app.dynv[i]; i+=2)
-               if (app.dynv[i]==DT_DEBUG)
+       for (i=0; app.dynv[i]; i+=2) {
+               if (!DT_DEBUG_INDIRECT && app.dynv[i]==DT_DEBUG)
                        app.dynv[i+1] = (size_t)&debug;
-#endif
+               if (DT_DEBUG_INDIRECT && app.dynv[i]==DT_DEBUG_INDIRECT) {
+                       size_t *ptr = (size_t *) app.dynv[i+1];
+                       *ptr = (size_t)&debug;
+               }
+       }
 
        /* The main program must be relocated LAST since it may contin
         * copy relocations which depend on libraries' relocations. */
index 9c494e43966e0d7f0c80b621c6178f5cc4871a6d..48890b2db50ec5bc6178b506964c6eb900f6bdb4 100644 (file)
@@ -83,6 +83,10 @@ struct fdpic_dummy_loadmap {
 #define NEED_MIPS_GOT_RELOCS 0
 #endif
 
+#ifndef DT_DEBUG_INDIRECT
+#define DT_DEBUG_INDIRECT 0
+#endif
+
 #define AUX_CNT 32
 #define DYN_CNT 32