From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gnu.wildebeest.org (gnu.wildebeest.org [45.83.234.184]) by sourceware.org (Postfix) with ESMTPS id 19183385840D for ; Sat, 20 Nov 2021 14:18:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 19183385840D Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=klomp.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=klomp.org Received: from reform (deer0x10.wildebeest.org [172.31.17.146]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by gnu.wildebeest.org (Postfix) with ESMTPSA id 74B683000711; Sat, 20 Nov 2021 15:18:28 +0100 (CET) Received: by reform (Postfix, from userid 1000) id DAF3F2E83686; Sat, 20 Nov 2021 15:18:27 +0100 (CET) Date: Sat, 20 Nov 2021 15:18:27 +0100 From: Mark Wielaard To: "Dmitry V. Levin" Cc: Florian Weimer , elfutils-devel@sourceware.org Subject: Re: [PATCH] tests: Add -ldl to dwfl_proc_attach_LDFLAGS Message-ID: References: <20211118212341.19077-1-mark@klomp.org> <20211118222026.GB2074@altlinux.org> <87czmwaxqs.fsf@oldenburg.str.redhat.com> <20211119221217.GA18221@altlinux.org> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="ypYys2jPUqMjcbeR" Content-Disposition: inline In-Reply-To: <20211119221217.GA18221@altlinux.org> X-Spam-Status: No, score=-9.8 required=5.0 tests=BAYES_00, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, 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: elfutils-devel@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Elfutils-devel mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 20 Nov 2021 14:18:31 -0000 --ypYys2jPUqMjcbeR Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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. Does the attached patch look OK to you? Thanks, Mark --ypYys2jPUqMjcbeR Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0001-tests-Add-rdynamic-to-dwfl_proc_attach_LDFLAGS.patch" >From 311b42279d42187540e776648fd19c1e897fbacd Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Thu, 18 Nov 2021 21:34:57 +0100 Subject: [PATCH] tests: Add -rdynamic to dwfl_proc_attach_LDFLAGS dwfl-proc-attach uses (overrides) dlopen (so it does nothing). This seems to cause a versioned dlopen symbol to be pulled in when building with LTO. Resulting in a link failure (when dlopen isn't integrated into libc): /usr/bin/ld: dwfl-proc-attach.o (symbol from plugin): undefined reference to symbol 'dlopen@@GLIBC_2.2.5' /usr/bin/ld: /usr/lib64/libdl.so.2: error adding symbols: DSO missing from command line collect2: error: ld returned 1 exit status Add -rdynamic to the LDFLAGS to add all symbols to the dynamic symbol table for dwfl-proc-attach. Signed-off-by: Mark Wielaard --- tests/ChangeLog | 4 ++++ tests/Makefile.am | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/ChangeLog b/tests/ChangeLog index a59cdd51..d0fc3fb0 100644 --- a/tests/ChangeLog +++ b/tests/ChangeLog @@ -1,3 +1,7 @@ +2021-11-18 Mark Wielaard + + * Makefile.am (dwfl_proc_attach_LDFLAGS): Add -rdynamic. + 2021-11-05 Frank Ch. Eigler PR28430 diff --git a/tests/Makefile.am b/tests/Makefile.am index bfb8b13a..2298a5ae 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -717,7 +717,7 @@ strptr_LDADD = $(libelf) newdata_LDADD = $(libelf) elfstrtab_LDADD = $(libelf) dwfl_proc_attach_LDADD = $(libdw) -dwfl_proc_attach_LDFLAGS = -pthread $(AM_LDFLAGS) +dwfl_proc_attach_LDFLAGS = -pthread -rdynamic $(AM_LDFLAGS) elfshphehdr_LDADD =$(libelf) elfstrmerge_LDADD = $(libdw) $(libelf) dwelfgnucompressed_LDADD = $(libelf) $(libdw) -- 2.30.2 --ypYys2jPUqMjcbeR--