Date: Thu, 14 Jan 2016 17:51:16 -0500 From: Rich Felker <dalias@...c.org> To: musl@...ts.openwall.com Subject: Re: string word-at-a-time and atomic.h FAQ on twitter 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
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.