@@ -72,8 +72,24 @@ ifeq ($(IOP_LINKFILE),)
7272IOP_LINKFILE := $(PS2SDK)/iop/startup/linkfile
7373endif
7474
75+ # Populate object paths
7576IOP_OBJS := $(IOP_OBJS:%=$(IOP_OBJS_DIR)%)
7677
78+ # If this build produces an exports.o, ensure it is linked first so the
79+ # export-table object occupies .text offset 0 (helps srxfixup detection).
80+ ifneq (,$(filter $(IOP_OBJS_DIR)exports.o,$(IOP_OBJS)))
81+ IOP_OBJS := $(IOP_OBJS_DIR)exports.o $(filter-out $(IOP_OBJS_DIR)exports.o,$(IOP_OBJS))
82+ endif
83+
84+ # srxfixup flags: default to `--rb --irx1`. If this module does not build an
85+ # exports.o, add `--allow-zero-text` (modules without an export table may
86+ # legitimately lack an STT_OBJECT at .text offset 0). Top-level Makefiles may
87+ # override `IOP_SRXFIXUP_FLAGS` if they need custom behaviour.
88+ IOP_SRXFIXUP_FLAGS := --rb --irx1
89+ ifeq (,$(filter $(IOP_OBJS_DIR)exports.o,$(IOP_OBJS)))
90+ IOP_SRXFIXUP_FLAGS += --allow-zero-text
91+ endif
92+
7793IOP_BIN_ELF := $(IOP_BIN:.irx=.notiopmod.elf)
7894
7995IOP_BIN_STRIPPED_ELF := $(IOP_BIN:.irx=.notiopmod.stripped.elf)
@@ -133,7 +149,7 @@ $(IOP_BIN_STRIPPED_ELF): $(IOP_BIN_ELF)
133149
134150$(IOP_BIN): $(IOP_BIN_STRIPPED_ELF)
135151 $(DIR_GUARD)
136- iopfixup --irx1 -o $@ $<
152+ iopfixup $(IOP_SRXFIXUP_FLAGS) -o $@ $<
137153
138154$(IOP_LIB): $(IOP_OBJS)
139155 $(DIR_GUARD)
0 commit comments