From: Rich Felker <dalias@libc.org>
To: musl@lists.openwall.com
Subject: Re: string word-at-a-time and atomic.h FAQ on twitter
Date: Thu, 14 Jan 2016 17:51:16 -0500 [thread overview]
Message-ID: <20160114225116.GY238@brightrain.aerifal.cx> (raw)
In-Reply-To: <20160113173049.GF13558@port70.net>
On Wed, Jan 13, 2016 at 06:30:50PM +0100, Szabolcs Nagy wrote:
> i tried to do it with -fno-lto
>
> but it seems gcc-6 miscompiles musl with -flto anyway:
>
> lto incorrectly dead code eliminates _dlstart_c.
> (the libc entry point, _dlstart, is defined in toplevel
> inline asm in ldso/dlstart.c and it jumps to _dlstart_c)
I think the files that receive "crt" treatment (-DCRT?) should be
hard-coded as no-LTO. Even if it weren't for this issue, there are
also potential issues with optimizations that might move code across
relocations and initialization. At the very least there should be a
full asm barrier between such init code and the rest of the program.
> lto breaks symbol binding for environ, _environ, ___environ.
> (they should be weak, without that environ in a main binary
> has different address than in libc.so)
>
> libc.so built with -flto:
> $ readelf --dyn-syms -W libc.so |grep envi
> 22: 000000000028eb90 8 OBJECT GLOBAL DEFAULT 15 __environ
> 398: 000000000028eb90 8 OBJECT GLOBAL PROTECTED 15 ___environ
> 1034: 000000000028eb90 8 OBJECT GLOBAL PROTECTED 15 _environ
> 1107: 000000000028eb90 8 OBJECT GLOBAL DEFAULT 15 environ
>
> libc.so without -flto:
> $ readelf --dyn-syms -W libc.so |grep envi
> 22: 000000000028d2d8 8 OBJECT GLOBAL DEFAULT 15 __environ
> 398: 000000000028d2d8 8 OBJECT WEAK PROTECTED 15 ___environ
> 1034: 000000000028d2d8 8 OBJECT WEAK PROTECTED 15 _environ
> 1107: 000000000028d2d8 8 OBJECT WEAK DEFAULT 15 environ
This is purely a gcc bug and indicates LTO is not really ready for use
with libc, which means I don't see much sense in trying to support it
yet. Of course that doesn't mean I'm disinterested in fixing actual C
language usage errors (aliasing, etc.) that might break with LTO.
Rather I'm disinterested in LTO-specific hacks for working around bugs
in GCC's LTO. OTOH your patch is nice from the standpoint of being
able to test LTO and find and report the bugs.
Rich
prev parent reply other threads:[~2016-01-14 22:51 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-05 16:46 Szabolcs Nagy
2016-01-05 17:50 ` Rich Felker
2016-01-05 23:39 ` Matthew Fernandez
2016-01-06 2:56 ` Szabolcs Nagy
2016-01-08 21:59 ` Alexander Cherepanov
2016-01-08 22:05 ` Rich Felker
2016-01-08 22:39 ` Alexander Cherepanov
2016-01-08 22:59 ` Rich Felker
2016-01-09 1:40 ` Szabolcs Nagy
2016-01-12 12:41 ` Alexander Cherepanov
2016-01-12 21:02 ` Alexander Cherepanov
2016-01-12 21:09 ` Alexander Cherepanov
2016-01-12 23:07 ` Szabolcs Nagy
2016-01-13 17:30 ` Szabolcs Nagy
2016-01-14 12:49 ` Szabolcs Nagy
2016-01-14 22:51 ` 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=20160114225116.GY238@brightrain.aerifal.cx \
--to=dalias@libc.org \
--cc=musl@lists.openwall.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.
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).