diff --git a/Defs.make b/Defs.make index 28e6e5b02ee9..06b2c2602dec 100644 --- a/Defs.make +++ b/Defs.make @@ -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 diff --git a/iop/Rules.make b/iop/Rules.make index d3346c3fe1fb..f4fe5a39ca34 100644 --- a/iop/Rules.make +++ b/iop/Rules.make @@ -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 @@ -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. @@ -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\"" > $@ @@ -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-debug --remove-section=.pdr -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) diff --git a/samples/Makefile.iopglobal_sample b/samples/Makefile.iopglobal_sample index 0f00a64e83ff..21630539c2e6 100644 --- a/samples/Makefile.iopglobal_sample +++ b/samples/Makefile.iopglobal_sample @@ -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 @@ -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. @@ -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-debug --remove-section=.pdr -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) diff --git a/samples/Makefile.pref_sample b/samples/Makefile.pref_sample index d03c793da701..7fd25f149d8c 100644 --- a/samples/Makefile.pref_sample +++ b/samples/Makefile.pref_sample @@ -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