mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Felix Fietkau <nbd@openwrt.org>
To: musl@lists.openwall.com
Subject: [PATCH v3] ldso: fix GDB dynamic linker info on MIPS
Date: Sat, 30 Jan 2016 21:14:05 +0100	[thread overview]
Message-ID: <1454184845-96384-1-git-send-email-nbd@openwrt.org> (raw)

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      |  2 +-
 ldso/dynlink.c         | 11 +++++++----
 src/internal/dynlink.h |  4 ++++
 3 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/arch/mips/reloc.h b/arch/mips/reloc.h
index 9b40e3d..8c52df0 100644
--- a/arch/mips/reloc.h
+++ b/arch/mips/reloc.h
@@ -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__( \
diff --git a/ldso/dynlink.c b/ldso/dynlink.c
index f497542..87f3b7f 100644
--- a/ldso/dynlink.c
+++ b/ldso/dynlink.c
@@ -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. */
diff --git a/src/internal/dynlink.h b/src/internal/dynlink.h
index 9c494e4..48890b2 100644
--- a/src/internal/dynlink.h
+++ b/src/internal/dynlink.h
@@ -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
 
-- 
2.2.2



             reply	other threads:[~2016-01-30 20:14 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-30 20:14 Felix Fietkau [this message]
2016-01-31  1:58 ` Rich Felker

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1454184845-96384-1-git-send-email-nbd@openwrt.org \
    --to=nbd@openwrt.org \
    --cc=musl@lists.openwall.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).