Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
4 changes: 2 additions & 2 deletions iop/startup/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@ release:
@$(PRINTF) 'Installing %slinkfile into %s/iop/startup\n' $(IOP_SRC_DIR) $(PS2SDK)
$(ECHO) Installing $(IOP_SRC_DIR)linkfile into $(PS2SDK)/iop/startup
cp -f $(IOP_SRC_DIR)linkfile $(PS2SDK)/iop/startup
@$(ECHO) Installing $(IOP_OBJS_DIR)crt0.o into $(PS2DEV)/ee/mipsel-ps2-irx/lib
cp -f $(IOP_OBJS_DIR)crt0.o $(PS2DEV)/iop/mipsel-ps2-irx/lib
@$(ECHO) Installing $(IOP_OBJS_DIR)crt0.o into $(PS2DEV)/iop/mipsel-none-elf/lib
cp -f $(IOP_OBJS_DIR)crt0.o $(PS2DEV)/iop/mipsel-none-elf/lib
242 changes: 145 additions & 97 deletions iop/startup/src/linkfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,110 +3,158 @@
# ____| | ____| | | |____|
# | ___| |____ ___| ____| | \ PS2DEV Open Source Project.
#-----------------------------------------------------------------------
# Copyright 2001-2022, ps2dev - http://www.ps2dev.org
# Copyright ps2dev - http://www.ps2dev.org
# Licenced under Academic Free License version 2.0
# Review ps2sdk README & LICENSE files for further details.
#
# Linkfile script for iop-ld
*/

OUTPUT_FORMAT("elf32-littlemips")
SEARCH_DIR("");
OUTPUT_FORMAT("elf32-littlemips", "elf32-bigmips",
"elf32-littlemips")
OUTPUT_ARCH(mips)
ENTRY(_start)
PHDRS
{
irxhdr 0x70000080 FLAGS (PF_R); /* 0x70000080 -> PT_SCE_IOPMOD */
defhdr PT_LOAD FLAGS (PF_X | PF_W | PF_R);
}
SEARCH_DIR("");
/* FORCE_COMMON_ALLOCATION */
/* Do we need any of these for elf?
__DYNAMIC = 0; */
SECTIONS
{
. = SIZEOF_HEADERS;

.text 0 : ALIGN(16) {
CREATE_OBJECT_SYMBOLS
PROVIDE (_ftext = .) ;
KEEP (* ( .module.imports )) ;
* ( .text )
* ( .text.* )
* ( .init )
* ( .fini )
KEEP (* ( .module.exports )) ;
PROVIDE (_etext = .) ;
} :defhdr = 0

.rodata : ALIGN(16) {
* ( .rdata )
* ( .rodata )
* ( .rodata1 )
* ( .rodata.* )
} :defhdr = 0

.data : ALIGN(16) {
* ( .data )
* ( .data1 )
* ( .data.* )
CONSTRUCTORS
} :defhdr = 0

.bss : ALIGN(16) {
* ( .bss )
* ( .bss.* )
* ( COMMON )
. = ALIGN(4) ;
} :defhdr
_gp = ALIGN(16) ;

/*
* This is the .iopmod section for the IRX, it contains information that
* the IOP uses when loading the IRX.
* This section is placed in its own segment.
*/
.iopmod 0 (COPY) : ALIGN(4) {
/*
* The linker will replace this first LONG with a pointer to _irx_id
* if the symbol has been defined.
*/
LONG (DEFINED(_irx_id) ? ABSOLUTE(_irx_id) : 0xffffffff) ;
LONG (ABSOLUTE(_start)) ;
LONG (_gp) ;
LONG (SIZEOF(.text)) ;
LONG (SIZEOF(.data)) ;
LONG (SIZEOF(.bss)) ;
/*
* The linker will put a SHORT here with the version of the IRX
* (or zero if there is no version).
*/
/*
* The linker will put a null terminated string here containing the
* name of the IRX (or an empty string if the name is not known).
*/
KEEP (* ( .iopmod.version )) ;
KEEP (* ( .iopmod.name )) ;
FILL(0x00000000);
} :irxhdr = 0

/*
* These are the stuff that we don't want to be put in an IRX.
*/
/DISCARD/ : {
* ( .MIPS.abiflags )
* ( .comment )
* ( .debug_* )
* ( .gnu.attributes )
* ( .mdebug.* )
* ( .reginfo )
* ( .symtab )
* ( .strtab )
* ( .shstrtab )
* ( .eh_frame )
/*
* This must go because it confuses the IOP kernel (treated as a reloc section).
*/
* ( .pdr )
/*
* Until I can figure out if there's a better way to rid ourselves of
* .rel.dyn this will have to do. - MRB
*/
* ( .rel.dyn )
}
/* Read-only sections, merged into text segment: */
. = 0x0400000; /* Can conditionally be changed to . = 0x5ffe0000 + SIZEOF_HEADERS; */
.interp : { *(.interp) } /* Can conditionally be removed */
.reginfo : { *(.reginfo) }
.hash : { *(.hash) }
.dynsym : { *(.dynsym) }
.dynstr : { *(.dynstr) }
.gnu.version : { *(.gnu.version) }
.gnu.version_d : { *(.gnu.version_d) }
.gnu.version_r : { *(.gnu.version_r) }
.rel.text :
{ *(.rel.text) *(.rel.gnu.linkonce.t*) }
.rela.text :
{ *(.rela.text) *(.rela.gnu.linkonce.t*) }
.rel.data :
{ *(.rel.data) *(.rel.gnu.linkonce.d*) }
.rela.data :
{ *(.rela.data) *(.rela.gnu.linkonce.d*) }
.rel.rodata :
{ *(.rel.rodata) *(.rel.gnu.linkonce.r*) }
.rela.rodata :
{ *(.rela.rodata) *(.rela.gnu.linkonce.r*) }
.rel.got : { *(.rel.got) }
.rela.got : { *(.rela.got) }
.rel.ctors : { *(.rel.ctors) }
.rela.ctors : { *(.rela.ctors) }
.rel.dtors : { *(.rel.dtors) }
.rela.dtors : { *(.rela.dtors) }
.rel.init : { *(.rel.init) }
.rela.init : { *(.rela.init) }
.rel.fini : { *(.rel.fini) }
.rela.fini : { *(.rela.fini) }
.rel.bss : { *(.rel.bss) }
.rela.bss : { *(.rela.bss) }
.rel.plt : { *(.rel.plt) }
.rela.plt : { *(.rela.plt) }
.init : { *(.init) } =0
.plt : { *(.plt) }
.text :
{
PROVIDE(_ftext = . );
*(.text)
*(.stub)
/* .gnu.warning sections are handled specially by elf32.em. */
*(.gnu.warning)
*(.gnu.linkonce.t*)
*(.mips16.fn.*) *(.mips16.call.*)
} =0
PROVIDE(_etext = .);
PROVIDE (etext = .);
.fini : { *(.fini) } =0
.rodata : { *(.rodata) *(.rodata.*) *(.gnu.linkonce.r*) }
.rodata1 : { *(.rodata1) }
/* Adjust the address for the data segment. We want to adjust up to
the same address within the page on the next page up. */
. = ALIGN(0x40000) + (. & (0x40000 - 1)); /* Can conditionally be changed to . = .; */
.data :
{
PROVIDE(_fdata = .);
*(.data)
*(.gnu.linkonce.d*)
CONSTRUCTORS
}
.data1 : { *(.data1) }
.ctors :
{
*(.ctors)
}
.dtors :
{
*(.dtors)
}
PROVIDE(_gp = ALIGN(16) + 0x7ff0);
.got : { *(.got.plt) *(.got) }
.dynamic : { *(.dynamic) }
/* We want the small data sections together, so single-instruction offsets
can access them all, and initialized data all before uninitialized, so
we can shorten the on-disk segment size. */
.sdata : { *(.sdata) }
.lit8 : { *(.lit8) }
.lit4 : { *(.lit4) }
PROVIDE(_edata = .);
PROVIDE (edata = .);
__bss_start = .;
PROVIDE(_fbss = .);
.sbss : { *(.sbss) *(.scommon) }
.bss :
{
*(.dynbss)
*(.bss)
*(COMMON)
}
. = ALIGN(32 / 8);
PROVIDE(_end = .);
PROVIDE (end = .);
/* Stabs debugging sections. */
.stab 0 : { *(.stab) }
.stabstr 0 : { *(.stabstr) }
.stab.excl 0 : { *(.stab.excl) }
.stab.exclstr 0 : { *(.stab.exclstr) }
.stab.index 0 : { *(.stab.index) }
.stab.indexstr 0 : { *(.stab.indexstr) }
.comment 0 : { *(.comment) }
/* DWARF debug sections.
Symbols in the DWARF debugging sections are relative to the beginning
of the section so we begin them at 0. */
/* DWARF 1 */
.debug 0 : { *(.debug) }
.line 0 : { *(.line) }
/* GNU DWARF 1 extensions */
.debug_srcinfo 0 : { *(.debug_srcinfo) }
.debug_sfnames 0 : { *(.debug_sfnames) }
/* DWARF 1.1 and DWARF 2 */
.debug_aranges 0 : { *(.debug_aranges) }
.debug_pubnames 0 : { *(.debug_pubnames) }
/* DWARF 2 */
.debug_info 0 : { *(.debug_info) }
.debug_abbrev 0 : { *(.debug_abbrev) }
.debug_line 0 : { *(.debug_line) }
.debug_frame 0 : { *(.debug_frame) }
.debug_str 0 : { *(.debug_str) }
.debug_loc 0 : { *(.debug_loc) }
.debug_macinfo 0 : { *(.debug_macinfo) }
/* SGI/MIPS DWARF 2 extensions */
.debug_weaknames 0 : { *(.debug_weaknames) }
.debug_funcnames 0 : { *(.debug_funcnames) }
.debug_typenames 0 : { *(.debug_typenames) }
.debug_varnames 0 : { *(.debug_varnames) }
/* These must appear regardless of . */
.gptab.sdata : { *(.gptab.data) *(.gptab.sdata) }
.gptab.sbss : { *(.gptab.bss) *(.gptab.sbss) }
/*
* These are the stuff that we don't want to be put in an IRX.
*/
/DISCARD/ : {
* ( .MIPS.abiflags )
}
}
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
4 changes: 2 additions & 2 deletions samples/ps2dev_iop.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ endif()
SET(CMAKE_SYSTEM_NAME Generic)
SET(CMAKE_SYSTEM_VERSION 1)
SET(CMAKE_SYSTEM_PROCESSOR mips)
SET(CMAKE_C_COMPILER mipsel-ps2-irx-gcc)
SET(CMAKE_CXX_COMPILER mipsel-ps2-irx-g++)
SET(CMAKE_C_COMPILER mipsel-none-elf-gcc)
SET(CMAKE_CXX_COMPILER mipsel-none-elf-g++)
SET(CMAKE_C_COMPILER_WORKS 1) #Hack by f0bes
SET(CMAKE_CXX_COMPILER_WORKS 1) #Hack by f0bes

Expand Down
Loading
Loading