Skip to content

Commit

Permalink
change: Use ELF toolchain and iopfixup to build IRX
Browse files Browse the repository at this point in the history
  • Loading branch information
uyjulian committed Dec 21, 2024
1 parent d6815bc commit 131daa6
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Defs.make
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ EE_PKG_CONFIG ?= $(EE_TOOL_PREFIX)pkg-config
# Defintions for the IOP toolchain.
#

IOP_TOOL_PREFIX ?= mipsel-ps2-irx-
IOP_TOOL_PREFIX ?= mipsel-none-elf-
IOP_CC ?= $(IOP_TOOL_PREFIX)gcc
IOP_AS ?= $(IOP_TOOL_PREFIX)as
IOP_LD ?= $(IOP_TOOL_PREFIX)ld
Expand Down
25 changes: 22 additions & 3 deletions iop/Rules.make
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ ifeq ($(DEBUG),1)
IOP_CFLAGS += -DDEBUG
endif
# Linker flags
IOP_LDFLAGS := -nostdlib -s $(IOP_LDFLAGS)
IOP_LDFLAGS := -nostdlib -dc -r $(IOP_LDFLAGS)

# Additional C compiler flags for GCC >=v5.3.0
# -msoft-float is to "remind" GCC/Binutils that the soft-float ABI is to be used. This is due to a bug, which
Expand Down Expand Up @@ -69,8 +69,17 @@ endif
# Assembler flags
IOP_ASFLAGS := $(ASFLAGS_TARGET) -EL -G0 $(IOP_ASFLAGS)

# Default link file
ifeq ($(IOP_LINKFILE),)
IOP_LINKFILE := $(PS2SDKSRC)/iop/startup/src/linkfile
endif

IOP_OBJS := $(IOP_OBJS:%=$(IOP_OBJS_DIR)%)

IOP_BIN_ELF := $(IOP_BIN:.irx=.notiopmod.elf)

IOP_BIN_STRIPPED_ELF := $(IOP_BIN:.irx=.notiopmod.stripped.elf)

# Externally defined variables: IOP_BIN, IOP_OBJS, IOP_LIB

# These macros can be used to simplify certain build rules.
Expand All @@ -95,6 +104,9 @@ $(IOP_OBJS_DIR)%.o: $(IOP_SRC_DIR)%.s

.INTERMEDIATE:: $(IOP_LIB)_tmp$(MAKE_CURPID) $(IOP_OBJS_DIR)build-imports.c $(IOP_OBJS_DIR)build-exports.c

$(PS2SDKSRC)/tools/srxfixup/bin/srxfixup: $(PS2SDKSRC)/tools/srxfixup
$(MAKEREC) $<

$(IOP_OBJS_DIR)template-imports.h:
$(DIR_GUARD)
$(PRINTF) '%s\n' "#include \"irx_imports.h\"" > $@
Expand All @@ -121,9 +133,16 @@ $(IOP_OBJS_DIR)exports.o: $(IOP_OBJS_DIR)build-exports.c
$(DIR_GUARD)
$(IOP_C_COMPILE) $(IOP_IETABLE_CFLAGS) -c $< -o $@

$(IOP_BIN): $(IOP_OBJS) $(IOP_LIB_ARCHIVES) $(IOP_ADDITIONAL_DEPS)
$(IOP_BIN_ELF): $(IOP_OBJS) $(IOP_LIB_ARCHIVES) $(IOP_ADDITIONAL_DEPS)
$(DIR_GUARD)
$(IOP_C_COMPILE) -T$(IOP_LINKFILE) $(IOP_OPTFLAGS) -o $@ $(IOP_OBJS) $(IOP_LDFLAGS) $(IOP_LIB_ARCHIVES) $(IOP_LIBS)

$(IOP_BIN_STRIPPED_ELF): $(IOP_BIN_ELF)
$(DIR_GUARD)
$(IOP_C_COMPILE) $(IOP_OPTFLAGS) -o $(IOP_BIN) $(IOP_OBJS) $(IOP_LDFLAGS) $(IOP_LIB_ARCHIVES) $(IOP_LIBS)
$(IOP_STRIP) --strip-unneeded --remove-section=.pdr --remove-section=.comment --remove-section=.mdebug.abi32 --remove-section=.gnu.attributes -o $@ $<

$(IOP_BIN): $(IOP_BIN_STRIPPED_ELF) $(PS2SDKSRC)/tools/srxfixup/bin/srxfixup
$(PS2SDKSRC)/tools/srxfixup/bin/srxfixup --irx1 -o $@ $<

$(IOP_LIB)_tmp$(MAKE_CURPID): $(IOP_OBJS)
$(DIR_GUARD)
Expand Down
23 changes: 20 additions & 3 deletions samples/Makefile.iopglobal_sample
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ IOP_DBGINFOFLAGS ?= -gdwarf-2 -gz
# for finer-grained control over what goes into each IRX.
IOP_CFLAGS := -D_IOP -fno-builtin -G0 $(IOP_OPTFLAGS) $(IOP_WARNFLAGS) $(IOP_DBGINFOFLAGS) $(IOP_INCS) $(IOP_CFLAGS)
# linker flags
IOP_LDFLAGS := -nostdlib -s $(IOP_LDFLAGS)
IOP_LDFLAGS := -nostdlib -dc -r $(IOP_LDFLAGS)

# Additional C compiler flags for GCC >=v5.3.0
# -msoft-float is to "remind" GCC/Binutils that the soft-float ABI is to be used. This is due to a bug, which
Expand Down Expand Up @@ -67,8 +67,17 @@ endif
# Assembler flags
IOP_ASFLAGS := $(ASFLAGS_TARGET) -EL -G0 $(IOP_ASFLAGS)

# Default link file
ifeq ($(IOP_LINKFILE),)
IOP_LINKFILE := $(PS2SDK)/iop/startup/linkfile
endif

IOP_OBJS := $(IOP_OBJS:%=$(IOP_OBJS_DIR)%)

IOP_BIN_ELF := $(IOP_BIN:.irx=.notiopmod.elf)

IOP_BIN_STRIPPED_ELF := $(IOP_BIN:.irx=.notiopmod.stripped.elf)

# Externally defined variables: IOP_BIN, IOP_OBJS, IOP_LIB

# These macros can be used to simplify certain build rules.
Expand Down Expand Up @@ -110,9 +119,17 @@ $(IOP_OBJS_DIR)exports.o: $(IOP_OBJS_DIR)build-exports.c
$(DIR_GUARD)
$(IOP_C_COMPILE) $(IOP_IETABLE_CFLAGS) -c $< -o $@

$(IOP_BIN): $(IOP_OBJS)
$(IOP_BIN_ELF): $(IOP_OBJS)
$(DIR_GUARD)
$(IOP_C_COMPILE) -T$(IOP_LINKFILE) $(IOP_OPTFLAGS) -o $@ $(IOP_OBJS) $(IOP_LDFLAGS) $(IOP_LIBS)

$(IOP_BIN_STRIPPED_ELF): $(IOP_BIN_ELF)
$(DIR_GUARD)
$(IOP_STRIP) --strip-unneeded --remove-section=.pdr --remove-section=.comment --remove-section=.mdebug.abi32 --remove-section=.gnu.attributes -o $@ $<

$(IOP_BIN): $(IOP_BIN_STRIPPED_ELF)
$(DIR_GUARD)
$(IOP_C_COMPILE) $(IOP_OPTFLAGS) -o $(IOP_BIN) $(IOP_OBJS) $(IOP_LDFLAGS) $(IOP_LIBS)
iopfixup --irx1 -o $@ $<

$(IOP_LIB): $(IOP_OBJS)
$(DIR_GUARD)
Expand Down
2 changes: 1 addition & 1 deletion samples/Makefile.pref_sample
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ EE_RANLIB ?= $(EE_TOOL_PREFIX)ranlib
# Defintions for the IOP toolchain.
#

IOP_TOOL_PREFIX ?= mipsel-ps2-irx-
IOP_TOOL_PREFIX ?= mipsel-none-elf-
IOP_CC ?= $(IOP_TOOL_PREFIX)gcc
IOP_AS ?= $(IOP_TOOL_PREFIX)as
IOP_LD ?= $(IOP_TOOL_PREFIX)ld
Expand Down

0 comments on commit 131daa6

Please sign in to comment.