From: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
To: buildroot@busybox.net
Subject: [Buildroot] [PATCH 2/2] fwup: link in pthreads for static builds
Date: Fri, 12 Aug 2016 15:51:48 +0200 [thread overview]
Message-ID: <20160812155148.1a0e2508@free-electrons.com> (raw)
In-Reply-To: <9D32ABC7-1620-4C8E-983B-1D82180CB888@gmail.com>
Hello,
On Thu, 11 Aug 2016 21:54:24 -0700, Khem Raj wrote:
> > The problem is that this doesn't work with static linking with uClibc.
> > I believe it's a uClibc bug, but I'm not entirely sure either.
>
> As per elf specs.
>
> "A weak definition does not change the rules by which object files are
> selected from libraries. However, if a link set contains both a weak
> definition and a non-weak definition, the non-weak definition will always
> be used.?
>
> The "link set" is the set of objects that have been loaded by the linker.
> It does not include objects from libraries that are not required.
>
> So if libc.a appears first and provides the symbol it will be used
> even if its weak. If you exchange the order where libpthread appears
> first it will use the libpthread provided symbols. another option
> could be to use
>
> -Wl,--whole-archive -lpthread -Wl,--no-whole-archive
>
> This would link the right strong symbols into binary irrespective of
> link order
>
> but this will also include unused symbols into binary, probably not
> optimal, and may using -Wl,--gc-sections could help in letting linker
> remove the unused functions, maybe worth trying.
Thanks for those details, but I'm not sure to understand what is the
conclusion. Do you mean that it's impossible to implement this dual
symbol definition mechanism with static libraries? Indeed, while shared
libraries have the weak/non-weak mechanism that allows to be sure the
pthread implementation of the symbols will be used if available, with
static libraries, only the link order will decide if the libpthread of
libc implementation is used.
So, if this cannot be fixed in uClibc, how should this problem be
addressed?
Thanks,
Thomas
--
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
next prev parent reply other threads:[~2016-08-12 13:51 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-10 22:35 [Buildroot] [PATCH 1/2] fwup: bump version to v0.8.2 Frank Hunleth
2016-08-10 22:35 ` [Buildroot] [PATCH 2/2] fwup: link in pthreads for static builds Frank Hunleth
2016-08-11 22:06 ` Thomas Petazzoni
2016-08-12 2:32 ` Frank Hunleth
2016-08-12 4:54 ` Khem Raj
2016-08-12 13:51 ` Thomas Petazzoni [this message]
2016-08-12 15:05 ` Khem Raj
2016-10-16 14:32 ` Thomas Petazzoni
2016-10-16 15:02 ` Frank Hunleth
2016-08-20 13:04 ` [Buildroot] [PATCH 1/2] fwup: bump version to v0.8.2 Thomas Petazzoni
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=20160812155148.1a0e2508@free-electrons.com \
--to=thomas.petazzoni@free-electrons.com \
--cc=buildroot@busybox.net \
/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