[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug gas/12719] New: strange behavior with immediate symbols when using
From: |
theorizer at freemail dot hu |
Subject: |
[Bug gas/12719] New: strange behavior with immediate symbols when using inline assembly |
Date: |
Sun, 1 May 2011 13:37:11 +0000 |
http://sourceware.org/bugzilla/show_bug.cgi?id=12719
Summary: strange behavior with immediate symbols when using
inline assembly
Product: binutils
Version: 2.21
Status: NEW
Severity: minor
Priority: P2
Component: gas
AssignedTo: address@hidden
ReportedBy: address@hidden
Created attachment 5699
--> http://sourceware.org/bugzilla/attachment.cgi?id=5699
example sources
With the gnu c-compiler, assuming the structure
typedef struct foo {
int a;
int b;
} foo;
and the define below
#define offsetof(type, member) __builtin_offsetof(type, member)
one can write the following inline assembly lines to define a symbol for offset
of member "b" within the foo structure above:
asm(".global foo.b;"
"foo.b = %0\n"
:: "i" (offsetof(foo, b)));
The problem is that by default gcc generates the following (it assumes at&t
syntax):
.global foo.b; foo.b = $4
This line is although compiled by "as" but the symbol foo.b won't be defined
(instead only the $4 symbol is declared to be undefined (extern).
If you however apply the -masm=intel compiler switch the statements below will
be generated as expected:
.global foo.b; foo.b = 4
by this workaround "as" will properly define the foo.b symbol and my test
project (see in attachments) builds correctly.
To test it apply the following commands on the attached files:
gcc main.c add_one.S -o test
or
gcc -masm=intel main.c add_one.S -o test
in the first case it doesn't link, in the latter one it builds perfectly.
The test code is assumed to be built and run on x86-64 Linux and FreeBSD
systems.
I tested the issue with binutils versions 2.15, 2.20, 2.21. All are the same in
this regard.
--
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
- [Bug gas/12719] New: strange behavior with immediate symbols when using inline assembly,
theorizer at freemail dot hu <=