From 5c7f3b06b3c04b461c93f8bc03fd7981b041bbd6 Mon Sep 17 00:00:00 2001 From: mrb0nk500 Date: Mon, 30 Jan 2023 11:22:41 -0400 Subject: Makefile: Add `TEST_LD` env var for testing out linking --- Makefile | 7 ++++++- src/Dolphin/os/__start.c | 11 +++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 9278985..c5019b6 100644 --- a/Makefile +++ b/Makefile @@ -25,12 +25,17 @@ LD := $(WINE) tools/mwcc_compiler/$(MWCC_VERSION)/mwldeppc.exe INCLUDES := -i include/ ASM_INCLUDES := -I include/ +ifdef LD_TEST +TEST_LD := -DLD_TEST +else +TEST_LD := +endif LDFLAGS := -fp hard -nodefaults ASFLAGS := -mgekko $(ASM_INCLUDES) -CFLAGS := -nodefaults -proc gekko -fp hard -O4 -use_lmw_stmw on -str reuse -RTTI off -rostr -sdata2 4 $(INCLUDES) +CFLAGS := -nodefaults -proc gekko -fp hard -O4 -use_lmw_stmw on -str reuse -RTTI off -rostr -sdata2 4 -g $(INCLUDES) $(TEST_LD) include obj_files.mk diff --git a/src/Dolphin/os/__start.c b/src/Dolphin/os/__start.c index cebb086..4cb44e2 100644 --- a/src/Dolphin/os/__start.c +++ b/src/Dolphin/os/__start.c @@ -12,6 +12,7 @@ void __check_pad3(void) return; } +#ifndef LD_TEST // clang-format off __declspec (weak) asm void __start(void) @@ -116,6 +117,16 @@ _skip_crc: bl main b exit } +#else +__declspec(weak) void __start() { + int ret; + int argc = 0; + char **argv = NULL; + __init_user(); + ret = main(argc, argv); + exit(ret); +} +#endif asm static void __init_registers(void) { -- cgit v1.2.3-13-gbd6f