hi, i've discovered some weird problem with cross-binutils configured for {i686,x86_64}-pc-mingw32 targets with an explicite option: --enable-targets="i386-linux,x86_64-linux,i386-mingw32,x86_64-mingw32" with this option linker produces broken binaries. trivial testcase... #include <stdio.h> int main() { puts( "hello mingw world." ); return 0; } ...assembled/lined with binutils configured WITHOUT --enable-targets renders to proper .o and .exe: % less 32.good/test.o.asm (...) 00000000 <_main>: 0: 55 push %ebp 1: 89 e5 mov %esp,%ebp 3: 83 e4 f0 and $0xfffffff0,%esp 6: 83 ec 10 sub $0x10,%esp 9: e8 00 00 00 00 call e <_main+0xe> a: DISP32 ___main e: c7 04 24 00 00 00 00 movl $0x0,(%esp) 11: dir32 .rdata 15: e8 00 00 00 00 call 1a <_main+0x1a> 16: DISP32 _puts 1a: 31 c0 xor %eax,%eax 1c: c9 leave 1d: c3 ret % less 32.good/test.exe.asm (...) 004017d0 <_main>: 4017d0: 55 push %ebp 4017d1: 89 e5 mov %esp,%ebp 4017d3: 83 e4 f0 and $0xfffffff0,%esp 4017d6: 83 ec 10 sub $0x10,%esp 4017d9: e8 52 08 00 00 call 402030 <___main> 4017de: c7 04 24 a8 40 40 00 movl $0x4040a8,(%esp) 4017e5: e8 96 0b 00 00 call 402380 <_puts> 4017ea: 31 c0 xor %eax,%eax 4017ec: c9 leave 4017ed: c3 ret (...) 00402380 <_puts>: 402380: ff 25 c8 71 40 00 jmp *0x4071c8 402386: 90 nop 402387: 90 nop but WITH explcite --enable-targets we get correct .o and broken .exe: % less 32.bad/test.o.asm (...) 00000000 <_main>: 0: 55 push %ebp 1: 89 e5 mov %esp,%ebp 3: 83 e4 f0 and $0xfffffff0,%esp 6: 83 ec 10 sub $0x10,%esp 9: e8 f2 ff ff ff call 0 <_main> a: DISP32 ___main e: c7 04 24 00 00 00 00 movl $0x0,(%esp) 11: dir32 .rdata 15: e8 e6 ff ff ff call 0 <_main> 16: DISP32 _puts 1a: 31 c0 xor %eax,%eax 1c: c9 leave 1d: c3 ret % less 32.bad/test.exe.asm (...) 004017d0 <_main>: 4017d0: 55 push %ebp 4017d1: 89 e5 mov %esp,%ebp 4017d3: 83 e4 f0 and $0xfffffff0,%esp 4017d6: 83 ec 10 sub $0x10,%esp 4017d9: e8 44 08 00 00 call 402022 <___do_global_ctors+0xd2> ^^^^^ BAD! 4017de: c7 04 24 a8 40 40 00 movl $0x4040a8,(%esp) 4017e5: e8 7c 0b 00 00 call 402366 <__amsg_exit+0x6> ^^^^^ BAD! 4017ea: 31 c0 xor %eax,%eax 4017ec: c9 leave 4017ed: c3 ret (...) 00402380 <_puts>: 402380: ff 25 c8 71 40 00 jmp *0x4071c8 402386: 90 nop 402387: 90 afaics more emulations suported by binutils (with --enable-targets option) are problematic. % i686-pc-mingw32-ld -V GNU ld (Linux/GNU Binutils) 2.20.51.0.12.20101020 Supported emulations: i386pe elf_i386 i386linux elf_x86_64 elf_l1om i386pep
hmm, in fact the .o and .exe are broken, so there's a bug in assembler. diff -uNr 32.good/test.exe.asm 32.bad/test.exe.asm --- 32.good/test.exe.asm 2010-11-03 11:20:41.304319688 +0100 +++ 32.bad/test.exe.asm 2010-11-03 11:29:22.650344926 +0100 @@ -567,14 +567,13 @@ 4017d1: 89 e5 mov %esp,%ebp 4017d3: 83 e4 f0 and $0xfffffff0,%esp 4017d6: 83 ec 10 sub $0x10,%esp - 4017d9: e8 52 08 00 00 call 402030 <___main> + 4017d9: e8 44 08 00 00 call 402022 <___do_global_ctors+0xd2> 4017de: c7 04 24 a8 40 40 00 movl $0x4040a8,(%esp) - 4017e5: e8 96 0b 00 00 call 402380 <_puts> + 4017e5: e8 7c 0b 00 00 call 402366 <__amsg_exit+0x6> 4017ea: 31 c0 xor %eax,%eax 4017ec: c9 leave 4017ed: c3 ret - 4017ee: 90 nop - 4017ef: 90 nop + ... 004017f0 <___dyn_tls_dtor@12>: 4017f0: 55 push %ebp diff -uNr 32.good/test.log 32.bad/test.log --- 32.good/test.log 2010-11-03 11:20:41.293319703 +0100 +++ 32.bad/test.log 2010-11-03 11:29:22.639344917 +0100 @@ -33,6 +33,11 @@ GNU ld (Linux/GNU Binutils) 2.20.51.0.12.20101020 Supported emulations: i386pe + elf_i386 + i386linux + elf_x86_64 + elf_l1om + i386pep using internal linker script: ================================================== /* Default linker script, for normal executables */ Binary files 32.good/test.o and 32.bad/test.o differ diff -uNr 32.good/test.o.asm 32.bad/test.o.asm --- 32.good/test.o.asm 2010-11-03 11:20:41.296319699 +0100 +++ 32.bad/test.o.asm 2010-11-03 11:29:22.642344919 +0100 @@ -9,14 +9,13 @@ 1: 89 e5 mov %esp,%ebp 3: 83 e4 f0 and $0xfffffff0,%esp 6: 83 ec 10 sub $0x10,%esp - 9: e8 00 00 00 00 call e <_main+0xe> + 9: e8 f2 ff ff ff call 0 <_main> a: DISP32 ___main e: c7 04 24 00 00 00 00 movl $0x0,(%esp) 11: dir32 .rdata - 15: e8 00 00 00 00 call 1a <_main+0x1a> + 15: e8 e6 ff ff ff call 0 <_main> 16: DISP32 _puts 1a: 31 c0 xor %eax,%eax 1c: c9 leave 1d: c3 ret - 1e: 90 nop - 1f: 90 nop + ...
Created attachment 5107 [details] testcase with precompiled binaries.
I think this is a dup of #2606. See http://sourceware.org/ml/binutils/2006-04/msg00376.html
It is a dup *** This bug has been marked as a duplicate of bug 2606 ***