From eedbea45274e7fa353fad7e8296374441619781b Mon Sep 17 00:00:00 2001 From: aliaspider Date: Wed, 23 Nov 2016 00:06:35 +0100 Subject: [PATCH] (WiiU) build RPX imports from imports.h. --- Makefile.wiiu | 5 ++-- wiiu/system/dynamic.c | 6 ++--- wiiu/system/imports.h | 14 +++++------ wiiu/system/stubs_elf.S | 2 +- wiiu/system/stubs_rpl.S | 53 +++++++++++++++++++++++++++++++++++++++++ 5 files changed, 67 insertions(+), 13 deletions(-) create mode 100644 wiiu/system/stubs_rpl.S diff --git a/Makefile.wiiu b/Makefile.wiiu index 753ade52b9..1ee2552b4e 100644 --- a/Makefile.wiiu +++ b/Makefile.wiiu @@ -14,7 +14,9 @@ OBJ += wiiu/fs/sd_fat_devoptab.o OBJ += wiiu/fs/fs_utils.o OBJ += wiiu/tex_shader.o -ifneq ($(RPX_BUILD), 1) +ifeq ($(RPX_BUILD), 1) +OBJ += wiiu/system/stubs_rpl.o +else OBJ += wiiu/system/dynamic.o OBJ += wiiu/system/stubs_elf.o endif @@ -145,7 +147,6 @@ ifeq ($(RPX_BUILD), 1) LIBDIRS += -L$(WUT_ROOT)/lib -L$(DEVKITPPC)/lib LDFLAGS += -pie -fPIE LDFLAGS += -z common-page-size=64 -z max-page-size=64 - LDFLAGS += -lcoreinit -lgx2 -lnsysnet -lproc_ui -lsndcore2 -lsysapp -lvpad LDFLAGS += -T $(WUT_ROOT)/rules/rpl.ld # LDFLAGS += -T wiiu/link_rpl.ld LDFLAGS += -nostartfiles diff --git a/wiiu/system/dynamic.c b/wiiu/system/dynamic.c index 8b929071d4..d70e16a53d 100644 --- a/wiiu/system/dynamic.c +++ b/wiiu/system/dynamic.c @@ -3,7 +3,7 @@ #define IMPORT(name) void* addr_##name #define IMPORT_BEGIN(lib) -#define IMPORT_END() +#define IMPORT_END(lib) #include "imports.h" #undef IMPORT @@ -12,8 +12,8 @@ #define IMPORT(name) do{if(OSDynLoad_FindExport(handle, 0, #name, &addr_##name) < 0)OSFatal("Function " # name " is NULL");} while(0) #define IMPORT_BEGIN(lib) OSDynLoad_Acquire(#lib ".rpl", &handle) -//#define IMPORT_END() OSDynLoad_Release(handle) -#define IMPORT_END() +//#define IMPORT_END(lib) OSDynLoad_Release(handle) +#define IMPORT_END(lib) void InitFunctionPointers(void) { diff --git a/wiiu/system/imports.h b/wiiu/system/imports.h index e660fe2f86..a8c92081cc 100644 --- a/wiiu/system/imports.h +++ b/wiiu/system/imports.h @@ -63,7 +63,7 @@ IMPORT(FSGetMountSource); IMPORT(FSMount); IMPORT(FSUnmount); -IMPORT_END(); +IMPORT_END(coreinit); /* nsysnet */ IMPORT_BEGIN(nsysnet); @@ -75,7 +75,7 @@ IMPORT(connect); IMPORT(send); IMPORT(inet_aton); -IMPORT_END(); +IMPORT_END(nsysnet); /* gx2 */ IMPORT_BEGIN(gx2); @@ -122,7 +122,7 @@ IMPORT(GX2DrawEx); IMPORT(GX2WaitForFlip); IMPORT(GX2GetSwapStatus); -IMPORT_END(); +IMPORT_END(gx2); /* proc_ui */ IMPORT_BEGIN(proc_ui); @@ -130,7 +130,7 @@ IMPORT_BEGIN(proc_ui); IMPORT(ProcUIInit); IMPORT(ProcUIShutdown); -IMPORT_END(); +IMPORT_END(proc_ui); /* sndcore2 */ IMPORT_BEGIN(sndcore2); @@ -148,14 +148,14 @@ IMPORT(AXSetMultiVoiceSrcRatio); IMPORT(AXIsMultiVoiceRunning); IMPORT(AXFreeMultiVoice); -IMPORT_END(); +IMPORT_END(sndcore2); /* sysapp */ IMPORT_BEGIN(sysapp); IMPORT(SYSRelaunchTitle); -IMPORT_END(); +IMPORT_END(sysapp); /* vpad */ IMPORT_BEGIN(vpad); @@ -163,4 +163,4 @@ IMPORT_BEGIN(vpad); IMPORT(VPADRead); IMPORT(VPADInit); -IMPORT_END(); +IMPORT_END(vpad); diff --git a/wiiu/system/stubs_elf.S b/wiiu/system/stubs_elf.S index 2fb57eb6b1..8762650678 100644 --- a/wiiu/system/stubs_elf.S +++ b/wiiu/system/stubs_elf.S @@ -16,7 +16,7 @@ bctr #define IMPORT_BEGIN(lib) -#define IMPORT_END() +#define IMPORT_END(lib) .align 2; .section ".text"; diff --git a/wiiu/system/stubs_rpl.S b/wiiu/system/stubs_rpl.S new file mode 100644 index 0000000000..a2c25a8b49 --- /dev/null +++ b/wiiu/system/stubs_rpl.S @@ -0,0 +1,53 @@ + +/*#define IMPORT_BEGIN(lib) .align 2; .section .fimport_##lib,"ax";*/ +#define IMPORT_BEGIN(lib) + +/*#define IMPORT(name) \ + .global name; \ + name: \ + nop; \ + nop*/ + + +#define IMPORT(name) \ +.align 2; \ +.section ".rplTramp.text","ax"; \ + .global name; \ + name: \ + lis %r0, name##_stub@h; \ + ori %r0, %r0, name##_stub@l; \ + mtctr %r0; \ + bctr; + +/*#define IMPORT_END() .align 2;*/ +#define IMPORT_END(lib) + +#include "imports.h" + + +#undef IMPORT_BEGIN +#undef IMPORT +#undef IMPORT_END + +#define IMPORT_BEGIN(lib) \ +.section ".data.rplFuncStubs"; \ +.align 2; \ + fstubBegin_##lib: + +#define IMPORT(name) \ + .global name##_stub; \ + name##_stub: \ + .long name; + +#define IMPORT_END(lib) \ + fstubEnd_##lib: \ +.section ".rodata.rplNames"; \ + lib##_name: \ + .string #lib; \ +.section ".lib.rplLibs"; \ + .align 2; \ + .long lib##_name; \ + .long fstubBegin_##lib; \ + .long fstubEnd_##lib + +#include "imports.h"