[Bug debug/50544] New: Wrong esp offset in debug infos for functions that call stdcall functions

2011-09-27 Thread bernhardloos at googlemail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50544

 Bug #: 50544
   Summary: Wrong esp offset in debug infos for functions that
call stdcall functions
Classification: Unclassified
   Product: gcc
   Version: 4.6.1
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: debug
AssignedTo: unassig...@gcc.gnu.org
ReportedBy: bernhardl...@googlemail.com


Created attachment 25372
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=25372
compile with -g -O2

In the attached program, f2 disassambles to this:
   0x08048400 <+0>: sub$0x1c,%esp
   0x08048403 <+3>: mov0x8049708,%eax
   0x08048408 <+8>: mov%eax,(%esp)
   0x0804840b <+11>:call   0x80483e0 
   0x08048410 <+16>:sub$0x4,%esp
   0x08048413 <+19>:add$0x1c,%esp
   0x08048416 <+22>:ret

If one places a breakpoint at 0x08048410  the stack looks like this:
Breakpoint 1, 0x08048410 in f2 () at asdf.c:20
20  f(x);
(gdb) bt
#0  0x08048410 in f2 () at asdf.c:20
#1  0x08048420 in ?? ()
#2  0x4dedd413 in __libc_start_main (main=0x8048310 , argc=1,
ubp_av=0xb724,
init=0x8048420 <__libc_csu_init>, fini=0x8048490 <__libc_csu_fini>,
rtld_fini=0x4deb1dd0 <_dl_fini>, stack_end=0xb71c) at libc-start.c:226
#3  0x08048341 in _start ()

For 0x08048413, it looks as it should:
#0  f2 () at asdf.c:22
#1  0x0804831b in main (argc=1, argv=0xb724) at asdf.c:27

I would guess that the frame adjustment DWARF op is not emitted for the
instruction at 0x08048410.
Normally this wouldn't be much of a problem, but wine hits this sometimes with
the way it sets up windows exceptions, which makes this very annoying.

gcc version is
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/i686-redhat-linux/4.6.1/lto-wrapper
Target: i686-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
--infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla
--enable-bootstrap --enable-shared --enable-threads=posix
--enable-checking=release --with-system-zlib --enable-__cxa_atexit
--disable-libunwind-exceptions --enable-gnu-unique-object
--enable-linker-build-id
--enable-languages=c,c++,objc,obj-c++,java,fortran,ada,go,lto --enable-plugin
--enable-java-awt=gtk --disable-dssi
--with-java-home=/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/jre
--enable-libgcj-multifile --enable-java-maintainer-mode
--with-ecj-jar=/usr/share/java/eclipse-ecj.jar --disable-libjava-multilib
--with-ppl --with-cloog --with-tune=generic --with-arch=i686
--build=i686-redhat-linux
Thread model: posix
gcc version 4.6.1 20110804 (Red Hat 4.6.1-7) (GCC)


[Bug target/44060] New: miscompilation with -Os on x86

2010-05-10 Thread bernhardloos at googlemail dot com
Gcc 4.5 miscompiles the following code:

char buf[1024];
void add_input_file(int file) 
{
(*((int **)&buf))[0] = file;
}

it results in this asm:
Disassembly of section .text:

 :
   0:   c3  ret

The file argument is completly ignored.

gcc4.4 does the right thing:
Disassembly of section .text:

 :
   0:   a1 00 00 00 00  mov0x0,%eax
   5:   8b 54 24 04 mov0x4(%esp),%edx
   9:   89 10   mov%edx,(%eax)
   b:   c3  ret

The command used to produce this output was i486-openwrt-linux-gcc -c asdf.c
-fomit-frame-pointer -Os -o asdf2.o

Openwrt adds a number of patches to gcc, they can be seen here:
https://dev.openwrt.org/browser/trunk/toolchain/gcc/patches/4.5.0
None of them should interfer with the codegeneration for x86.
The problem doesn't seem to happen with the mips target.

This is the output of gcc -v:
Using built-in specs.
COLLECT_GCC=../staging_dir/toolchain-i386_gcc-4.5.0_uClibc-0.9.30.3/usr/bin/i486-openwrt-linux-gcc
COLLECT_LTO_WRAPPER=/home/asdf/openwrt/trunk/staging_dir/toolchain-i386_gcc-4.5.0_uClibc-0.9.30.3/usr/libexec/gcc/i486-openwrt-linux-uclibc/4.5.0/lto-wrapper
Target: i486-openwrt-linux-uclibc
Configured with:
/home/asdf/openwrt/trunk/build_dir/toolchain-i386_gcc-4.5.0_uClibc-0.9.30.3/gcc-4.5.0/configure
--prefix=/home/asdf/openwrt/trunk/staging_dir/toolchain-i386_gcc-4.5.0_uClibc-0.9.30.3/usr
--build=i586-redhat-linux --host=i586-redhat-linux
--target=i486-openwrt-linux-uclibc --with-gnu-ld --enable-target-optspace
--disable-libgomp --disable-libmudflap --disable-multilib --disable-nls
--with-ppl --with-cloog --with-host-libstdcxx=-lstdc++
--with-gmp=/home/asdf/openwrt/trunk/staging_dir/host
--with-mpfr=/home/asdf/openwrt/trunk/staging_dir/host --disable-decimal-float
--disable-libssp --disable-__cxa_atexit --enable-languages=c,c++
--enable-shared --enable-threads
--with-slibdir=/home/asdf/openwrt/trunk/staging_dir/toolchain-i386_gcc-4.5.0_uClibc-0.9.30.3/lib
--enable-lto --disable-tls
Thread model: posix
gcc version 4.5.0 (GCC)


-- 
   Summary: miscompilation with -Os on x86
   Product: gcc
   Version: 4.5.0
Status: UNCONFIRMED
  Severity: major
  Priority: P3
 Component: target
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: bernhardloos at googlemail dot com
GCC target triplet: i486-openwrt-linux-uclibc


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44060



[Bug target/44060] miscompilation with -Os on x86

2010-05-10 Thread bernhardloos at googlemail dot com


--- Comment #2 from bernhardloos at googlemail dot com  2010-05-10 14:57 
---
(In reply to comment #1)
> Try -Wstrict-aliasing.
> 

It does produce a warning about dreferencing a type-punned pointer.
I tried to compile the snipped with both -fstrict-aliasing and
-fno-strict-aliasing and it doesn't produce a difference in the code. Not on
the i486 gcc4.5 nor on the gcc4.4 in fedora.

Busybox uses this in some places and it did work in the past, so it would be
really nice, if this could get fixed.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44060



[Bug target/44060] miscompilation with -Os on x86

2010-05-10 Thread bernhardloos at googlemail dot com


--- Comment #5 from bernhardloos at googlemail dot com  2010-05-10 16:48 
---
It is a duplicate, my problem happens in exactly the same place.
Sorry I missed the other bug.

*** This bug has been marked as a duplicate of 43987 ***


-- 

bernhardloos at googlemail dot com changed:

   What|Removed |Added

 Status|UNCONFIRMED |RESOLVED
 Resolution||DUPLICATE


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44060



[Bug middle-end/43987] [4.5 Regression] type-punning causes broken binaries unless -O0 is used

2010-05-10 Thread bernhardloos at googlemail dot com


--- Comment #21 from bernhardloos at googlemail dot com  2010-05-10 16:48 
---
*** Bug 44060 has been marked as a duplicate of this bug. ***


-- 

bernhardloos at googlemail dot com changed:

   What|Removed |Added

 CC||bernhardloos at googlemail
   ||dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43987