PureGo Version
v0.10.2
Operating System
Go Version (go version)
1.26.5
What steps will reproduce the problem?
For C functions with signatures like
int64_t some_fn(uintptr_t a1, int64_t a2)
or
int64_t some_fn(uintptr_t a1, uintptr_t a2, uintptr_t a3, uintptr_t a4, uintptr_t a5, int64_t a6)
arguments and return values are corruped when called via purego. This also applies to callbacks.
However, signatures like
int64_t some_fn(uintptr_t a1, uintptr_t a2, int64_t a3)
or
int64_t some_fn(uintptr_t a1, uintptr_t a2, uintptr_t a3, uintptr_t a4, uintptr_t a5, uintptr_t a6, int64_t a7)
will work.
What is the expected result?
64-bit function arguments are properly serialized and return values are properly deserialized
What happens instead?
I'm getting invalid values
Anything else you feel useful to add?
This happens because purego does not comply with 32-bit AAPCS. Exact points:
C.3 If the argument requires double-word alignment (8-byte), the NCRN is rounded up to the next even register number.
C.7 If the argument required double-word alignment (8-byte), then the NSAA is rounded up to the next double-word address.
PureGo Version
v0.10.2
Operating System
Go Version (
go version)1.26.5
What steps will reproduce the problem?
For C functions with signatures like
or
arguments and return values are corruped when called via purego. This also applies to callbacks.
However, signatures like
or
will work.
What is the expected result?
64-bit function arguments are properly serialized and return values are properly deserialized
What happens instead?
I'm getting invalid values
Anything else you feel useful to add?
This happens because purego does not comply with 32-bit AAPCS. Exact points: