-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
[LINUX/CPU/BASE] Added System-V ABI support in x64 backend & fixed mmap initialization #2228
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
2ba9f97
to
2638550
Compare
2638550
to
75b958e
Compare
75b958e
to
add1b00
Compare
This was required for me to get the CPU to work at all on Linux, before it was jumping to a random address due to the mismatched function arguments. |
…#2228 back to canary builds. This fixes various emulation crashes caused from different calling conventions on System-V ABI platforms compared to the Windows standard.
…#2228 back to canary builds. This fixes various emulation crashes caused from different calling conventions on System-V ABI platforms compared to the Windows standard.
… for Linux Upstream changes made from xenia-project#1339 and xenia-project#2228 back to canary builds. This fixes various emulation crashes caused from different calling conventions on System-V ABI platforms compared to Windows standard.
… for Linux Upstream changes made from xenia-project#1339 and xenia-project#2228 back to canary builds. This fixes various emulation crashes caused from different calling conventions on System-V ABI platforms compared to Windows standard.
… for Linux Upstream changes made from xenia-project#1339 and xenia-project#2228 back to canary builds. This fixes various emulation crashes caused from different calling conventions on System-V ABI platforms compared to Windows standard.
add(rsp, stack_size); | ||
ret(); | ||
#elif XE_PLATFORM_LINUX || XE_PLATFORM_MAC | ||
// This function is being called using the Microsoft ABI from CallNative |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to research the usage of registers in the guest instruction translation and probably change CallNativeSafe
itself instead, there's no need to use the Microsoft calling convention anywhere on Linux. Instruction implementations calling native functions seem to use GetNativeParam
, it possibly should be enough to modify GetNativeParam
, though all call sites need to be checked carefully.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#2018 already has the GetNativeParam changes.
Current thunks in x64_backend.cc assumed that the calling convention is Microsoft ABI. Added an implementation for the System-V ABI which is used in Unix(-like) systems (Linux/MacOS/FreeBSD/etc).
When memory mapping a file, we should ensure it is large enough.
See:
https://wiki.osdev.org/System_V_ABI
https://man7.org/linux/man-pages/man2/mmap.2.html