public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/37651]  New: __sync_bool_compare_and_swap creates wrong code with -fPIC
@ 2008-09-25 19:46 fm3 at os dot inf dot tu-dresden dot de
  2008-09-25 21:37 ` [Bug target/37651] " pinskia at gcc dot gnu dot org
  2008-09-25 22:30 ` brian at dessent dot net
  0 siblings, 2 replies; 4+ messages in thread
From: fm3 at os dot inf dot tu-dresden dot de @ 2008-09-25 19:46 UTC (permalink / raw)
  To: gcc-bugs

The following example dumps a core if compiled with -march=i586 -fPIC:

#include <stdint.h>
int main(void)
{
    static uint64_t volatile s_u64;
    __sync_bool_compare_and_swap(&s_u64, 0, 0);
}

The reason is that %ebx will be used as pointer for the memory variable.

I can reproduce this bug so far with gcc-4.2 and gcc-4.3.2 (both Debian Sid).

$ gcc -v
Using built-in specs.
Target: i486-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 4.3.2-1'
--with-bugurl=file:///usr/share/doc/gcc-4.3/README.Bugs
--enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --enable-shared
--with-system-zlib --libexecdir=/usr/lib --without-included-gettext
--enable-threads=posix --enable-nls --with-gxx-include-dir=/usr/include/c++/4.3
--program-suffix=-4.3 --enable-clocale=gnu --enable-libstdcxx-debug
--enable-objc-gc --enable-mpfr --enable-targets=all --enable-cld
--enable-checking=release --build=i486-linux-gnu --host=i486-linux-gnu
--target=i486-linux-gnu
Thread model: posix
gcc version 4.3.2 (Debian 4.3.2-1)


-- 
           Summary: __sync_bool_compare_and_swap creates wrong code with -
                    fPIC
           Product: gcc
           Version: 4.3.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: fm3 at os dot inf dot tu-dresden dot de
 GCC build triplet: i486-linux-gnu
  GCC host triplet: i486-linux-gnu
GCC target triplet: i486-linux-gnu


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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug target/37651] __sync_bool_compare_and_swap creates wrong code with -fPIC
  2008-09-25 19:46 [Bug target/37651] New: __sync_bool_compare_and_swap creates wrong code with -fPIC fm3 at os dot inf dot tu-dresden dot de
@ 2008-09-25 21:37 ` pinskia at gcc dot gnu dot org
  2008-09-25 22:30 ` brian at dessent dot net
  1 sibling, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2008-09-25 21:37 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from pinskia at gcc dot gnu dot org  2008-09-25 21:36 -------
I get:
        xchgl   %ebx, %edi
        lock ; cmpxchg8b        (%esi)
        xchgl   %ebx, %edi

Which looks good.


-- 


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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug target/37651] __sync_bool_compare_and_swap creates wrong code with -fPIC
  2008-09-25 19:46 [Bug target/37651] New: __sync_bool_compare_and_swap creates wrong code with -fPIC fm3 at os dot inf dot tu-dresden dot de
  2008-09-25 21:37 ` [Bug target/37651] " pinskia at gcc dot gnu dot org
@ 2008-09-25 22:30 ` brian at dessent dot net
  1 sibling, 0 replies; 4+ messages in thread
From: brian at dessent dot net @ 2008-09-25 22:30 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from brian at dessent dot net  2008-09-25 22:29 -------
Subject: Re:  __sync_bool_compare_and_swap creates wrong code 
 with -fPIC

You get that if the variable is auto, but if it's static the reference
is with a GOTOFF reloc:

        xorl    %edi, %edi
        pushl   %ebx
        call    .L6
.L6:
        popl    %ebx
        addl    $_GLOBAL_OFFSET_TABLE_+[.-.L6], %ebx
        pushl   %ecx
        movl    %edi, %ecx
        xchgl   %ebx, %edi
        lock cmpxchg8b  s_u64.1229@GOTOFF(%ebx)


-- 


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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug target/37651] __sync_bool_compare_and_swap creates wrong code with -fPIC
       [not found] <bug-37651-4@http.gcc.gnu.org/bugzilla/>
@ 2012-01-06 10:19 ` aph at gcc dot gnu.org
  0 siblings, 0 replies; 4+ messages in thread
From: aph at gcc dot gnu.org @ 2012-01-06 10:19 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Haley <aph at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
                 CC|                            |aph at gcc dot gnu.org
         Resolution|                            |WORKSFORME

--- Comment #3 from Andrew Haley <aph at gcc dot gnu.org> 2012-01-06 10:17:52 UTC ---
Reproducible with with 4.2.4 but not with 4.4.6 or 4.6.2 or HEAD.


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-01-06 10:19 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-09-25 19:46 [Bug target/37651] New: __sync_bool_compare_and_swap creates wrong code with -fPIC fm3 at os dot inf dot tu-dresden dot de
2008-09-25 21:37 ` [Bug target/37651] " pinskia at gcc dot gnu dot org
2008-09-25 22:30 ` brian at dessent dot net
     [not found] <bug-37651-4@http.gcc.gnu.org/bugzilla/>
2012-01-06 10:19 ` aph at gcc dot gnu.org

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 read-only IMAP folder(s) and NNTP newsgroup(s).