Binding a single function symbol with [foreign]
Jorn Vernee
jbvernee at xs4all.nl
Mon Sep 10 14:33:48 UTC 2018
> So, for simple calls like puts, which take a single integer register
> value and returns via a single register value, things *should* work -
> but it seems like it doesn't. Anyway, the current support is, as I
> wrote, mostly Linux and MacOs centric - and we're not planning to do
> Windows tweak in the short term at least. But your experiment suggests
> that we might not be that far off the mark...
I was just reading up on the MS x64 ABI [1], and the main difference
seems to be that the caller is expected to allocate 32 bytes of 'shadow
space' on the stack right before the call so that the function can do
argument register spill into that space (I guess to make it easier to
forward to cdecl functions?). It doesn't look like the current
implementation accounts for that (?), so puts is probably corrupting the
stack values that are there, and it blows up on return.
Jorn
[1] :
https://en.wikipedia.org/wiki/X86_calling_conventions#Microsoft_x64_calling_convention
More information about the panama-dev
mailing list