public inbox for newlib@sourceware.org
 help / color / mirror / Atom feed
From: Thomas Preudhomme <thomas.preudhomme@foss.arm.com>
To: newlib@sourceware.org
Subject: Re: [PATCH 3/3, newlib] Allow locking routine to be retargeted
Date: Thu, 02 Feb 2017 10:21:00 -0000	[thread overview]
Message-ID: <309756b1-8d2f-ce85-0381-20d2cdb6419a@foss.arm.com> (raw)
In-Reply-To: <1485939967.1269.5.camel@op.pl>



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

  reply	other threads:[~2017-02-02 10:21 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-24 16:05 [PATCH 2/2, " Thomas Preudhomme
2017-01-25 11:39 ` Corinna Vinschen
2017-01-25 20:43   ` Jeff Johnston
2017-01-31 17:19     ` [PATCH 3/3, " Thomas Preudhomme
2017-02-01  8:43       ` Freddie Chopin
2017-02-02 10:21         ` Thomas Preudhomme
2017-02-02 16:16           ` Freddie Chopin
2017-02-02 16:25             ` Freddie Chopin
2017-02-02 23:24           ` Freddie Chopin
2017-02-07 21:36           ` Jeff Johnston
2017-02-08  9:07             ` Thomas Preudhomme
     [not found]               ` <1199540764.24714361.1486590050100.JavaMail.zimbra@redhat.com>
2017-02-10 11:15                 ` Thomas Preudhomme
2017-02-13 22:16                   ` Jeff Johnston
2017-02-01  9:06       ` Freddie Chopin
2017-02-02 10:21         ` Thomas Preudhomme [this message]
2017-01-29 11:19 ` [PATCH 2/2, " Freddie Chopin
2017-01-29 17:07   ` Freddie Chopin
2017-01-29 22:09 ` Freddie Chopin
2017-01-30 18:53 ` Freddie Chopin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=309756b1-8d2f-ce85-0381-20d2cdb6419a@foss.arm.com \
    --to=thomas.preudhomme@foss.arm.com \
    --cc=newlib@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).