Force gcc to pass parameters on the stack

Is there a way to get gcc to pass parameters to a function on the stack?

I do not want to use registers to pass parameters.

Update . I am using arm-gcc from CodeSourcery

+5
source share
3 answers

According to: http://infocenter.arm.com/help/topic/com.arm.doc.ihi0042d/IHI0042D_aapcs.pdf

The first four registers r0-r3 (a1-a4) are used to transfer the values ​​of the arguments to the subroutine and return the result value from the function. They can also store intermediate values ​​in a routine (but, in general, only between subroutine calls).

ARM , , . :

  • ? , .
  • , ABI, , . , x86-32, , x64 (AMD64 Microsoft). , ARM, ? .
0

; , int calc_my_sum(int x, int y) {return x+y;}, ():

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;
}

4 , , :

struct force_stack_usage {
    int dummy0, dummy1, dummy2, dummy3;
}

int calc_my_sum(force_stack_usage, int x, int y) {
    return x + y;
}
+1

, . , . , , .

0

All Articles