Skip to content

Commit 3fa3704

Browse files
committed
srxfixup: handle R_MIPS_NONE relocation; use --relative-branch in IOP 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.
1 parent 2bac3a6 commit 3fa3704

2 files changed

Lines changed: 3 additions & 1 deletion

File tree

iop/Rules.make

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ $(IOP_BIN_STRIPPED_ELF): $(IOP_BIN_ELF)
146146
$(IOP_STRIP) --strip-unneeded --remove-section=.pdr --remove-section=.comment --remove-section=.mdebug.abi32 --remove-section=.gnu.attributes -o $@ $<
147147

148148
$(IOP_BIN): $(IOP_BIN_STRIPPED_ELF) $(PS2SDKSRC)/tools/srxfixup/bin/srxfixup
149-
$(PS2SDKSRC)/tools/srxfixup/bin/srxfixup --irx1 -o $@ $<
149+
$(PS2SDKSRC)/tools/srxfixup/bin/srxfixup --rb --irx1 -o $@ $<
150150

151151
$(IOP_LIB)_tmp$(MAKE_CURPID): $(IOP_OBJS)
152152
$(DIR_GUARD)

tools/srxfixup/src/srxgen.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,8 @@ static void fixlocation_an_rel(elf_section *relsect, unsigned int startaddr)
412412
datal = &relsect->info->data[rp->rel.r_offset - relsect->info->shr.sh_addr];
413413
switch ( rp->type )
414414
{
415+
case R_MIPS_NONE:
416+
break;
415417
case R_MIPS_16:
416418
data_1 = startaddr + (int16_t)*(uint32_t *)datal;
417419
if ( (uint16_t)(data_1 >> 16) )

0 commit comments

Comments
 (0)