Binding a single function symbol with [foreign]

Jorn Vernee jbvernee at xs4all.nl
Tue Sep 11 08:48:29 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...

Got it working!

In the end I made 3 changes [1] :

* Allocate 32 bytes of shadow space before the call.

* Make sure the number of return registers is set to 1 on windows (it 
was hard-coded as 2).

* Make sure RDI and RSI are preserved by the native stub.

`printf` also works for simple calls. So yeah, not far off the mark at 
all.

Again; just leaving this here for future reference :)

Jorn

[1] : 
https://gist.github.com/JornVernee/240a079abe6791b3fa5c9d14613ef28d


More information about the panama-dev mailing list