I am using GCC 10.3.0 and I have this source code:
__asm__ volatile
(
"movl %%gs:%0, %%eax\n\t"
: "=a"(some_output)
: "i"(immediate_value)
);
I want to make GCC translate this instruction into
movl %gs:immediate_value, %eax
but because I am using AT&T syntax and using immediate value I get additional '$':
movl %gs:$immediate_value, %eax
and this is an incorrect AT&T syntax.
I know tha I can use 'r' constraint instead of 'i', which will be ok, but I need to get exactly this opcode with immediate value.
The second solution is to rewrite asm code using Intel syntax and to pass -masm=intel
to the compiler. But then I get errors with htons
function: with optimization flag -O3
GCC substitutes some AT&T asm code instead of direct call.
Please, advise me some solutions.