Is there a way to force gcc to pass the parameters of a function on the stack?
I don't want to use the registers for parameter passing.
Update: I'am using arm-gcc from CodeSourcery
You can try wrapping the parameters in a structure; for example, if your function is int calc_my_sum(int x, int y) {return x+y;}
you can change it as follows (ugly):
struct my_x_y {
int x, y;
my_x_y(): x(0), y(0) {} // a non-trivial constructor to make the type non-POD
};
int calc_my_sum(my_x_y x_and_y) {
// passing non-POD object by value forces to use the stack
return x_and_y.x + x_and_y.y;
}
Alternatively, you can just add 4 dummy parameters to use up the registers, so other parameters will use stack:
struct force_stack_usage {
int dummy0, dummy1, dummy2, dummy3;
}
int calc_my_sum(force_stack_usage, int x, int y) {
return x + y;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With