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 ADC643858406 for ; Fri, 19 Nov 2021 22:12:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org ADC643858406 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 B48BD72C8B8; Sat, 20 Nov 2021 01:12:17 +0300 (MSK) Received: by mua.local.altlinux.org (Postfix, from userid 508) id 993237CC8C0; Sat, 20 Nov 2021 01:12:17 +0300 (MSK) Date: Sat, 20 Nov 2021 01:12:17 +0300 From: "Dmitry V. Levin" To: Florian Weimer Cc: Mark Wielaard , elfutils-devel@sourceware.org Subject: Re: [PATCH] tests: Add -ldl to dwfl_proc_attach_LDFLAGS Message-ID: <20211119221217.GA18221@altlinux.org> References: <20211118212341.19077-1-mark@klomp.org> <20211118222026.GB2074@altlinux.org> <87czmwaxqs.fsf@oldenburg.str.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87czmwaxqs.fsf@oldenburg.str.redhat.com> X-Spam-Status: No, score=-6.6 required=5.0 tests=BAYES_00, 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: Fri, 19 Nov 2021 22:12:20 -0000 On Fri, Nov 19, 2021 at 05:58:19PM +0100, Florian Weimer wrote: > * 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. I suppose adding -rdynamic to dwfl_proc_attach_LDFLAGS should be a more correct fix. -- ldv