mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Rich Felker <dalias@libc.org>
To: Timo Teras <timo.teras@iki.fi>
Cc: musl@lists.openwall.com, scjthm@live.com
Subject: Re: Linking musl with ld.gold
Date: Thu, 8 May 2014 01:18:21 -0400	[thread overview]
Message-ID: <20140508051821.GG26358@brightrain.aerifal.cx> (raw)
In-Reply-To: <20140508081126.140b0064@vostro>

On Thu, May 08, 2014 at 08:11:26AM +0300, Timo Teras wrote:
> On Wed, 7 May 2014 21:06:05 -0400
> Rich Felker <dalias@libc.org> wrote:
> 
> > On Wed, May 07, 2014 at 01:04:43PM +0300, Timo Teras wrote:
> > > Is perhaps -ffunction-sections and/or -fdata-sections added
> > > automatically? Those would break musl like experienced.
> > 
> > They should not break musl; if they do, it's a compiler bug. The
> > strong symbol that overrides the weak symbol elsewhere is not unused
> > and available for garbage collection because it's referenced.
> > 
> > I suspect your claim is just wrong, since IIRC people have
> > successfully used these options with musl.
> 
> -fdata-sections breaks things to my understanding.
> 
> stdin.c (and others), have:
> 
> FILE *const stdin = &f;
> FILE *const __stdin_used = &f;
> 
> And __stdin_used is only ever referenced via weak alias. -fdata-section
> makes each symbol go to different section, and if linker has
> gc-sections, it'll remove any unreferenced section. This means

But the section is not unreferenced. There's a reference to
__stdin_used from __stdio_exit.o. Ignoring this reference just because
it could have been satisfied by a weak symbol is wrong.

> __stdin_used will never get pulled in causing problems like described
> in the original mail.

I don't see anywhere it's documented to behave this way, and in fact
making it behave this way would not only be harmful but more difficult
than making it behave correctly. The basic way a linker works is to
pull in all objects to satisfy undefined symbols; performing GC on
sections is a separate task that takes place (or at least should)
after all symbols have been resolved, and thus once it's possible to
know which symbols are referenced and which are not.

Rich


      reply	other threads:[~2014-05-08  5:18 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-06  9:07 Stephen Thomas
2014-05-06 10:14 ` Szabolcs Nagy
2014-05-06 21:11   ` Stephen Thomas
2014-05-06 23:18     ` Szabolcs Nagy
2014-05-07  9:04       ` Stephen Thomas
2014-05-07 10:04         ` Timo Teras
2014-05-08  0:03           ` Stephen Thomas
2014-05-08  1:06           ` Rich Felker
2014-05-08  2:08             ` Stephen Thomas
2014-05-08  3:01               ` Rich Felker
2014-05-08  5:11             ` Timo Teras
2014-05-08  5:18               ` Rich Felker [this message]

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=20140508051821.GG26358@brightrain.aerifal.cx \
    --to=dalias@libc.org \
    --cc=musl@lists.openwall.com \
    --cc=scjthm@live.com \
    --cc=timo.teras@iki.fi \
    /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.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

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 NNTP newsgroup(s).