From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pj1-x102d.google.com (mail-pj1-x102d.google.com [IPv6:2607:f8b0:4864:20::102d]) by sourceware.org (Postfix) with ESMTPS id BA4863858D29; Fri, 10 Sep 2021 19:27:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org BA4863858D29 Received: by mail-pj1-x102d.google.com with SMTP id gp20-20020a17090adf1400b00196b761920aso2137290pjb.3; Fri, 10 Sep 2021 12:27:25 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=oUoKM+jCIZNYE+Y6U9d9vAOc5fJ7faDDWk+rRPmlpPU=; b=VXZ8ayF+Mkg1h6qWkCKVST1qy8WLCwbcvsDWbwI61gFOXO5W1bkwZN9WtWtuX06bu7 dP/XCd2uymTQPiSIOXg+8VAAryduNCoaSrVTyueFrP2JyC6Dv1CPSgSCWyCtNZwvu0LY Ek1/Hf7Axqyn2QaDksGk/aIvSPPTh7ozrBbbYGt/WfdkuD0JLMjhLlcZQyEmntgmVAkz 29whFCTcLUvWTkTqUZDF1mEEW6iETcUyu6MM3vLXc9Jvn9ir9QNMERwNszDXrwzZ2jaV nSUEAJ4sTiLJpKkQMbEUhhlDmCQUhub8o7SP0lie61TvxhCG9zzbibeEA5sRh20sAmpu 1QfQ== X-Gm-Message-State: AOAM531qpOds80zu6nrUsG5dSsAlc3LRZUvDuPwh+ZOOmNMV2WS+JEWy Zjf8qsjbMP+bmx72d3XavM0BwLPezrsomRTQ5YQ/4PX9IGE= X-Google-Smtp-Source: ABdhPJzwafnN717iAjjbAbUUQkYY5ZCWdSn4CWJEv87eg2rBa9kJzk3zSCfzxfbm4wsC5v72ZXmLU17vFJ976syP0LI= X-Received: by 2002:a17:902:e88d:b0:13b:67d5:2c34 with SMTP id w13-20020a170902e88d00b0013b67d52c34mr3539475plg.66.1631302044701; Fri, 10 Sep 2021 12:27:24 -0700 (PDT) MIME-Version: 1.0 References: <20210908182559.3461694-1-hjl.tools@gmail.com> <20210908182559.3461694-2-hjl.tools@gmail.com> <87h7esfe8p.fsf@oldenburg.str.redhat.com> In-Reply-To: <87h7esfe8p.fsf@oldenburg.str.redhat.com> From: "H.J. Lu" Date: Fri, 10 Sep 2021 12:26:48 -0700 Message-ID: Subject: Re: [PATCH v8 1/1] Extend struct r_debug to support multiple namespaces [BZ #15971] To: Florian Weimer Cc: GNU C Library , GDB , libc-coord@lists.openwall.com, Daniel Walker Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-3030.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham 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:27:27 -0000 On Fri, Sep 10, 2021 at 11:59 AM Florian Weimer wrote: > > * 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 p= ublic header. I will remove "compatibility". > Can we move GNAT off this symbol and deprecate it at least? There is no harm in keeping it. > > +/* The extended rendezvous structure used by the run-time dynamic link= er > > + to communicate details of shared object loading to the debugger. I= f > > + the executable's dynamic section has a DT_DEBUG element, the run-ti= me > > + linker sets that element's value to the address where this structur= e > > + 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_exte= nded > > + 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' sec= tion > > 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) > > - r_debug =3D (struct r_debug *) dyn->d_un.d_ptr; > > - */ > > + 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? Linker generates DT_DEBUG only in the executable. dl_iterate_phdr can be used to locate DT_DEBUG in the executable. > > 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 interfac= e. > > +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_extende= d > > + structure represents a different namespace. The first r_debug_ext= ended > > + structure is for the default namespace. > > I think this should say how a reader can determine which list elements > are in fact active. I will update it. > > > 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", > > + RTLD_LAZY); > > I think this should test that r_version is 1 before the dlmopen call. I will add the test. > > + > > + 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) > > + { > > + TEST_VERIFY_EXIT (debug->base.r_version =3D=3D 2); > > You could use TEST_COMPARE. I will fix it. > > > + TEST_VERIFY_EXIT (debug->r_next !=3D NULL); > > + TEST_VERIFY_EXIT (debug->r_next->r_next =3D=3D NULL); > > + TEST_VERIFY_EXIT (debug->r_next->base.r_map !=3D NULL); > > + TEST_VERIFY_EXIT (debug->r_next->base.r_map->l_name !=3D NULL); > > + const char *name =3D basename (debug->r_next->base.r_map->l_nam= e); > > + TEST_VERIFY_EXIT (strcmp (name, "tst-dlmopen1mod.so") =3D=3D 0)= ; > > You could use TEST_COMPARE_STRING. I will fix it. > Sorry, I have not reviewed the actual mechanics of the patch. > > Thanks, > Florian > Thanks. --=20 H.J.