Skip to content

Commit 00f199a

Browse files
committed
change: Use ELF toolchain and iopfixup to build IRX
1 parent e78a9cb commit 00f199a

File tree

6 files changed

+48
-12
lines changed

6 files changed

+48
-12
lines changed

Defs.make

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ EE_PKG_CONFIG ?= $(EE_TOOL_PREFIX)pkg-config
3030
# Defintions for the IOP toolchain.
3131
#
3232

33-
IOP_TOOL_PREFIX ?= mipsel-ps2-irx-
33+
IOP_TOOL_PREFIX ?= mipsel-none-elf-
3434
IOP_CC ?= $(IOP_TOOL_PREFIX)gcc
3535
IOP_AS ?= $(IOP_TOOL_PREFIX)as
3636
IOP_LD ?= $(IOP_TOOL_PREFIX)ld

iop/Rules.make

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ ifeq ($(DEBUG),1)
4040
IOP_CFLAGS += -DDEBUG
4141
endif
4242
# Linker flags
43-
IOP_LDFLAGS := -nostdlib -s $(IOP_LDFLAGS)
43+
IOP_LDFLAGS := -nostdlib -dc -r $(IOP_LDFLAGS)
4444

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

72+
# Default link file
73+
ifeq ($(IOP_LINKFILE),)
74+
IOP_LINKFILE := $(PS2SDKSRC)/iop/startup/src/linkfile
75+
endif
76+
7277
IOP_OBJS := $(IOP_OBJS:%=$(IOP_OBJS_DIR)%)
7378

79+
IOP_BIN_ELF := $(IOP_BIN:.irx=.notiopmod.elf)
80+
81+
IOP_BIN_STRIPPED_ELF := $(IOP_BIN:.irx=.notiopmod.stripped.elf)
82+
7483
# Externally defined variables: IOP_BIN, IOP_OBJS, IOP_LIB
7584

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

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

107+
$(PS2SDKSRC)/tools/srxfixup/bin/srxfixup: $(PS2SDKSRC)/tools/srxfixup
108+
$(MAKEREC) $<
109+
98110
$(IOP_OBJS_DIR)template-imports.h:
99111
$(DIR_GUARD)
100112
$(PRINTF) '%s\n' "#include \"irx_imports.h\"" > $@
@@ -121,9 +133,16 @@ $(IOP_OBJS_DIR)exports.o: $(IOP_OBJS_DIR)build-exports.c
121133
$(DIR_GUARD)
122134
$(IOP_C_COMPILE) $(IOP_IETABLE_CFLAGS) -c $< -o $@
123135

124-
$(IOP_BIN): $(IOP_OBJS) $(IOP_LIB_ARCHIVES) $(IOP_ADDITIONAL_DEPS)
136+
$(IOP_BIN_ELF): $(IOP_OBJS) $(IOP_LIB_ARCHIVES) $(IOP_ADDITIONAL_DEPS)
137+
$(DIR_GUARD)
138+
$(IOP_C_COMPILE) -T$(IOP_LINKFILE) $(IOP_OPTFLAGS) -o $@ $(IOP_OBJS) $(IOP_LDFLAGS) $(IOP_LIB_ARCHIVES) $(IOP_LIBS)
139+
140+
$(IOP_BIN_STRIPPED_ELF): $(IOP_BIN_ELF)
125141
$(DIR_GUARD)
126-
$(IOP_C_COMPILE) $(IOP_OPTFLAGS) -o $(IOP_BIN) $(IOP_OBJS) $(IOP_LDFLAGS) $(IOP_LIB_ARCHIVES) $(IOP_LIBS)
142+
$(IOP_STRIP) --strip-unneeded --remove-section=.pdr --remove-section=.comment --remove-section=.mdebug.abi32 --remove-section=.gnu.attributes -o $@ $<
143+
144+
$(IOP_BIN): $(IOP_BIN_STRIPPED_ELF) $(PS2SDKSRC)/tools/srxfixup/bin/srxfixup
145+
$(PS2SDKSRC)/tools/srxfixup/bin/srxfixup --irx1 -o $@ $<
127146

128147
$(IOP_LIB)_tmp$(MAKE_CURPID): $(IOP_OBJS)
129148
$(DIR_GUARD)

iop/startup/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,5 @@ release:
2424
@$(PRINTF) 'Installing %slinkfile into %s/iop/startup\n' $(IOP_SRC_DIR) $(PS2SDK)
2525
$(ECHO) Installing $(IOP_SRC_DIR)linkfile into $(PS2SDK)/iop/startup
2626
cp -f $(IOP_SRC_DIR)linkfile $(PS2SDK)/iop/startup
27-
@$(ECHO) Installing $(IOP_OBJS_DIR)crt0.o into $(PS2DEV)/ee/mipsel-ps2-irx/lib
28-
cp -f $(IOP_OBJS_DIR)crt0.o $(PS2DEV)/iop/mipsel-ps2-irx/lib
27+
@$(ECHO) Installing $(IOP_OBJS_DIR)crt0.o into $(PS2DEV)/iop/mipsel-none-elf/lib
28+
cp -f $(IOP_OBJS_DIR)crt0.o $(PS2DEV)/iop/mipsel-none-elf/lib

samples/Makefile.iopglobal_sample

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ IOP_DBGINFOFLAGS ?= -gdwarf-2 -gz
3838
# for finer-grained control over what goes into each IRX.
3939
IOP_CFLAGS := -D_IOP -fno-builtin -G0 $(IOP_OPTFLAGS) $(IOP_WARNFLAGS) $(IOP_DBGINFOFLAGS) $(IOP_INCS) $(IOP_CFLAGS)
4040
# linker flags
41-
IOP_LDFLAGS := -nostdlib -s $(IOP_LDFLAGS)
41+
IOP_LDFLAGS := -nostdlib -dc -r $(IOP_LDFLAGS)
4242

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

70+
# Default link file
71+
ifeq ($(IOP_LINKFILE),)
72+
IOP_LINKFILE := $(PS2SDK)/iop/startup/linkfile
73+
endif
74+
7075
IOP_OBJS := $(IOP_OBJS:%=$(IOP_OBJS_DIR)%)
7176

77+
IOP_BIN_ELF := $(IOP_BIN:.irx=.notiopmod.elf)
78+
79+
IOP_BIN_STRIPPED_ELF := $(IOP_BIN:.irx=.notiopmod.stripped.elf)
80+
7281
# Externally defined variables: IOP_BIN, IOP_OBJS, IOP_LIB
7382

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

113-
$(IOP_BIN): $(IOP_OBJS)
122+
$(IOP_BIN_ELF): $(IOP_OBJS)
123+
$(DIR_GUARD)
124+
$(IOP_C_COMPILE) -T$(IOP_LINKFILE) $(IOP_OPTFLAGS) -o $@ $(IOP_OBJS) $(IOP_LDFLAGS) $(IOP_LIBS)
125+
126+
$(IOP_BIN_STRIPPED_ELF): $(IOP_BIN_ELF)
127+
$(DIR_GUARD)
128+
$(IOP_STRIP) --strip-unneeded --remove-section=.pdr --remove-section=.comment --remove-section=.mdebug.abi32 --remove-section=.gnu.attributes -o $@ $<
129+
130+
$(IOP_BIN): $(IOP_BIN_STRIPPED_ELF)
114131
$(DIR_GUARD)
115-
$(IOP_C_COMPILE) $(IOP_OPTFLAGS) -o $(IOP_BIN) $(IOP_OBJS) $(IOP_LDFLAGS) $(IOP_LIBS)
132+
iopfixup --irx1 -o $@ $<
116133

117134
$(IOP_LIB): $(IOP_OBJS)
118135
$(DIR_GUARD)

samples/Makefile.pref_sample

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ EE_RANLIB ?= $(EE_TOOL_PREFIX)ranlib
2929
# Defintions for the IOP toolchain.
3030
#
3131

32-
IOP_TOOL_PREFIX ?= mipsel-ps2-irx-
32+
IOP_TOOL_PREFIX ?= mipsel-none-elf-
3333
IOP_CC ?= $(IOP_TOOL_PREFIX)gcc
3434
IOP_AS ?= $(IOP_TOOL_PREFIX)as
3535
IOP_LD ?= $(IOP_TOOL_PREFIX)ld

samples/ps2dev_iop.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ endif()
2525
SET(CMAKE_SYSTEM_NAME Generic)
2626
SET(CMAKE_SYSTEM_VERSION 1)
2727
SET(CMAKE_SYSTEM_PROCESSOR mips)
28-
SET(CMAKE_C_COMPILER mipsel-ps2-irx-gcc)
29-
SET(CMAKE_CXX_COMPILER mipsel-ps2-irx-g++)
28+
SET(CMAKE_C_COMPILER mipsel-none-elf-gcc)
29+
SET(CMAKE_CXX_COMPILER mipsel-none-elf-g++)
3030
SET(CMAKE_C_COMPILER_WORKS 1) #Hack by f0bes
3131
SET(CMAKE_CXX_COMPILER_WORKS 1) #Hack by f0bes
3232

0 commit comments

Comments
 (0)