public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/46275] New: -masm=intel -fPIC causes global offset table issues
@ 2010-11-02 18:30 hezekiahehud at gmail dot com
  2010-11-02 18:30 ` [Bug c/46275] " hezekiahehud at gmail dot com
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: hezekiahehud at gmail dot com @ 2010-11-02 18:30 UTC (permalink / raw)
  To: gcc-bugs

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

           Summary: -masm=intel -fPIC causes global offset table issues
           Product: gcc
           Version: 4.4.5
            Status: UNCONFIRMED
          Severity: major
          Priority: P3
         Component: c
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: hezekiahehud@gmail.com


Created attachment 22231
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=22231
Output from gcc -v -save-temps ...

The combination of -masm=intel and -fPIC when producing 32-bit causes strange
behaviour when dealing with globals.  Specifically, it looks like calculations
using the global offset table are being done incorrectly.  (I'm not sure if
this is because the EBX register was loaded with the wrong value or if the
computations using it are somehow off.)

You can reproduce the bug with a simple Hello World program.  I used the
following code and the command "gcc -m32 -fPIC -masm=intel -o hello hello.c":

#include <stdio.h>
int main()
{ puts("Hello, world!"); }

If you run the resulting 32-bit ELF, you get an output other than "Hello,
world!"  (In my case, I get a single 0x02 byte and the newline added by puts.) 
As far as my debugging has shown, it appears that an incorrect address is
computed for the "Hello, world!" global string constant.

If you compile the same code either without -fPIC or without -masm=intel, the
resulting executable works as expected.

I originally discovered the bug on a 32-bit system with a 32-bit gcc
executable, so it does not seem to be specific to running the compiler in a
64-bit environment; the 32-bit output seems to be the important part.


I have attached the compiler output from a -v -save-temps run.  I will attach
the hello.i file shortly.


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

end of thread, other threads:[~2010-11-03 14:13 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-11-02 18:30 [Bug c/46275] New: -masm=intel -fPIC causes global offset table issues hezekiahehud at gmail dot com
2010-11-02 18:30 ` [Bug c/46275] " hezekiahehud at gmail dot com
2010-11-02 18:31 ` [Bug target/46275] " pinskia at gcc dot gnu.org
2010-11-02 18:33 ` hezekiahehud at gmail dot com
2010-11-02 18:35 ` hezekiahehud at gmail dot com
2010-11-02 18:40 ` pinskia at gcc dot gnu.org
2010-11-02 18:54 ` hezekiahehud at gmail dot com
2010-11-02 18:59 ` pinskia at gcc dot gnu.org
2010-11-02 19:08 ` hezekiahehud at gmail dot com
2010-11-02 21:07 ` ubizjak at gmail dot com
2010-11-03  8:48 ` ubizjak at gmail dot com
2010-11-03 14:03 ` hjl.tools at gmail dot com
2010-11-03 14:13 ` hezekiahehud at gmail dot com

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).