3 ms·
I've implemented the exact same thing once, and found out later that it really doesn't work. The problem is that the caller cleans up the stack in the 32-bit c
by dezgeg 13y ago
I've implemented the exact same thing once, and found out later that it really doesn't work.
The problem is that the caller cleans up the stack in the 32-bit ccall calling convention.
For example, when main calls write_stdout("foo", 3) it will push 3 and "foo" to the stack. The generated stub pushes 1 to the stack, and jumps into the write() function. After write() returns, main() pops off the 2 parameters it pushed, and now the stack is misaligned since no-one popped the parameter pushed by the generated stub.