From: Xi Ruoyao <xry111@mengyan1223.wang>
To: libc-alpha@sourceware.org
Cc: Jiaxun Yang <jiaxun.yang@flygoat.com>,
syq@debian.org, Joseph Myers <joseph@codesourcery.com>,
Carlos O'Donell <carlos@systemhalted.org>
Subject: [PATCH] mips: fix elf/tst-dlmopen4
Date: Sat, 29 Jan 2022 02:54:59 +0800 [thread overview]
Message-ID: <9dff16aac870a046c7cc768eef84bcbd6fd4d65c.camel@mengyan1223.wang> (raw)
MIPS uses DT_MIPS_RLD_MAP and DT_MIPS_RLD_MAP_REL instead of DT_DEBUG,
to provide access to r_debug.
---
elf/tst-dlmopen4.c | 29 +++++++++++++++++++----------
1 file changed, 19 insertions(+), 10 deletions(-)
diff --git a/elf/tst-dlmopen4.c b/elf/tst-dlmopen4.c
index d8bcf7e9d5..de67a30a4b 100644
--- a/elf/tst-dlmopen4.c
+++ b/elf/tst-dlmopen4.c
@@ -25,17 +25,26 @@
#include <support/check.h>
#include <support/test-driver.h>
-#ifndef ELF_MACHINE_GET_R_DEBUG
-# define ELF_MACHINE_GET_R_DEBUG(d) \
- (__extension__ ({ \
- struct r_debug_extended *debug; \
- if ((d)->d_tag == DT_DEBUG) \
- debug = (struct r_debug_extended *) (d)->d_un.d_ptr; \
- else \
- debug = NULL; \
- debug; }))
+static struct r_debug_extended *
+elf_get_r_debug (ElfW(Dyn) *d)
+{
+#ifdef __mips__
+ if (d->d_tag == DT_MIPS_RLD_MAP_REL)
+ {
+ char *ptr = (char *) d;
+ ptr += d->d_un.d_val;
+ return *(struct r_debug_extended **) ptr;
+ }
+ else if (d->d_tag == DT_MIPS_RLD_MAP)
+ return *(struct r_debug_extended **) d->d_un.d_ptr;
+#else
+ if (d->d_tag == DT_DEBUG)
+ return (struct r_debug_extended *) d->d_un.d_ptr;
#endif
+ return NULL;
+}
+
static int
do_test (void)
{
@@ -44,7 +53,7 @@ do_test (void)
for (d = _DYNAMIC; d->d_tag != DT_NULL; ++d)
{
- debug = ELF_MACHINE_GET_R_DEBUG (d);
+ debug = elf_get_r_debug (d);
if (debug != NULL)
break;
}
--
2.35.0
next reply other threads:[~2022-01-28 18:55 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-28 18:54 Xi Ruoyao [this message]
2022-01-28 19:04 ` Carlos O'Donell
2022-01-28 20:12 ` Xi Ruoyao
2022-01-28 20:41 ` H.J. Lu
2022-01-28 20:49 ` Carlos O'Donell
2022-01-28 21:20 ` H.J. Lu
2022-01-28 21:23 ` Xi Ruoyao
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=9dff16aac870a046c7cc768eef84bcbd6fd4d65c.camel@mengyan1223.wang \
--to=xry111@mengyan1223.wang \
--cc=carlos@systemhalted.org \
--cc=jiaxun.yang@flygoat.com \
--cc=joseph@codesourcery.com \
--cc=libc-alpha@sourceware.org \
--cc=syq@debian.org \
/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.
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 read-only IMAP folder(s) and NNTP newsgroup(s).