From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 127481 invoked by alias); 26 Mar 2019 15:31:45 -0000 Mailing-List: contact binutils-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: binutils-owner@sourceware.org Received: (qmail 127457 invoked by uid 89); 26 Mar 2019 15:31:44 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=AWL,BAYES_00,SPF_PASS autolearn=ham version=3.3.1 spammy=luckily, H*i:sk:c4d1565, H*f:sk:c4d1565, answer X-HELO: mx1.suse.de Received: from mx2.suse.de (HELO mx1.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 26 Mar 2019 15:31:43 +0000 Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 1F151AD57; Tue, 26 Mar 2019 15:31:41 +0000 (UTC) Date: Tue, 26 Mar 2019 15:31:00 -0000 From: Michael Matz To: Martin McClure cc: "H.J. Lu" , Binutils Subject: Re: Behavior change, PLT entries for R_X86_64_PLT32 relocations with undefined symbol In-Reply-To: Message-ID: References: <6d93d4f6-40af-b73f-5c58-9bb77a55b13d@gemtalksystems.com> <5d8c3638-4480-d9fc-7964-406fd7d8e0ad@gemtalksystems.com> User-Agent: Alpine 2.21 (LSU 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-IsSubscribed: yes X-SW-Source: 2019-03/txt/msg00159.txt.bz2 Hi, On Mon, 25 Mar 2019, Martin McClure wrote: > Using the weak symbol worked nicely -- thanks again! The '-z > dynamic-undefined-weak' option was not required. I like this better than > our previous use of --unresolved-symbols=ignore-all since that did not > detect misspelled function names until runtime. With weak symbols you won't have such detection either. Weak undefined symbols will simply turn out to be NULL and crash the same way. > Is there any drawback to using weak symbols? I don't expect any strong > symbols with these names to be defined anywhere outside of the > dynamically loaded library. Then weak symbols won't have any drawback in your scenario. Weak references aren't much different from undefined (in the current DSO) global symbols; weak definitions would be, but you don't have those. > Is there any better way to implement this kind of pattern? I looked for > an option something like -l to link a dynamic library, but that unlike > -l did not add a DT_NEEDED entry for the library, so the specific > library could be specified at runtime. However, if there is such an > option I did not find it. There is one way: --dynamic-list. You can force certain symbols to be dynamic, which luckily still includes undefined symbols: % cat symbols.list { answer; }; % gcc executable.o -lc -ldl -Wl,--unresolved-symbols=ignore-all \ -Wl,--dynamic-list,symbols.list -o executable (remove the weak again to see it working for real). But you still need the --unresolved-symbols=ignore-all to not get an error, so you still get no nice checking for misspellings. Ciao, Michael.