[iop]: run srxfixup with --rb during link to convert relative branches (fixes J/JAL reloc incompatibilities)#814
Merged
uyjulian merged 1 commit intops2dev:masterfrom Mar 6, 2026
Conversation
… builds R_MIPS_NONE is a valid no-op relocation type that newer toolchains emit (e.g. as padding between real relocations). srxfixup's fixlocation_an_rel() had no case for it and would fall through to the default unhandled-relocation path, causing srxfixup to abort when building any IRX that contained one. Enable --relative-branch (--rb) in iop/Rules.make so that all IOP IRX binaries have their R_MIPS_26 absolute-jump relocations converted to position-independent relative branches. Without this, a module loaded at a different address than it was linked for will execute the wrong jal target.
There was a problem hiding this comment.
Pull request overview
Updates the IOP module link pipeline to proactively eliminate problematic R_MIPS_26 relocations by enabling srxfixup’s relative-branch conversion, and ensures the relocation-applier logic tolerates R_MIPS_NONE entries created by that conversion.
Changes:
- Add
R_MIPS_NONEhandling insrxgen.crelocation fixup switch to avoid treating it as an unknown relocation type. - Enable
srxfixup --rbin the IOP.irxbuild rule so eligibleJ/JALare rewritten to PC-relative branches and theirR_MIPS_26relocs removed.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| tools/srxfixup/src/srxgen.c | Treats R_MIPS_NONE as a no-op relocation during fixlocation processing (prevents abort on type 0). |
| iop/Rules.make | Adds --rb to the IOP srxfixup invocation to avoid loader-incompatible R_MIPS_26 relocs. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Run srxfixup with the
--rb/--relative-branchoption in theIOPlink pipeline so eligibleJ/JALinstructions are rewritten to PC-relative branches and theirR_MIPS_26relocations removed. This prevents loader/relocation incompatibilities introduced by modern toolchains.Problem
Modern
GCC/binutilscan emitR_MIPS_26relocations forJ/JALinstructions (absolute jump relocs). The PS2 loader /IRXformat has limited/fragile handling for those relocations, which can lead to:This is more likely with newer toolchains and certain optimizations.
Solution
When
--rbis enabled,srxfixup:R_MIPS_26entries,