[PATCH] tests: Add -ldl to dwfl_proc_attach_LDFLAGS
Dmitry V. Levin
ldv@altlinux.org
Thu Nov 25 14:38:52 GMT 2021
On Sat, Nov 20, 2021 at 03:18:27PM +0100, Mark Wielaard wrote:
> Hi,
>
> On Sat, Nov 20, 2021 at 01:12:17AM +0300, Dmitry V. Levin wrote:
> > On Fri, Nov 19, 2021 at 05:58:19PM +0100, Florian Weimer wrote:
> > > It may have to do with --as-needed that some builds use. If there are
> > > no pending undefined references, some linkers drop earlier shared object
> > > references with --as-needed (similar to what happens with static
> > > archives).
> > >
> > > The GCC LTO plugin results in ld looking at more objects in greater
> > > detail for some reason. Without LTO and --as-needed, you probably don't
> > > get a dlopen export (if you do not link with -E) because indirect
> > > dependencies are not consulted, breaking the valgrind workaround because
> > > there is no interposition.
> >
> > Thanks. I suppose adding -rdynamic to dwfl_proc_attach_LDFLAGS should be
> > a more correct fix.
>
> That works. But I don't really understand why.
If I understand correctly, -rdynamic makes sure the dlopen symbol
is exported by dwfl-proc-attach executable and interposes other dlopen
symbols exported by libdl or libc. Without -rdynamic, there is a change
that dlopen defined in dwfl-proc-attach.c is optimized out.
> Does the attached patch look OK to you?
Yes, thanks.
--
ldv
More information about the Elfutils-devel
mailing list