[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug gas/4079] New: Errors in @GOT

From: mikulas at artax dot karlin dot mff dot cuni dot cz
Subject: [Bug gas/4079] New: Errors in @GOT
Date: 19 Feb 2007 19:40:50 -0000

There are errors with expressions with @GOT suffix. They can be
manifested in this example:

#include <stdio.h>
__asm__ (".global number; number = 0x12345678");
extern void number;
int main()
        printf("%p\n", &number);
        return 0;

--- when this program is compiled with -fPIC, it crashes, without -fPIC it
prints 12345678. Note that if you split program to two files, one containing
__asm__ line and the other file containing the rest, compile with -fPIC and
link files statically or dynamically, it succeeds and prints correct value ---
12345678. Static and dynamic linker can process this relocation fine, but
that gas corrupts it if both definition and @GOT reference are in one file.

The error is caused by bad processing of @GOT suffix:

movl address@hidden, %eax is assembled as movl $constant, %eax --- which is
wrong. It should move offset in GOT, where pointer to constant is.

movl address@hidden, %eax will ignore the constant.

Gas should at least write error messages and not generate incorrect code when
encountering these constructs. With more work, some of these cases can be
assembled correctly:
movl address@hidden, %eax is assembled correctly --- special symbol with name 
is created and GOT relocation against this symbol is generated. movl
address@hidden, %eax could do exactly the same trick, setting the symbol to

movl address@hidden, %eax could be assembled corectly too by
creating special symbol --- but I don't see any use for such construct.
movl address@hidden, %eax cannot be correctly assembled and error
should be reported (current implementation just forgets the constant).

           Summary: Errors in @GOT
           Product: binutils
           Version: 2.17
            Status: NEW
          Severity: normal
          Priority: P2
         Component: gas
        AssignedTo: unassigned at sources dot redhat dot com
        ReportedBy: mikulas at artax dot karlin dot mff dot cuni dot cz
                CC: bug-binutils at gnu dot org
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]