-
-
Notifications
You must be signed in to change notification settings - Fork 708
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
Mac OS ARM Native reaches ELF entry #769
base: main
Are you sure you want to change the base?
Conversation
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.
Overall this is good enough to get to ARM entry but a bit incomplete and untested, particularly the address space changes could have an impact or might need more modifications. I think you should really make some initial progress with getting an ARM translator running and then PR this stuff once its verified to be a sound base, just to validate that everything here is correct.
CMakeLists.txt
Outdated
# Reserve system-managed memory space. | ||
target_link_options(shadps4 PRIVATE -Wl,-no_pie,-no_fixup_chains,-no_huge,-pagezero_size,0x4000,-segaddr,TCB_SPACE,0x4000,-segaddr,GUEST_SYSTEM,0x400000,-image_base,0x20000000000) | ||
# Using x86_64 (ARM by default if not set) | ||
if (CMAKE_OSX_ARCHITECTURES) |
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.
You will need to check more than just CMAKE_OSX_ARCHITECTURES
because it may be compiled natively on an Intel Mac. Simplest option I think would be to move the logic added to externals/CMakeList.txt
for ffmpeg to this file and use the ARCHITECTURE
variable to see if ARCHITECTURE STREQUAL "x86_64"
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.
Done
src/common/assert.cpp
Outdated
#define Crash() __asm__ __volatile__("int $3") | ||
#elif __aarch64__ | ||
#define Crash() ; |
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.
This should probably have an actual implementation.
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.
Done
src/common/rdtsc.cpp
Outdated
|
||
#else | ||
|
||
return 0; |
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.
Should have an alternate implementation or at least a TODO note.
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.
Done
#else | ||
// ARM | ||
static inline u64 FencedRDTSC() { | ||
return 0; |
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.
Same here for actual implementation or TODO.
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.
Done
ASSERT_MSG(ret != MAP_FAILED, "mmap failed: {}", strerror(errno)); | ||
} else { | ||
int ret = mprotect(reinterpret_cast<void*>(virtual_addr), size, prot); | ||
ASSERT_MSG(ret == 0, "mprotect failed: {}", strerror(errno)); |
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.
This and the below in Unmap
will need a closer look to make sure the behavior is correct, I put it together for you quick to get things going but I'm not sure it's good enough to go upstream.
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.
Actually no, this part was @squidbus who has more experience with the memory, so I trust that it's correct. Feel free to test though
[Edit] I just realized it was you that said the message, this was in the mem.patch file you gave me
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.
That's... me though.
src/core/linker.cpp
Outdated
void* Linker::TlsGetAddr(u64 module_index, u64 offset) { | ||
void* Linker::TlsGetAddr(u64 module_index, u64 offset) | ||
{ | ||
#ifdef __x86_64__ |
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.
You should probably just stub GetTcbBase()
for now if anything, not the whole thing here.
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.
Done
src/core/linker.cpp
Outdated
@@ -107,7 +119,9 @@ void Linker::Execute() { | |||
} | |||
} | |||
|
|||
#ifdef __x86_64__ | |||
SetTcbBase(nullptr); |
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.
Instead of stubbing out SetTcbBase
calls it should probably just have an stub function to call for now, it's going to need to be set up somehow for ARM translated code to access. Ditto for the other cases of this.
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.
Done
Reaches entry and then stops, the recompiler comes next