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 common/sbus/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ IOP_INCS += \

IOP_OBJS_DIR = iop_obj/

IOP_OBJS = ps2_sbus.o iop_sbus.o ps2_sif.o iop_sif2.o sif2cmd.o imports.o exports.o
IOP_OBJS = exports.o iop_sbus.o iop_sif2.o ps2_sbus.o ps2_sif.o sif2cmd.o imports.o

include $(PS2SDKSRC)/Defs.make
include $(PS2SDKSRC)/ee/Rules.lib.make
Expand Down
9 changes: 8 additions & 1 deletion iop/Rules.make
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,15 @@ $(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 $@ $<

# If the module has no export table, allow symbols at .text offset 0.
# The jal 0x0 hazard only matters when an export table can dispatch to offset 0.
IOP_SRXFIXUP_FLAGS := --rb --irx1
ifeq ($(filter %exports.o,$(IOP_OBJS)),)
IOP_SRXFIXUP_FLAGS += --allow-zero-text
endif

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

$(IOP_LIB)_tmp$(MAKE_CURPID): $(IOP_OBJS)
$(DIR_GUARD)
Expand Down
4 changes: 2 additions & 2 deletions iop/arcade/acatad/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ IOP_IMPORT_INCS += \
system/threadman

IOP_OBJS = \
exports.o \
acatad.o \
imports.o \
exports.o
imports.o

include $(PS2SDKSRC)/Defs.make
include $(PS2SDKSRC)/iop/Rules.bin.make
Expand Down
4 changes: 2 additions & 2 deletions iop/arcade/accdvd/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ IOP_IMPORT_INCS += \
system/threadman

IOP_OBJS = \
exports.o \
accdvdi-entry.o \
acd.o \
cdc.o \
cdi.o \
cddrv.o \
cdfs.o \
imports.o \
exports.o
imports.o

include $(PS2SDKSRC)/Defs.make
include $(PS2SDKSRC)/iop/Rules.bin.make
Expand Down
4 changes: 2 additions & 2 deletions iop/arcade/acdev/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ IOP_IMPORT_INCS += \
system/sysmem

IOP_OBJS = \
exports.o \
acdev.o \
imports.o \
exports.o
imports.o

include $(PS2SDKSRC)/Defs.make
include $(PS2SDKSRC)/iop/Rules.bin.make
Expand Down
4 changes: 2 additions & 2 deletions iop/arcade/acdev9/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ IOP_IMPORT_INCS += \
system/stdio

IOP_OBJS = \
exports.o \
acdev9.o \
imports.o \
exports.o
imports.o

include $(PS2SDKSRC)/Defs.make
include $(PS2SDKSRC)/iop/Rules.bin.make
Expand Down
2 changes: 1 addition & 1 deletion iop/cdvd/cdvdfsv/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ IOP_IMPORT_INCS += \
system/sysmem \
system/threadman

IOP_OBJS = cdvdfsv.o imports.o exports.o
IOP_OBJS = exports.o cdvdfsv.o imports.o

include $(PS2SDKSRC)/Defs.make
include $(PS2SDKSRC)/iop/Rules.bin.make
Expand Down
2 changes: 1 addition & 1 deletion iop/cdvd/cdvdman/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ IOP_IMPORT_INCS += \
system/sysmem \
system/threadman

IOP_OBJS = cdvdman.o imports.o exports.o
IOP_OBJS = exports.o cdvdman.o imports.o

include $(PS2SDKSRC)/Defs.make
include $(PS2SDKSRC)/iop/Rules.bin.make
Expand Down
2 changes: 1 addition & 1 deletion iop/cdvd/cdvdstm/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ IOP_IMPORT_INCS += \
system/sysmem \
system/threadman

IOP_OBJS = cdvdstm.o imports.o exports.o
IOP_OBJS = exports.o cdvdstm.o imports.o

include $(PS2SDKSRC)/Defs.make
include $(PS2SDKSRC)/iop/Rules.bin.make
Expand Down
2 changes: 1 addition & 1 deletion iop/debug/ioptrap/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ IOP_IMPORT_INCS += \
system/sysclib \
system/threadman

IOP_OBJS = ioptrap.o handler.o breakpoint.o exports.o imports.o
IOP_OBJS = exports.o ioptrap.o handler.o breakpoint.o imports.o

include $(PS2SDKSRC)/Defs.make
include $(PS2SDKSRC)/iop/Rules.bin.make
Expand Down
2 changes: 1 addition & 1 deletion iop/debug/sior/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ IOP_IMPORT_INCS += \
system/sysclib \
system/threadman

IOP_OBJS = sior.o xprintf.o exports.o imports.o
IOP_OBJS = exports.o sior.o xprintf.o imports.o

include $(PS2SDKSRC)/Defs.make
include $(PS2SDKSRC)/iop/Rules.bin.make
Expand Down
2 changes: 1 addition & 1 deletion iop/dev9/pvrdrv/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ IOP_IMPORT_INCS += \
system/sysmem \
system/threadman

IOP_OBJS = dvrdrv.o exports.o imports.o
IOP_OBJS = exports.o dvrdrv.o imports.o

include $(PS2SDKSRC)/Defs.make
include $(PS2SDKSRC)/iop/Rules.bin.make
Expand Down
2 changes: 1 addition & 1 deletion iop/fs/devfs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ IOP_IMPORT_INCS += \
system/sysmem \
system/threadman

IOP_OBJS = devfs.o exports.o imports.o
IOP_OBJS = exports.o devfs.o imports.o

include $(PS2SDKSRC)/Defs.make
include $(PS2SDKSRC)/iop/Rules.bin.make
Expand Down
4 changes: 2 additions & 2 deletions iop/fs/romdrv/src/exports.tab
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
void _retonly(void) {}

DECLARE_EXPORT_TABLE(romdrv, 2, 1)
DECLARE_EXPORT(_start)
DECLARE_EXPORT(_retonly)
Expand All @@ -21,3 +19,5 @@ DECLARE_EXPORT_TABLE(romdrvX, 1, 1)
DECLARE_EXPORT(romGetDevice)
END_EXPORT_TABLE
#endif

void _retonly(void) {}
4 changes: 2 additions & 2 deletions iop/memorycard/mcman/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@ IOP_IMPORT_INCS += \
system/timrman

IOP_OBJS = \
exports.o \
main.o \
mcdev.o \
mciomanx_backing.o \
mcsio2.o \
ps2mc_fio.o \
ps1mc_fio.o \
imports.o \
exports.o
imports.o

ifneq (x$(MCMAN_BUILDING_XMCMAN),x0)
IOP_CFLAGS += -DBUILDING_XMCMAN
Expand Down
2 changes: 1 addition & 1 deletion iop/memorycard/mcserv/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ IOP_IMPORT_INCS += \
system/sysclib \
system/threadman

IOP_OBJS = mcserv.o imports.o exports.o
IOP_OBJS = exports.o mcserv.o imports.o

ifneq (x$(MCMAN_BUILDING_XMCSERV),x0)
IOP_CFLAGS += -DBUILDING_XMCSERV
Expand Down
4 changes: 2 additions & 2 deletions iop/network/netman/src/exports.tab
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
void _retonly(){};

DECLARE_EXPORT_TABLE(netman, 3, 1)
DECLARE_EXPORT(_start)
DECLARE_EXPORT(_retonly)
Expand All @@ -23,3 +21,5 @@ DECLARE_EXPORT_TABLE(netman, 3, 1)
DECLARE_EXPORT(NetManTxPacketNext)
DECLARE_EXPORT(NetManTxPacketDeQ)
END_EXPORT_TABLE

void _retonly(){};
3 changes: 3 additions & 0 deletions iop/network/smap-none/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,7 @@ IOP_INC_DIR = $(PS2SDKSRC)/iop/network/smap/include/
SMAP_NETMAN ?= 0
SMAP_PS2IP ?= 0

# No export table for this variant, exclude exports.o
IOP_OBJS = main.o smap.o xfer.o ipstack.o imports.o

include $(PS2SDKSRC)/iop/network/smap/Makefile
3 changes: 3 additions & 0 deletions iop/network/smap-ps2ip/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,7 @@ IOP_INC_DIR = $(PS2SDKSRC)/iop/network/smap/include/
SMAP_NETMAN ?= 0
SMAP_PS2IP ?= 1

# No export table for this variant, exclude exports.o
IOP_OBJS = main.o smap.o xfer.o ipstack.o imports.o

include $(PS2SDKSRC)/iop/network/smap/Makefile
2 changes: 1 addition & 1 deletion iop/network/smap/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ IOP_IMPORT_INCS += \
system/sysclib \
system/threadman

IOP_OBJS = ipstack.o main.o smap.o xfer.o imports.o exports.o
IOP_OBJS ?= exports.o main.o smap.o xfer.o ipstack.o imports.o

ifneq (x$(LWIP_DHCP),x0)
IOP_CFLAGS += -DLWIP_DHCP=1
Expand Down
5 changes: 2 additions & 3 deletions iop/network/smap/src/exports.tab
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@

void _retonly(){};

#ifdef BUILDING_SMAP_NETMAN
DECLARE_EXPORT_TABLE(smap, 1, 1)
DECLARE_EXPORT(_retonly)
Expand All @@ -19,3 +16,5 @@ DECLARE_EXPORT_TABLE(smapmodu, 1, 1)
DECLARE_EXPORT(SmapModularGetExportTable)
END_EXPORT_TABLE
#endif

void _retonly(){};
4 changes: 2 additions & 2 deletions iop/network/udptty/src/exports.tab
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
void _retonly(void) {}

DECLARE_EXPORT_TABLE(udptty, 1, 1)
DECLARE_EXPORT(_start)
DECLARE_EXPORT(_retonly)
DECLARE_EXPORT(_shutdown)
DECLARE_EXPORT(_retonly)
DECLARE_EXPORT(_retonly)
END_EXPORT_TABLE

void _retonly(void) {}
2 changes: 1 addition & 1 deletion iop/sound/libsd/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ IOP_IMPORT_INCS += \
system/stdio \
system/sysclib

IOP_OBJS = freesd.o batch.o block.o effect.o voice.o exports.o imports.o
IOP_OBJS = exports.o freesd.o batch.o block.o effect.o voice.o imports.o

include $(PS2SDKSRC)/Defs.make
include $(PS2SDKSRC)/iop/Rules.bin.make
Expand Down
2 changes: 1 addition & 1 deletion iop/system/dmacman/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ IOP_IMPORT_INCS += \
system/loadcore \
system/sysmem

IOP_OBJS = dmacman.o exports.o imports.o
IOP_OBJS = exports.o dmacman.o imports.o

include $(PS2SDKSRC)/Defs.make
include $(PS2SDKSRC)/iop/Rules.bin.make
Expand Down
2 changes: 1 addition & 1 deletion iop/system/intrman/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ IOP_IMPORT_INCS += \
system/excepman \
system/loadcore

IOP_OBJS = intrman.o exports.o imports.o
IOP_OBJS = exports.o intrman.o imports.o

ifneq (x$(INTRMAN_PS1),x0)
IOP_CFLAGS += -DBUILDING_INTRMANP
Expand Down
2 changes: 1 addition & 1 deletion iop/system/mtapman/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ IOP_IMPORT_INCS += \
system/stdio \
system/threadman

IOP_OBJS = freemtap.o rpcservers.o exports.o imports.o
IOP_OBJS = exports.o freemtap.o rpcservers.o imports.o

include $(PS2SDKSRC)/Defs.make
include $(PS2SDKSRC)/iop/Rules.bin.make
Expand Down
2 changes: 1 addition & 1 deletion iop/system/siftoo/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ IOP_IMPORT_INCS += \
system/sifman \
system/stdio

IOP_OBJS = siftoo.o pipe.o exports.o imports.o
IOP_OBJS = exports.o siftoo.o pipe.o imports.o

include $(PS2SDKSRC)/Defs.make
include $(PS2SDKSRC)/iop/Rules.bin.make
Expand Down
2 changes: 1 addition & 1 deletion iop/system/stdio/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ IOP_IMPORT_INCS += \
system/loadcore \
system/sysclib

IOP_OBJS = stdio.o exports.o imports.o
IOP_OBJS = exports.o stdio.o imports.o

include $(PS2SDKSRC)/Defs.make
include $(PS2SDKSRC)/iop/Rules.bin.make
Expand Down
2 changes: 1 addition & 1 deletion iop/system/timrman/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ IOP_IMPORT_INCS += \
system/intrman \
system/loadcore

IOP_OBJS = timrman.o imports.o exports.o
IOP_OBJS = exports.o timrman.o imports.o

ifneq (x$(TIMRMAN_PS1),x0)
IOP_CFLAGS += -DBUILDING_TIMRMANP
Expand Down
4 changes: 2 additions & 2 deletions iop/tcpip/tcpip-netman/src/exports.tab
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
void _retonly(void){}

DECLARE_EXPORT_TABLE(ps2ip, 2, 6)
DECLARE_EXPORT(_start)
DECLARE_EXPORT(_retonly)
Expand Down Expand Up @@ -70,3 +68,5 @@ DECLARE_EXPORT_TABLE(ps2ip, 2, 6)
DECLARE_EXPORT(tcpip_callback_with_block)
DECLARE_EXPORT(pbuf_coalesce)
END_EXPORT_TABLE

void _retonly(void) {}
2 changes: 1 addition & 1 deletion iop/tcpip/tcpip/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ ifdef PS2IP_DNS
ps2ip_OBJECTS += dns.o netdb.o
endif

IOP_OBJS = ps2ip.o sys_arch.o exports.o imports.o $(ps2ip_OBJECTS)
IOP_OBJS = exports.o ps2ip.o sys_arch.o imports.o $(ps2ip_OBJECTS)

include $(PS2SDKSRC)/Defs.make
include $(PS2SDKSRC)/iop/Rules.bin.make
Expand Down
4 changes: 2 additions & 2 deletions iop/tcpip/tcpip/src/exports.tab
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
void _retonly(void){}

DECLARE_EXPORT_TABLE(ps2ip, 2, 6)
DECLARE_EXPORT(_start)
DECLARE_EXPORT(_retonly)
Expand Down Expand Up @@ -70,3 +68,5 @@ DECLARE_EXPORT_TABLE(ps2ip, 2, 6)
DECLARE_EXPORT(tcpip_callback_with_block)
DECLARE_EXPORT(pbuf_coalesce)
END_EXPORT_TABLE

void _retonly(void) {}
28 changes: 28 additions & 0 deletions tools/srxfixup/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,31 @@ This tool provides the following:

To see usage and possible command line arguments that can be used with the
program, run it without arguments.

## Zero-.text symbol check

When processing a relocatable ELF (`ET_REL`), `srxfixup` checks for function
or no-type symbols in the `.text` section whose `st_value` is exactly 0. Such
symbols indicate that real code was placed first in `.text` by the linker.
If an IOP export table has a zeroed or uninitialized entry, the dispatcher
will issue a `jal 0x0` — silently jumping into whatever function sits at
`.text` offset 0 instead of faulting. The symbols `_start` and `_ftext` are
excluded because they are entry points / linker labels that are never
dispatched through an export table.

If any offending symbol is found, `srxfixup` prints an error like:

```
ERROR: foo.irx: symbol 'bar' (sym#3) is in .text with value 0 -- if this module has an export table, put exports.o first in IOP_OBJS and move _retonly after DECLARE_EXPORT_TABLE in exports.tab; otherwise use --allow-zero-text.
```

and exits with a non-zero status so the build fails.

For modules **with** an export table, the fix is to ensure `exports.o` is
first in `IOP_OBJS` and that the `_retonly` definition appears after
`DECLARE_EXPORT_TABLE` in `exports.tab`. This places the export-table struct
(`STT_OBJECT`) at `.text` offset 0 instead of function code.

For modules **without** an export table, the `jal 0x0` hazard does not apply.
Use `--allow-zero-text` to suppress the check. The IOP `Rules.make`
automatically passes this flag when `exports.o` is not present in `IOP_OBJS`.
Loading