There are errors with expressions with @GOT suffix. They can be
manifested in this example:
__asm__ (".global number; number = 0x12345678");
extern void number;
--- 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 $constant@GOT, %eax is assembled as movl $constant, %eax --- which is
wrong. It should move offset in GOT, where pointer to constant is.
movl $symbol+constant@GOT, %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
movl $.@GOT, %eax is assembled correctly --- special symbol with name "L0\001"
is created and GOT relocation against this symbol is generated. movl
$constant@GOT, %eax could do exactly the same trick, setting the symbol to
movl $defined_symbol+constant@GOT, %eax could be assembled corectly too by
creating special symbol --- but I don't see any use for such construct.
movl $extern_symbol+constant@GOT, %eax cannot be correctly assembled and error
should be reported (current implementation just forgets the constant).