From f3746f3c05e889dc5715f1aa0357a9070e9ebe32 Mon Sep 17 00:00:00 2001 From: Julian Uy Date: Fri, 6 Mar 2026 17:24:17 -0600 Subject: [PATCH 1/2] fix: Fixes to export rearrange Rearrange exports in ps2sdk makefile also Make the export rearrange unconditional Rearrange object files before prepending object directory Create directory for build-exports before continuing --- iop/Rules.make | 4 ++++ samples/Makefile.iopglobal_sample | 11 +++++------ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/iop/Rules.make b/iop/Rules.make index 42b69dd6fdc..a9a831140e9 100644 --- a/iop/Rules.make +++ b/iop/Rules.make @@ -78,6 +78,10 @@ ifeq ($(IOP_LINKFILE),) IOP_LINKFILE := $(PS2SDKSRC)/iop/startup/src/linkfile endif +# If this build produces an exports.o, ensure it is linked first so the +# export-table object occupies .text offset 0 (helps srxfixup detection). +IOP_OBJS := $(filter exports.o,$(IOP_OBJS)) $(filter-out exports.o,$(IOP_OBJS)) + IOP_OBJS := $(IOP_OBJS:%=$(IOP_OBJS_DIR)%) IOP_BIN_ELF := $(IOP_BIN:.irx=.notiopmod.elf) diff --git a/samples/Makefile.iopglobal_sample b/samples/Makefile.iopglobal_sample index defdf51bb3e..81602bfd719 100644 --- a/samples/Makefile.iopglobal_sample +++ b/samples/Makefile.iopglobal_sample @@ -72,14 +72,12 @@ ifeq ($(IOP_LINKFILE),) IOP_LINKFILE := $(PS2SDK)/iop/startup/linkfile endif -# Populate object paths -IOP_OBJS := $(IOP_OBJS:%=$(IOP_OBJS_DIR)%) - # If this build produces an exports.o, ensure it is linked first so the # export-table object occupies .text offset 0 (helps srxfixup detection). -ifneq (,$(filter $(IOP_OBJS_DIR)exports.o,$(IOP_OBJS))) -IOP_OBJS := $(IOP_OBJS_DIR)exports.o $(filter-out $(IOP_OBJS_DIR)exports.o,$(IOP_OBJS)) -endif +IOP_OBJS := $(filter exports.o,$(IOP_OBJS)) $(filter-out exports.o,$(IOP_OBJS)) + +# Populate object paths +IOP_OBJS := $(IOP_OBJS:%=$(IOP_OBJS_DIR)%) # srxfixup flags: default to `--rb --irx1`. If this module does not build an # exports.o, add `--allow-zero-text` (modules without an export table may @@ -132,6 +130,7 @@ $(IOP_OBJS_DIR)imports.o: $(IOP_OBJS_DIR)build-imports.c # Rules to build exports.tab. $(IOP_OBJS_DIR)build-exports.c: $(IOP_SRC_DIR)exports.tab + $(DIR_GUARD) $(PRINTF) '%s\n' "#include \"irx.h\"" > $@ cat $< >> $@ From fbdc7ecc29bc9c8bed2899530d9f46cff1ff6f0f Mon Sep 17 00:00:00 2001 From: Julian Uy Date: Fri, 6 Mar 2026 17:29:19 -0600 Subject: [PATCH 2/2] fix: move retonly function to end of export table --- iop/iLink/iLinkman/src/exports.tab | 7 ++++--- iop/security/secrman/src/exports.tab | 7 ++++--- iop/security/secrsif/src/exports.tab | 9 +++++---- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/iop/iLink/iLinkman/src/exports.tab b/iop/iLink/iLinkman/src/exports.tab index 38a91f76eb7..fe235ca4f96 100644 --- a/iop/iLink/iLinkman/src/exports.tab +++ b/iop/iLink/iLinkman/src/exports.tab @@ -1,10 +1,9 @@ -void _funcret(){}; DECLARE_EXPORT_TABLE(iLinkman, 1, 1) DECLARE_EXPORT(_start) /* 000 */ - DECLARE_EXPORT(_funcret) + DECLARE_EXPORT(_retonly) DECLARE_EXPORT(_exit) /* 002 */ - DECLARE_EXPORT(_funcret) /* 003 */ + DECLARE_EXPORT(_retonly) /* 003 */ DECLARE_EXPORT(iLinkEnableSBus) /* 004 */ DECLARE_EXPORT(iLinkDisableSBus) /* 005 */ DECLARE_EXPORT(iLinkResetSBus) /* 006 */ @@ -28,3 +27,5 @@ DECLARE_EXPORT_TABLE(iLinkman, 1, 1) DECLARE_EXPORT(iLinkReadCROM) /* 024 */ DECLARE_EXPORT(iLinkGetLocalNodeEUI64) /* 025 */ END_EXPORT_TABLE + +void _retonly(){}; diff --git a/iop/security/secrman/src/exports.tab b/iop/security/secrman/src/exports.tab index 3d25c411993..f497cd97bf8 100644 --- a/iop/security/secrman/src/exports.tab +++ b/iop/security/secrman/src/exports.tab @@ -1,11 +1,10 @@ -void _funcret(){}; // El_isra: this was 0x1, 0x3 originally. but the IRX_ID macro on source code has 0x1, 0x4. just like arcade SECRMAN... DECLARE_EXPORT_TABLE(secrman, 0x01, 0x04) DECLARE_EXPORT(_start) - DECLARE_EXPORT(_funcret) + DECLARE_EXPORT(_retonly) DECLARE_EXPORT(_exit) - DECLARE_EXPORT(_funcret) + DECLARE_EXPORT(_retonly) DECLARE_EXPORT(SecrSetMcCommandHandler) /* 004 */ DECLARE_EXPORT(SecrSetMcDevIDHandler) /* 005 */ DECLARE_EXPORT(SecrAuthCard) /* 006 */ @@ -26,3 +25,5 @@ DECLARE_EXPORT_TABLE(secrman, 0x01, 0x04) DECLARE_EXPORT(SecrAuthDongle) /* 020 */ #endif END_EXPORT_TABLE + +void _retonly(){}; diff --git a/iop/security/secrsif/src/exports.tab b/iop/security/secrsif/src/exports.tab index e6140e07809..89cb37cbb8f 100644 --- a/iop/security/secrsif/src/exports.tab +++ b/iop/security/secrsif/src/exports.tab @@ -1,8 +1,9 @@ -void _funcret(){}; DECLARE_EXPORT_TABLE(secrsif, 1, 1) DECLARE_EXPORT(_start) - DECLARE_EXPORT(_funcret) - DECLARE_EXPORT(_funcret) - DECLARE_EXPORT(_funcret) + DECLARE_EXPORT(_retonly) + DECLARE_EXPORT(_retonly) + DECLARE_EXPORT(_retonly) END_EXPORT_TABLE + +void _retonly(){};