mkw icon indicating copy to clipboard operation
mkw copied to clipboard

Replace binary blob extab(index) with linker-generated sections

Open riptl opened this issue 3 years ago • 1 comments

The linker is supposed to generate the extab and extabindex sections.

Since we don't have the source code to do that, we used binary blob .s files to recreate them. This is where the first problem occurs. The linker segfaults when feeding it object files with existing extab / extabindex sections. As a workaround, the sections were renamed to extab_ / extabindex_.

The second problem is the symbol _eti_init_info. This is a linker-generated symbol. Trying to reference it when using the extab_ hack instead of actual extab is also going to make the linker crash.

So as another workaround, I've defined _eti_init_info_ with a hardcoded address.

I feel like we should work towards the root problem: Fixing extab and extabindex in the object files with some magic, so that the linker has no problem generating its exception-related symbols and sections.

I'm not sure on this but I think if we don't do this, we're not going to have C++ runtime exception support.

riptl avatar Aug 03 '21 20:08 riptl

Really excellent writeup. I think this will be relatively low priority as the game itself makes no use of C++ exceptions--the vast majority of the unwind tables were accidentally generated by the RFL library. Hopefully once we get that split, generating the tables will be relatively simple.

riidefi avatar Aug 03 '21 20:08 riidefi