mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Rich Felker <dalias@libc.org>
To: d.dorau@avm.de
Cc: musl@lists.openwall.com
Subject: Re: [musl] Tracking shared libraries in GDB not working?
Date: Sun, 9 Jan 2022 00:14:08 -0500	[thread overview]
Message-ID: <20220109051408.GQ7074@brightrain.aerifal.cx> (raw)
In-Reply-To: <OFE57EEAE8.27A5D6B9-ONC12587B1.0030F359-C12587B1.0030F35E@avm.de>

[-- Attachment #1: Type: text/plain, Size: 947 bytes --]

On Mon, Dec 20, 2021 at 09:54:40AM +0100, d.dorau@avm.de wrote:
> Thanks for your thoughts. I used them to search for further information and found
> the missing piece:
> 
> https://lists.yoctoproject.org/g/yocto/message/48584
> 
> I applied that first patch
> https://lists.yoctoproject.org/g/yocto/attachment/48584/0/0007-Teach-dynlink.c-about-DT_MIPS_RLD_MAP_REL.patch
> 
> and apparently it seems to solve the issue. :-)
> 
> I did a search on this mailing list and couldn't find this patch mentioned here.
> Maybe you can include this patch in a future release if you think the solution is correct.

Thanks! This patch is not correct as-is, because the value of
DT_MIPS_RLD_MAP_REL is only meaningful on mips and could be reused on
other archs. But I've whipped up what I think is a correct version of
it here (attached), using the same approach as used for
DT_MIPS_RLD_MAP already. If you get a chance, please let me know if it
works.

Rich

[-- Attachment #2: mips_pie_debug.diff --]
[-- Type: text/plain, Size: 2021 bytes --]

diff --git a/arch/mips/reloc.h b/arch/mips/reloc.h
index 88d23639..f4023b16 100644
--- a/arch/mips/reloc.h
+++ b/arch/mips/reloc.h
@@ -29,6 +29,7 @@
 
 #define NEED_MIPS_GOT_RELOCS 1
 #define DT_DEBUG_INDIRECT DT_MIPS_RLD_MAP
+#define DT_DEBUG_INDIRECT_REL DT_MIPS_RLD_MAP_REL
 #define ARCH_SYM_REJECT_UND(s) (!((s)->st_other & STO_MIPS_PLT))
 
 #define CRTJMP(pc,sp) __asm__ __volatile__( \
diff --git a/arch/mips64/reloc.h b/arch/mips64/reloc.h
index fdb5edc9..145d8b0b 100644
--- a/arch/mips64/reloc.h
+++ b/arch/mips64/reloc.h
@@ -38,6 +38,7 @@
 
 #define NEED_MIPS_GOT_RELOCS 1
 #define DT_DEBUG_INDIRECT DT_MIPS_RLD_MAP
+#define DT_DEBUG_INDIRECT_REL DT_MIPS_RLD_MAP_REL
 #define ARCH_SYM_REJECT_UND(s) (!((s)->st_other & STO_MIPS_PLT))
 
 #define CRTJMP(pc,sp) __asm__ __volatile__( \
diff --git a/arch/mipsn32/reloc.h b/arch/mipsn32/reloc.h
index 47c6e591..bf00bd6a 100644
--- a/arch/mipsn32/reloc.h
+++ b/arch/mipsn32/reloc.h
@@ -29,6 +29,7 @@
 
 #define NEED_MIPS_GOT_RELOCS 1
 #define DT_DEBUG_INDIRECT DT_MIPS_RLD_MAP
+#define DT_DEBUG_INDIRECT_REL DT_MIPS_RLD_MAP_REL
 #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 5b9c8be4..93615cb6 100644
--- a/ldso/dynlink.c
+++ b/ldso/dynlink.c
@@ -1923,6 +1923,10 @@ void __dls3(size_t *sp, size_t *auxv)
 			size_t *ptr = (size_t *) app.dynv[i+1];
 			*ptr = (size_t)&debug;
 		}
+		if (app.dynv[i]==DT_DEBUG_INDIRECT_REL) {
+			size_t *ptr = (size_t *)((size_t)&app.dynv[i] + app.dynv[i+1]);
+			*ptr = (size_t)&debug;
+		}
 	}
 
 	/* This must be done before final relocations, since it calls
diff --git a/src/internal/dynlink.h b/src/internal/dynlink.h
index 51c0639f..d37ebbaa 100644
--- a/src/internal/dynlink.h
+++ b/src/internal/dynlink.h
@@ -92,6 +92,10 @@ struct fdpic_dummy_loadmap {
 #define DT_DEBUG_INDIRECT 0
 #endif
 
+#ifndef DT_DEBUG_INDIRECT_REL
+#define DT_DEBUG_INDIRECT_REL 0
+#endif
+
 #define AUX_CNT 32
 #define DYN_CNT 32
 

  reply	other threads:[~2022-01-09  5:14 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-15 13:10 d.dorau
2021-12-15 15:20 ` Rich Felker
2021-12-20  8:54 ` d.dorau
2022-01-09  5:14   ` Rich Felker [this message]
2023-01-10 20:02     ` Hauke Mehrtens
2023-01-17 23:14       ` Hauke Mehrtens
2023-01-18 16:03         ` 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=20220109051408.GQ7074@brightrain.aerifal.cx \
    --to=dalias@libc.org \
    --cc=d.dorau@avm.de \
    --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).