How to make gcc aware of arguments in embedded assembly code?

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

 



Hi,

I have the following embedded assembly code which works fine without
optimization. But it fails when the optimization is enabled. How to
make gcc aware of the fact that the assembly code takes arguments?

$ cat main.c
int f(int x, int y) {
	__asm__(
			"lea (%rdi, %rsi, 1), %rax\n"
			"pop %rbp\n"
			"ret\n"
			);
}
int main() {
	return f(1, 2);
}
$ gcc main.c
$ ./a.out || echo "$?"
3
$ gcc -O3 main.c
$ ./a.out || echo "$?"
Segmentation fault
139

-- 
Regards,
Peng



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux