Skip to content
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

Elf2rpl: Fix order of sections inside the .rpx #11

Merged
merged 4 commits into from
Jul 2, 2024

Conversation

Maschell
Copy link
Contributor

@Maschell Maschell commented Jul 1, 2024

The CafeOS Loader loads .rpx files in chunks of 4MiB. Because of this, it's very important, that the sections of the .rpx are in a order the loader is expecting. Additionally the section offets inside the .rpx should only be in ascending order as is impossible to access the "previous" 4MiB chunk. Only binaries bigger than 4MiB even have a chance running into these, this why we never caught this earlier

But when compiling fbalpha2012 retroarch core for Wii U, the .symtab section is still in the first 4MiB chunk (at 0x30D6C7), while the loader already loaded section from the second chunk (section 24, .dimport_coreinit at 0x43B67E).

This causes this check to fail in the loader:

grafik
grafik

The pull request tries to make sure the section are in the correct order. I don't really understand the logic for the LOADER section in current elf2rpl implemenation, but just copy pasting the conditions the actual loader is checking for seems to fix the order. Maybe the old elf2rpl implementation had to work around a broken/older wut.ld?

More tests are required but early results look promising. Here is a screenshot of a .elf converted to a .rpx with the patches of the PR.
grafik
The binary is not even big enough to be loaded in multiple chunks, but the offsets of the sections are now correct.

@Maschell Maschell marked this pull request as ready for review July 1, 2024 20:57
@Maschell
Copy link
Contributor Author

Maschell commented Jul 2, 2024

It has been confirmed this fixes conveting .elf of the two RetroArch cores that were producing incompatible .rpx before

Waiting for confirmation that .rpl creatinon is still working

@WinterMute WinterMute merged commit 9320942 into devkitPro:master Jul 2, 2024
1 check passed
@Maschell Maschell deleted the elf2rpl_section_order branch July 27, 2024 10:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants