Created attachment 5699 [details] 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.
Inline asm constraints are for instructions. asm(".global foo.b;" "foo.b = %0\n" :: "i" (offsetof(foo, b))); isn't an instruction. In any case, it isn't an assembler issue.