From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTP id E15D63858405 for ; Fri, 10 Sep 2021 18:59:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org E15D63858405 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-582-Y3wEtmeCMGmELXXZw3JIOw-1; Fri, 10 Sep 2021 14:59:55 -0400 X-MC-Unique: Y3wEtmeCMGmELXXZw3JIOw-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 65C8E835DE0; Fri, 10 Sep 2021 18:59:54 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.39.195.4]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B7B6160C7F; Fri, 10 Sep 2021 18:59:52 +0000 (UTC) From: Florian Weimer To: "H.J. Lu" Cc: libc-alpha@sourceware.org, gdb@sourceware.org, libc-coord@lists.openwall.com, Daniel Walker Subject: Re: [PATCH v8 1/1] Extend struct r_debug to support multiple namespaces [BZ #15971] References: <20210908182559.3461694-1-hjl.tools@gmail.com> <20210908182559.3461694-2-hjl.tools@gmail.com> Date: Fri, 10 Sep 2021 20:59:50 +0200 In-Reply-To: <20210908182559.3461694-2-hjl.tools@gmail.com> (H. J. Lu's message of "Wed, 8 Sep 2021 11:25:59 -0700") Message-ID: <87h7esfe8p.fsf@oldenburg.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-14.4 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=unavailable autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gdb@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 10 Sep 2021 19:00:00 -0000 * 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 =E2=80=9Ccompatibility symbol=E2=80=9D in a pub= lic 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 =3D=3D 2. */ > + > + /* Link to the next r_debug_extended structure. Each r_debug_extend= ed > + 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' secti= on > 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 =3D _DYNAMIC; dyn->d_tag !=3D DT_NULL; ++dyn) > if (dyn->d_tag =3D=3D DT_DEBUG) > -=09 r_debug =3D (struct r_debug *) dyn->d_un.d_ptr; > - */ > +=09 r_debug_extended =3D (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 > +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > + > +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_exten= ded > + 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 =3D xdlmopen (LM_ID_NEWLM, "$ORIGIN/tst-dlmopen1mod.so", > +=09=09 RTLD_LAZY); I think this should test that r_version is 1 before the dlmopen call. > + > + int status =3D EXIT_FAILURE; > + ElfW(Dyn) *d; > + for (d =3D _DYNAMIC; d->d_tag !=3D DT_NULL; ++d) > + { > + struct r_debug_extended *debug =3D ELF_MACHINE_GET_R_DEBUG (d); > + if (debug !=3D NULL) > +=09{ > +=09 TEST_VERIFY_EXIT (debug->base.r_version =3D=3D 2); You could use TEST_COMPARE. > +=09 TEST_VERIFY_EXIT (debug->r_next !=3D NULL); > +=09 TEST_VERIFY_EXIT (debug->r_next->r_next =3D=3D NULL); > +=09 TEST_VERIFY_EXIT (debug->r_next->base.r_map !=3D NULL); > +=09 TEST_VERIFY_EXIT (debug->r_next->base.r_map->l_name !=3D NULL); > +=09 const char *name =3D basename (debug->r_next->base.r_map->l_name); > +=09 TEST_VERIFY_EXIT (strcmp (name, "tst-dlmopen1mod.so") =3D=3D 0); You could use TEST_COMPARE_STRING. Sorry, I have not reviewed the actual mechanics of the patch. Thanks, Florian