This question is related to this question: How can I access arguments 7+ using inline assembly?
I understand that accessing the pointers myself is non-standard, potentially unsafe, and not portable.
That being said, I'd like to get the stack pointer %rsp
and transfer its value into a C variable. Is it possible to do this with the following command?
int main()
{
void extra_args;
__asm__("mov %%rsp, %0": "=m"(extra_args));
return 0;
}
I've tried this, but it doesn't seem to point to the right place. Does the above command actually transfer %rsp
to the extra_args
variable?