Skip to content

Commit b16cc34

Browse files
committed
change: Use ELF toolchain and iopfixup to build IRX
1 parent bc5d944 commit b16cc34

File tree

4 files changed

+44
-8
lines changed

4 files changed

+44
-8
lines changed

Defs.make

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

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-debug --remove-section=.pdr -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)

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-debug --remove-section=.pdr -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

0 commit comments

Comments
 (0)