From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 59246 invoked by alias); 2 Feb 2017 10:21:33 -0000 Mailing-List: contact newlib-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: newlib-owner@sourceware.org Received: (qmail 59230 invoked by uid 89); 2 Feb 2017 10:21:33 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.9 required=5.0 tests=BAYES_00,KAM_LAZY_DOMAIN_SECURITY,RP_MATCHES_RCVD autolearn=no version=3.3.2 spammy=bo, Hx-languages-length:1881, H*i:sk:1485939, H*f:sk:1485939 X-HELO: foss.arm.com Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 02 Feb 2017 10:21:32 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id C3F351516; Thu, 2 Feb 2017 02:21:30 -0800 (PST) Received: from [10.2.206.52] (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 746DE3F24D for ; Thu, 2 Feb 2017 02:21:30 -0800 (PST) Subject: Re: [PATCH 3/3, newlib] Allow locking routine to be retargeted To: newlib@sourceware.org References: <53697464-af87-8917-c5ec-b1a0d06cca00@foss.arm.com> <20170125113934.GD21591@calimero.vinschen.de> <1247899115.19685162.1485376973312.JavaMail.zimbra@redhat.com> <7477136f-dc07-5081-a06f-2144a8ce2251@foss.arm.com> <1485939967.1269.5.camel@op.pl> From: Thomas Preudhomme Message-ID: <309756b1-8d2f-ce85-0381-20d2cdb6419a@foss.arm.com> Date: Thu, 02 Feb 2017 10:21:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 MIME-Version: 1.0 In-Reply-To: <1485939967.1269.5.camel@op.pl> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2017/txt/msg00116.txt.bz2 On 01/02/17 09:06, Freddie Chopin wrote: > On Tue, 2017-01-31 at 17:19 +0000, Thomas Preudhomme wrote: >> > 1. Why is the lock used by at_quick_exit() not required - I have >> no >> > idea. The linking error (when I do not provide storage for this >> lock) >> > about multiple definitions is visible only when I actually use the >> > at_quick_exit() function. >> >> That makes sense. If you don't use at_quick_exit then probably no >> symbol in the >> corresponding object file is referenced and therefore the file is not >> linked in. >> That's exactly why the "doubly defined error on missing symbol" work >> as >> explained in the cover letter: file with dummy symbol is only linked >> in if it >> solves an undefined reference. > > This case seems a bit different, as it applies only to the > at_quick_exit() lock. In my code I have no references to "env" or "tz" > locks either, but I cannot drop these objects without the "multiple > definitions" error. Maybe my test is flawed, but browsing the assembly > output does not show any uses of __tz_lock(), __tz_unlock(), > __env_lock() or __env_unlock() functions (which are not present in the > output file), and these are the only places of newlib which use this > particular locks. I'll try later with a simpler project. Your code don't need to reference the env or tz lock directly for them to be linked in. The linker does a transitive closure of files until all references are resolved. So you code could reference a function a() present in a file A.o with that file containing references to function b() in file B.o which contains reference to tz_lock in file tz_lock.o which also contains the tz_mutex lock. If you show me a small testcase where tz_lock or the env lock cannot be removed I can tell you why does the error happens. Best regards, Thomas