public inbox for elfutils@sourceware.org
 help / color / mirror / Atom feed
From: Florian Weimer <fweimer@redhat.com>
To: "Dmitry V. Levin" <ldv@altlinux.org>
Cc: Mark Wielaard <mark@klomp.org>,  elfutils-devel@sourceware.org
Subject: Re: [PATCH] tests: Add -ldl to dwfl_proc_attach_LDFLAGS
Date: Fri, 19 Nov 2021 17:58:19 +0100	[thread overview]
Message-ID: <87czmwaxqs.fsf@oldenburg.str.redhat.com> (raw)
In-Reply-To: <20211118222026.GB2074@altlinux.org> (Dmitry V. Levin's message of "Fri, 19 Nov 2021 01:20:26 +0300")

* Dmitry V. Levin:

> Let's make clear what's going on here.  First of all, dwfl-proc-attach.c
> does not use dlopen so it doesn't pull it in and doesn't need -ldl.
> In regular builds, dwfl-proc-attach.o is linked with ../libdw/libdw.so
> which in turn uses dlopen and is already linked with -ldl.
> When elfutils is configured with --enable-gprof or --enable-gcov,
> BUILD_STATIC is enabled and dwfl-proc-attach.o is linked with
> ../libdw/libdw.a -lz $(zip_LIBS) $(libelf) $(libebl) -ldl -lpthread
> which already contains -ldl.
> In any case, I fail to understand why dwfl-proc-attach might need
> an extra -ldl, especially in LDFLAGS which goes before LDADD
> in the linking command.

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,
Florian


  parent reply	other threads:[~2021-11-19 16:58 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-18 21:23 Mark Wielaard
2021-11-18 22:20 ` Dmitry V. Levin
2021-11-19 10:57   ` Mark Wielaard
2021-11-19 16:58   ` Florian Weimer [this message]
2021-11-19 22:12     ` Dmitry V. Levin
2021-11-20 14:18       ` Mark Wielaard
2021-11-25 13:35         ` Mark Wielaard
2021-11-25 14:38         ` Dmitry V. Levin

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=87czmwaxqs.fsf@oldenburg.str.redhat.com \
    --to=fweimer@redhat.com \
    --cc=elfutils-devel@sourceware.org \
    --cc=ldv@altlinux.org \
    --cc=mark@klomp.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).