tags:

views:

54

answers:

1

Hi,

i would like to play with the constructing calls feature of gcc...

From the doc :

— Built-in Function:

void * __builtin_apply (void (*function)(), void *arguments, size_t size)

This built-in function invokes function with a copy of the parameters described by arguments and size.

The value of arguments should be the value returned by __builtin_apply_args. The argument size specifies the size of the stack argument data, in bytes.

This function returns a pointer to data describing how to return whatever value was returned by function. The data is saved in a block of memory allocated on the stack.

It is not always simple to compute the proper value for size. The value is used by __builtin_apply to compute the amount of data that should be pushed on the stack and copied from the incoming argument area.

My question is how to know what size to give to this size argument ? And what are the consequences if the value is too small or too large ?

Thanks...

+1  A: 

Based on the code snippets I found via google, I would say that the size value is not something you can directly compute without more platform specific information (or at least knowing the calling convention). If the size is too small, then you won't pass enough arguments on the stack and the function will do something unspecified. If the size is too large, then you'll just use up unnecessary stack space.

MSN
That's what I fear. Do you have any idea what information I need ?
LB
It depends on the platform and the function signature of the function calling __builtin_apply. It would behoove you to learn how the stack frame is layed out for your particular platform and compiler.
MSN