When i disassembly simple code and found a question.
Why local variable isn't place in current function stack??
ex: The "_ZN3aaa10build_user17h6ef656f427941943E" function does't create stack frame only use previous function's stack.
line :5,6,7
This my code :
https://gist.github.com/wayling/4f0a2b40dece616893722299631b7441
Firstly, questions like this should probably be asked in the users.rust-lang.org section next time.
Secondly to answer your question, LLVM may choose several ways to return a struct. The ABI may allow returning it in multiple registers, or as you see here there is an implicit out parameter. Here you’ll see where space is allocated on the stack and rdi
is set to point towards that space on the stack. The rdi
is one of the argument registers. The other function then uses this pointer to construct the struct.
(to answer why sub rsp, 0x20
but lea rdi, [rbp-0x18]
only 0x18 bytes are needed but it usually preferable and perhaps required on some ABIs that the stack is kept specially aligned)
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.