From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from vmicros1.altlinux.org (vmicros1.altlinux.org [194.107.17.57]) by sourceware.org (Postfix) with ESMTP id CB2AC3858422 for ; Thu, 18 Nov 2021 22:20:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org CB2AC3858422 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=altlinux.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=altlinux.org Received: from mua.local.altlinux.org (mua.local.altlinux.org [192.168.1.14]) by vmicros1.altlinux.org (Postfix) with ESMTP id 28C7372C8B8; Fri, 19 Nov 2021 01:20:27 +0300 (MSK) Received: by mua.local.altlinux.org (Postfix, from userid 508) id 195187CC8BC; Fri, 19 Nov 2021 01:20:26 +0300 (MSK) Date: Fri, 19 Nov 2021 01:20:26 +0300 From: "Dmitry V. Levin" To: Mark Wielaard Cc: elfutils-devel@sourceware.org Subject: Re: [PATCH] tests: Add -ldl to dwfl_proc_attach_LDFLAGS Message-ID: <20211118222026.GB2074@altlinux.org> References: <20211118212341.19077-1-mark@klomp.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20211118212341.19077-1-mark@klomp.org> X-Spam-Status: No, score=-12.6 required=5.0 tests=BAYES_00, GIT_PATCH_0, 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: Thu, 18 Nov 2021 22:20:29 -0000 On Thu, Nov 18, 2021 at 10:23:41PM +0100, Mark Wielaard wrote: > 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 > > So simply explicitly add -ldl to the LDFLAGS. > > 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..97cb3fa3 100644 > --- a/tests/ChangeLog > +++ b/tests/ChangeLog > @@ -1,3 +1,7 @@ > +2021-11-18 Mark Wielaard > + > + * Makefile.am (dwfl_proc_attach_LDFLAGS): Add -ldl. > + > 2021-11-05 Frank Ch. Eigler > > PR28430 > diff --git a/tests/Makefile.am b/tests/Makefile.am > index bfb8b13a..f212f9fb 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 -ldl $(AM_LDFLAGS) 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. -- ldv