From: Florian Weimer <fweimer@redhat.com>
To: "H.J. Lu" <hjl.tools@gmail.com>
Cc: libc-alpha@sourceware.org, gdb@sourceware.org,
libc-coord@lists.openwall.com,
Daniel Walker <danielwa@cisco.com>
Subject: Re: [PATCH v8 1/1] Extend struct r_debug to support multiple namespaces [BZ #15971]
Date: Fri, 10 Sep 2021 20:59:50 +0200 [thread overview]
Message-ID: <87h7esfe8p.fsf@oldenburg.str.redhat.com> (raw)
In-Reply-To: <20210908182559.3461694-2-hjl.tools@gmail.com> (H. J. Lu's message of "Wed, 8 Sep 2021 11:25:59 -0700")
* H. J. Lu:
> diff --git a/elf/link.h b/elf/link.h
> index ff3a85c847..a297318236 100644
> --- a/elf/link.h
> +++ b/elf/link.h
> @@ -34,14 +34,13 @@
> -/* This is the instance of that structure used by the dynamic linker. */
> +/* This is the compatibility symbol of that structure provided by the
> + dynamic linker. */
> extern struct r_debug _r_debug;
I don't think we should say “compatibility symbol” in a public header.
Can we move GNAT off this symbol and deprecate it at least?
> +/* The extended rendezvous structure used by the run-time dynamic linker
> + to communicate details of shared object loading to the debugger. If
> + the executable's dynamic section has a DT_DEBUG element, the run-time
> + linker sets that element's value to the address where this structure
> + can be found. */
> +
> +struct r_debug_extended
> + {
> + struct r_debug base;
> +
> + /* The following field is added by r_version == 2. */
> +
> + /* Link to the next r_debug_extended structure. Each r_debug_extended
> + structure represents a different namespace. The first
> + r_debug_extended structure is for the default namespace. */
> + struct r_debug_extended *r_next;
> + };
> +
> /* This symbol refers to the "dynamic structure" in the `.dynamic' section
> of whatever module refers to `_DYNAMIC'. So, to find its own
> - `struct r_debug', a program could do:
> + `struct r_debug_extended', a program could do:
> for (dyn = _DYNAMIC; dyn->d_tag != DT_NULL; ++dyn)
> if (dyn->d_tag == DT_DEBUG)
> - r_debug = (struct r_debug *) dyn->d_un.d_ptr;
> - */
> + r_debug_extended = (struct r_debug_extended *) dyn->d_un.d_ptr;
> + */
> extern ElfW(Dyn) _DYNAMIC[];
What about shared objects? How can they find r_debug_extended? Should
they just make sure they have DT_DEBUG in their dynamic section?
Calling getauxval (AT_PHDR) has a relocation dependencies, which I
expect some consumers want to avoid.
> +Extension to the r_debug structure
> +==================================
> +
> +The r_debug_extended structure is an extension of the r_debug interface.
> +If r_version is 2, one additional field is available:
> +
> + struct r_debug_extended *r_next;
> + Link to the next r_debug_extended structure. Each r_debug_extended
> + structure represents a different namespace. The first r_debug_extended
> + structure is for the default namespace.
I think this should say how a reader can determine which list elements
are in fact active.
> diff --git a/elf/tst-dlmopen4.c b/elf/tst-dlmopen4.c
> new file mode 100644
> index 0000000000..7a6c502e8c
> --- /dev/null
> +++ b/elf/tst-dlmopen4.c
> +static int
> +do_test (void)
> +{
> + void *h = xdlmopen (LM_ID_NEWLM, "$ORIGIN/tst-dlmopen1mod.so",
> + RTLD_LAZY);
I think this should test that r_version is 1 before the dlmopen call.
> +
> + int status = EXIT_FAILURE;
> + ElfW(Dyn) *d;
> + for (d = _DYNAMIC; d->d_tag != DT_NULL; ++d)
> + {
> + struct r_debug_extended *debug = ELF_MACHINE_GET_R_DEBUG (d);
> + if (debug != NULL)
> + {
> + TEST_VERIFY_EXIT (debug->base.r_version == 2);
You could use TEST_COMPARE.
> + TEST_VERIFY_EXIT (debug->r_next != NULL);
> + TEST_VERIFY_EXIT (debug->r_next->r_next == NULL);
> + TEST_VERIFY_EXIT (debug->r_next->base.r_map != NULL);
> + TEST_VERIFY_EXIT (debug->r_next->base.r_map->l_name != NULL);
> + const char *name = basename (debug->r_next->base.r_map->l_name);
> + TEST_VERIFY_EXIT (strcmp (name, "tst-dlmopen1mod.so") == 0);
You could use TEST_COMPARE_STRING.
Sorry, I have not reviewed the actual mechanics of the patch.
Thanks,
Florian
next prev parent reply other threads:[~2021-09-10 18:59 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-08 18:25 [PATCH v8 0/1] Extend struct r_debug to support multiple namespaces H.J. Lu
2021-09-08 18:25 ` [PATCH v8 1/1] Extend struct r_debug to support multiple namespaces [BZ #15971] H.J. Lu
2021-09-10 18:59 ` Florian Weimer [this message]
2021-09-10 19:26 ` H.J. Lu
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=87h7esfe8p.fsf@oldenburg.str.redhat.com \
--to=fweimer@redhat.com \
--cc=danielwa@cisco.com \
--cc=gdb@sourceware.org \
--cc=hjl.tools@gmail.com \
--cc=libc-alpha@sourceware.org \
--cc=libc-coord@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.
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).