-
Notifications
You must be signed in to change notification settings - Fork 52
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
Makes both stage1 and 2 as position independent executables #32
Conversation
Had to implement a memcpy replacement since PIC code is incompatible with the default newlib used by devkitarm.
@@ -13,9 +13,19 @@ | |||
extern u8 screen_init_bin[]; | |||
extern u32 screen_init_bin_size; | |||
|
|||
static inline void* copy_memory(void *dst, void *src, size_t amount) |
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.
As a heads up, PIC code isn't compatible with the newlib standard library shipped with devKitARM, so I included a simple replacement for memcpy here.
-Fixed a bug in the GOT relocation in stage1 _start.s. Wrong base address was being calculated. -Refactored stage1 and stage2 _start.s files. -Copied screen_init.c from dark_samus's repository, which was also worked on by Aurora. Looks cleaner, works fine. -Drew from changes cleaning up screen init from dark_samus's repository, which also includes changes done by Aurora. Files affected include bits of stage2 main.c, screen.h, and screen.c. -In order to handle icache correctly, now flushing caches right before jumping to the payload to make sure icache sees the data that has been placed in memory.
Tested on my console, werks |
In this case,what does "werk" mean? |
@mariogamer2 Assume it was a grammatical error. He's saying it works on his device. |
Can anyone test this with dark-samus/AuroraWright fork? (don't want to take the risk....) |
I tested this in my Old3DS, and it worked with no problems. |
works on my end (new3ds) |
These commits implement stage1 and 2 as position independent executables, meaning they can be placed at any address, and they should still run. Stage2 doesn't benefit from this too much (although this does mean it can easily be moved around now), but stage1 can now be moved without having to modify linker scripts if for some reason the key needs to change.
I have tested these changes on my o3DS. I tested stage1 relocation by changing the key being used to the old one and placing stage1 in the right place, but leaving everything else intact, which worked. It also works with the newer key. Stage2 I tested by simply changing the location in RAM where it was saved to and launched from. This also worked.
I would highly recommend this be tested by people with hardmods before being merged. I am not extremely confident in my understanding of PIC/PIE.
I also took the opportunity to try to improve the _start.s file in stage1, and the Makefiles.