Reputation: 481
I'm working on the Pintos toy operating system at university, but there's a strange bug when using GCC 4.6.2. When I push my system call arguments (just 3 pushl-s in inline assembly), some mysterious data also appears on the stack, and the arguments are in the wrong order. Setting -fno-omit-frame-pointer gets rid of the strange data, but the arguments are still in the wrong order. GCC 4.5 works fine. Any idea what specific option could fix this?
NOTE: the problem still occurs with -O0.
Upvotes: 0
Views: 378
Reputation: 3911
Did you clean the parameters on stack after the syscall? gcc may not be aware that you touch the stack and generate code depends on the stack pointer it expected. -fno-omit-frame-pointer force gcc to use e/rbp for accessing locate data but it just hide the actual problem.
Upvotes: 0
Reputation: 481
The culprit was -fomit-frame-pointer, which has been enabled by default since 4.6.2. -fno-omit-frame-pointer fixed the issue.
Upvotes: 0
Reputation: 3482
Without a code example and a listing of the result from your different compilations, it's difficult to help you. But here are three possible causes for your problems:
printf(char *, ...)
to examine the first item to find out how many more there are. If you want to call the function int foo(int a, int b, int c)
, you'll need to push c, then b and finally a.volatile
/__volatile__
in front of it. Otherwise GCC is allowed to move it when optimizing.I need to see your code to better understand what's going on.
Upvotes: 1