http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47891
Summary: GCC 4.6 LTO not worked reliable on Windows target Product: gcc Version: 4.6.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: lto AssignedTo: unassig...@gcc.gnu.org ReportedBy: dongsheng.s...@gmail.com Created attachment 23464 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=23464 exe file which have invalid address reference to _puts I have test LTO with hello.cpp and hello.c, testing on hello.cpp passed, testing on hello.c sucks with: Program received signal SIGSEGV, Segmentation fault. Here is gcc and binutils version information: $ i686-w64-mingw32-ld -v GNU ld (GNU Binutils) 2.21.51.20110225 $ i686-w64-mingw32-gcc -v Using built-in specs. COLLECT_GCC=i686-w64-mingw32-gcc COLLECT_LTO_WRAPPER=/home/oracle/gcc-4.6-windows_i686-linux/libexec/gcc/i686-w64-mingw32/4.6.0/lto-wrapper Target: i686-w64-mingw32 Configured with: /home/oracle/vcs/svn/gcc/trunk/configure --prefix=/home/oracle/gcc-4.6-windows_i686-linux --with-sysroot=/home/oracle/gcc-4.6-windows_i686-linux --build=i686-pc-linux-gnu --host=i686-pc-linux-gnu --target=i686-w64-mingw32 --enable-targets=all --with-arch-32=x86-64 --with-tune-32=generic --with-arch-64=x86-64 --with-tune-64=generic --with-fpmath=sse --enable-fully-dynamic-string --disable-nls --enable-languages=c,c++,fortran,objc,obj-c++ --enable-libgomp --enable-libssp --enable-lto --enable-cloog-backend=ppl-legacy Thread model: win32 gcc version 4.6.0 20110224 (experimental) (GCC) With LTO, the generated exe file have invalid address reference to _puts: $ i686-w64-mingw32-gcc -g -flto -o hello.c.lto.exe Hello.c $ i686-w64-mingw32-objdump -d hello.c.lto.exe 00402430 <_main>: 402430: 55 push %ebp 402431: 89 e5 mov %esp,%ebp 402433: 83 e4 f0 and $0xfffffff0,%esp 402436: 83 ec 10 sub $0x10,%esp 402439: e8 02 fb ff ff call 401f40 <___main> 40243e: c7 04 24 94 42 40 00 movl $0x404294,(%esp) 402445: e8 b6 db bf ff call 0 <_puts> 40244a: b8 00 00 00 00 mov $0x0,%eax 40244f: c9 leave 402450: c3 ret 402451: 90 nop 402452: 90 nop 402453: 90 nop With LTO, it's OK: $ i686-w64-mingw32-gcc -g -o hello.c.exe Hello.c $ i686-w64-mingw32-objdump -d hello.c.exe 004015f0 <_main>: 4015f0: 55 push %ebp 4015f1: 89 e5 mov %esp,%ebp 4015f3: 83 e4 f0 and $0xfffffff0,%esp 4015f6: 83 ec 10 sub $0x10,%esp 4015f9: e8 72 09 00 00 call 401f70 <___main> 4015fe: c7 04 24 68 40 40 00 movl $0x404068,(%esp) 401605: e8 fe 0d 00 00 call 402408 <_puts> 40160a: b8 00 00 00 00 mov $0x0,%eax 40160f: c9 leave 401610: c3 ret 401611: 90 nop 401612: 90 nop 401613: 90 nop I checked GCC 4.5.3 20110224 with same binutils version, it works fine.