public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
To: Rich Felker <dalias@libc.org>
Cc: Florian Weimer <fweimer@redhat.com>, carlos <carlos@redhat.com>,
	Joseph Myers <joseph@codesourcery.com>,
	Szabolcs Nagy <szabolcs.nagy@arm.com>,
	libc-alpha <libc-alpha@sourceware.org>,
	Thomas Gleixner <tglx@linutronix.de>, Ben Maurer <bmaurer@fb.com>,
	Peter Zijlstra <peterz@infradead.org>,
	"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>,
	Boqun Feng <boqun.feng@gmail.com>,
	Will Deacon <will.deacon@arm.com>,
	Dave Watson <davejwatson@fb.com>, Paul Turner <pjt@google.com>,
	linux-kernel <linux-kernel@vger.kernel.org>,
	linux-api <linux-api@vger.kernel.org>
Subject: Re: [RFC PATCH v4 1/5] glibc: Perform rseq(2) registration at nptl init and thread creation
Date: Wed, 5 Dec 2018 12:24:40 -0500 (EST)	[thread overview]
Message-ID: <210288020.19588.1544030680384.JavaMail.zimbra@efficios.com> (raw)
In-Reply-To: <20181126170758.GP23599@brightrain.aerifal.cx>



----- On Nov 26, 2018, at 12:07 PM, Rich Felker dalias@libc.org wrote:

> On Mon, Nov 26, 2018 at 11:30:51AM -0500, Mathieu Desnoyers wrote:
>> ----- On Nov 26, 2018, at 10:51 AM, Mathieu Desnoyers
>> mathieu.desnoyers@efficios.com wrote:
>> 
>> > ----- On Nov 26, 2018, at 3:28 AM, Florian Weimer fweimer@redhat.com wrote:
>> > 
>> >> * Mathieu Desnoyers:
>> >> 
>> >>> Using a "weak" symbol in early adopter libraries is important, so they
>> >>> can be loaded together into the same process without causing loader
>> >>> errors due to many definitions of the same strong symbol.
>> >> 
>> >> This is not how ELF dynamic linking works.  If the symbol name is the
>> >> same, one definition interposes the others.
>> >> 
>> >> You need to ensure that the symbol has the same size everywhere, though.
>> >> There are some tricky interactions with symbol versions, too.  (The
>> >> interposing libraries must not use symbol versioning.)
>> > 
>> > I was under the impression that loading the same strong symbol into an
>> > application multiple times would cause some kind of warning if non-weak. I did
>> > some testing to figure out which case I remembered would cause this.
>> > 
>> > When compiling with "-fno-common", dynamic and static linking work fine, but
>> > trying to add multiple instances of a given symbol into a single object fails
>> > with:
>> > 
>> > /tmp/ccSakXZV.o:(.bss+0x0): multiple definition of `a'
>> > /tmp/ccQBJBOo.o:(.bss+0x0): first defined here
>> > 
>> > Even if the symbol has the same size.
>> > 
>> > So considering that we don't care about compiling into a single object here,
>> > and only care about static and dynamic linking of libraries, indeed the "weak"
>> > symbol is not useful.
>> > 
>> > So let's make __rseq_abi and __rseq_refcount strong symbols then ?
>> 
>> Actually, looking into ld(1) --warn-common, it looks like "weak" would be
>> cleaner
>> after all, especially for __rseq_abi which we needs to be initialized to a
>> specific
>> value, which is therefore not a common symbol.
>> 
>> "      --warn-common
>>            Warn when a common symbol is combined with another common symbol or with a
>>            symbol definition.  Unix
>>            linkers allow this somewhat sloppy practice, but linkers on some other operating
>>            systems do not.
>>            This option allows you to find potential problems from combining global symbols.
>>            Unfortunately,
>>            some C libraries use this practice, so you may get some warnings about symbols
>>            in the libraries as
>>            well as in your programs."
>> 
>> Thoughts ?
> 
> AFAIK this has nothing to do with dynamic linking.

Reading through the ELF specification, it seems to imply that "weak" only affects the link
editor behavior when combining relocatable objects, not the behavior of the dynamic linker.
Is that what you refer to when you say "weak" has nothing to do with dynamic linking ?

If that interpretation is correct, then indeed I should remove the "weak" from the __rseq_abi
and __rseq_refcount.

Thanks,

Mathieu


-- 
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.com

  reply	other threads:[~2018-12-05 17:24 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-21 18:39 [RFC PATCH v4 1/5] glibc: Perform rseq(2) registration at nptl init and thread creation Mathieu Desnoyers
2018-11-21 18:39 ` [RFC PATCH v4 2/5] glibc: sched_getcpu(): use rseq cpu_id TLS on Linux Mathieu Desnoyers
2018-11-22 14:36 ` [RFC PATCH v4 1/5] glibc: Perform rseq(2) registration at nptl init and thread creation Rich Felker
2018-11-22 15:04   ` Mathieu Desnoyers
2018-11-22 15:11     ` Florian Weimer
2018-11-22 15:17       ` Rich Felker
2018-11-22 15:21         ` Florian Weimer
2018-11-22 15:33           ` Mathieu Desnoyers
2018-11-22 15:44             ` Rich Felker
2018-11-22 16:24             ` Szabolcs Nagy
2018-11-22 18:35               ` Mathieu Desnoyers
2018-11-22 19:01                 ` Rich Felker
2018-11-22 19:36                   ` Mathieu Desnoyers
2018-11-22 15:14     ` Rich Felker
2018-11-22 15:47       ` Mathieu Desnoyers
2018-11-22 16:28         ` Florian Weimer
2018-11-22 16:47           ` Mathieu Desnoyers
2018-11-22 16:59             ` Florian Weimer
2018-11-22 17:10               ` Rich Felker
2018-11-23 13:10                 ` Florian Weimer
2018-11-23 14:28                   ` Rich Felker
2018-11-23 17:05                     ` Mathieu Desnoyers
2018-11-23 17:30                       ` Rich Felker
2018-11-23 17:39                         ` Florian Weimer
2018-11-23 17:44                           ` Rich Felker
2018-11-23 18:01                             ` Florian Weimer
2018-11-23 17:52                         ` Mathieu Desnoyers
2018-11-23 18:35                           ` Rich Felker
2018-11-23 21:09                             ` Mathieu Desnoyers
2018-11-26  8:28                               ` Florian Weimer
2018-11-26 15:51                                 ` Mathieu Desnoyers
2018-11-26 16:03                                   ` Florian Weimer
2018-11-26 17:10                                     ` Rich Felker
2018-11-26 19:22                                       ` Mathieu Desnoyers
2018-12-03 21:30                                         ` Mathieu Desnoyers
2018-11-26 16:30                                   ` Mathieu Desnoyers
2018-11-26 17:07                                     ` Rich Felker
2018-12-05 17:24                                       ` Mathieu Desnoyers [this message]
2018-11-26 11:56                               ` Szabolcs Nagy
2018-11-22 17:29               ` Mathieu Desnoyers
2018-11-23 13:29                 ` Florian Weimer

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=210288020.19588.1544030680384.JavaMail.zimbra@efficios.com \
    --to=mathieu.desnoyers@efficios.com \
    --cc=bmaurer@fb.com \
    --cc=boqun.feng@gmail.com \
    --cc=carlos@redhat.com \
    --cc=dalias@libc.org \
    --cc=davejwatson@fb.com \
    --cc=fweimer@redhat.com \
    --cc=joseph@codesourcery.com \
    --cc=libc-alpha@sourceware.org \
    --cc=linux-api@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=paulmck@linux.vnet.ibm.com \
    --cc=peterz@infradead.org \
    --cc=pjt@google.com \
    --cc=szabolcs.nagy@arm.com \
    --cc=tglx@linutronix.de \
    --cc=will.deacon@arm.com \
    /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