From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/5087 Path: news.gmane.org!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general Subject: Re: Linking musl with ld.gold Date: Thu, 8 May 2014 01:18:21 -0400 Message-ID: <20140508051821.GG26358@brightrain.aerifal.cx> References: <20140506101410.GP12324@port70.net> <20140506231807.GQ12324@port70.net> <20140507130443.72c74f47@vostro> <20140508010605.GE26358@brightrain.aerifal.cx> <20140508081126.140b0064@vostro> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1399526334 2061 80.91.229.3 (8 May 2014 05:18:54 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 8 May 2014 05:18:54 +0000 (UTC) Cc: musl@lists.openwall.com, scjthm@live.com To: Timo Teras Original-X-From: musl-return-5093-gllmg-musl=m.gmane.org@lists.openwall.com Thu May 08 07:18:46 2014 Return-path: Envelope-to: gllmg-musl@plane.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1WiGjD-0005ag-UZ for gllmg-musl@plane.gmane.org; Thu, 08 May 2014 07:18:44 +0200 Original-Received: (qmail 32640 invoked by uid 550); 8 May 2014 05:18:43 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Original-Received: (qmail 32629 invoked from network); 8 May 2014 05:18:43 -0000 Content-Disposition: inline In-Reply-To: <20140508081126.140b0064@vostro> User-Agent: Mutt/1.5.21 (2010-09-15) Original-Sender: Rich Felker Xref: news.gmane.org gmane.linux.lib.musl.general:5087 Archived-At: On Thu, May 08, 2014 at 08:11:26AM +0300, Timo Teras wrote: > On Wed, 7 May 2014 21:06:05 -0400 > Rich Felker 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