summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile23
-rw-r--r--linker_scripts/makerom.ld13
-rw-r--r--src/makerom/entry.s39
-rw-r--r--src/makerom/rom_header.s9
4 files changed, 70 insertions, 14 deletions
diff --git a/Makefile b/Makefile
index d5acb6325..357fe7e53 100644
--- a/Makefile
+++ b/Makefile
@@ -281,8 +281,10 @@ ifeq ($(ORIG_COMPILER),1)
CCAS := $(CC)
endif
+# EGCS Compiler
EGCS_PREFIX := tools/egcs/$(DETECTED_OS)/
EGCS_CC := $(EGCS_PREFIX)gcc -B $(EGCS_PREFIX)
+EGCS_CCAS := $(EGCS_CC) -x assembler-with-cpp
AS := $(MIPS_BINUTILS_PREFIX)as
LD := $(MIPS_BINUTILS_PREFIX)ld
@@ -368,6 +370,9 @@ else
CCASFLAGS += $(CPP_DEFINES) $(GBI_DEFINES) -G 0 -non_shared -fullwarn -verbose -Xcpluscomm $(INC) -Wab,-r4300_mul -woff 516,609,649,838,712,807 -o32
EGCS_CFLAGS += $(CPP_DEFINES) $(GBI_DEFINES) -G 0 -nostdinc $(INC) -mcpu=vr4300 -mabi=32 -mgp32 -mfp32 -fno-PIC
MIPS_VERSION := -mips2
+
+ EGCS_CCASFLAGS := -Wall -nostdinc $(CPP_DEFINES) $(INC) -c -G 0 -Wa,-irix-symtab -D_ABIO32=1 -D_ABI64=3 -D_MIPS_SIM_ABI64=_ABI64 -D_MIPS_SIM_ABI32=_ABIO32 -DMIPSEB -D_LANGUAGE_ASSEMBLY -fno-PIC -non_shared -mcpu=4300 -mfix4300
+ EGCS_ASOPTFLAGS :=
endif
ifeq ($(COMPILER),ido)
@@ -516,7 +521,8 @@ TEXTURE_FILES_OUT := $(foreach f,$(TEXTURE_FILES_PNG_EXTRACTED:.png=.inc.c),$(f:
# create build directories
$(shell mkdir -p $(BUILD_DIR)/baserom \
- $(BUILD_DIR)/assets/text)
+ $(BUILD_DIR)/assets/text \
+ $(BUILD_DIR)/linker_scripts)
$(shell mkdir -p $(foreach dir, \
$(SRC_DIRS) \
$(UNDECOMPILED_DATA_DIRS) \
@@ -681,6 +687,14 @@ endif
$(BUILD_DIR)/assets/misc/z_select_static/%.o: GBI_DEFINES := -DF3DEX_GBI
+ifeq ($(PLATFORM),IQUE)
+
+$(BUILD_DIR)/src/makerom/%.o: CCAS := $(EGCS_CCAS)
+$(BUILD_DIR)/src/makerom/%.o: CCASFLAGS := $(EGCS_CCASFLAGS)
+$(BUILD_DIR)/src/makerom/%.o: ASOPTFLAGS := $(EGCS_ASOPTFLAGS)
+
+endif
+
# For using asm_processor on some files:
#$(BUILD_DIR)/.../%.o: CC := $(PYTHON) tools/asm_processor/build.py $(CC) -- $(AS) $(ASFLAGS) --
@@ -784,10 +798,13 @@ $(ROMC): $(ROM) $(ELF) $(BUILD_DIR)/compress_ranges.txt
$(PYTHON) tools/compress.py --in $(ROM) --out $@ --dmadata-start `./tools/dmadata_start.sh $(NM) $(ELF)` --compress `cat $(BUILD_DIR)/compress_ranges.txt` --threads $(N_THREADS) $(COMPRESS_ARGS)
$(PYTHON) -m ipl3checksum sum --cic $(CIC) --update $@
-$(ELF): $(TEXTURE_FILES_OUT) $(ASSET_FILES_OUT) $(O_FILES) $(OVL_RELOC_FILES) $(LDSCRIPT) $(BUILD_DIR)/undefined_syms.txt \
+$(ELF): $(TEXTURE_FILES_OUT) $(ASSET_FILES_OUT) $(O_FILES) $(OVL_RELOC_FILES) $(LDSCRIPT) $(BUILD_DIR)/linker_scripts/makerom.ld $(BUILD_DIR)/undefined_syms.txt \
$(SAMPLEBANK_O_FILES) $(SOUNDFONT_O_FILES) $(SEQUENCE_O_FILES) \
$(BUILD_DIR)/assets/audio/sequence_font_table.o $(BUILD_DIR)/assets/audio/audiobank_padding.o
- $(LD) -T $(LDSCRIPT) -T $(BUILD_DIR)/undefined_syms.txt --no-check-sections --accept-unknown-input-arch --emit-relocs -Map $(MAP) -o $@
+ $(LD) -T $(LDSCRIPT) -T $(BUILD_DIR)/linker_scripts/makerom.ld -T $(BUILD_DIR)/undefined_syms.txt --no-check-sections --accept-unknown-input-arch --emit-relocs -Map $(MAP) -o $@
+
+$(BUILD_DIR)/linker_scripts/makerom.ld: linker_scripts/makerom.ld
+ $(CPP) -I include $(CPPFLAGS) $< > $@
## Order-only prerequisites
# These ensure e.g. the O_FILES are built before the OVL_RELOC_FILES.
diff --git a/linker_scripts/makerom.ld b/linker_scripts/makerom.ld
new file mode 100644
index 000000000..a898c6b34
--- /dev/null
+++ b/linker_scripts/makerom.ld
@@ -0,0 +1,13 @@
+#include "boot.h"
+
+/* These are only here due to iQue entry.s using ori to load the lower halves of symbols
+ * rather than addiu, so the usual relocation operators %hi() and %lo() can't be used. */
+
+_bootSegmentBssStart_HI = _bootSegmentBssStart >> 16;
+
+_bootSegmentBssSize_HI = _bootSegmentBssSize >> 16;
+
+bootproc_HI = bootproc >> 16;
+
+BOOT_STACK_TOP = (sBootThreadStack + BOOT_STACK_SIZE);
+BOOT_STACK_TOP_HI = BOOT_STACK_TOP >> 16;
diff --git a/src/makerom/entry.s b/src/makerom/entry.s
index 0a1233d80..e6074357b 100644
--- a/src/makerom/entry.s
+++ b/src/makerom/entry.s
@@ -4,21 +4,38 @@
.text
-#if defined(__sgi) && !defined(AVOID_UB)
-/* IDO assembler workaround: The makerom tool in the N64 SDK was given the bss segment size as a const
+#if defined(NON_MATCHING) || defined(__sgi)
+/* Non-matching builds or IDO */
+#define PAD_TO 0x60
+#define LA(reg, sym) la reg, sym
+#define BOOT_STACK_TOP sBootThreadStack + BOOT_STACK_SIZE
+#else
+/* EGCS */
+#define PAD_TO 0x50
+#define LA(reg, sym) \
+ lui reg, %lo(sym##_HI); \
+ ori reg, %lo(sym)
+#endif
+
+#if !defined(AVOID_UB)
+/* Old assembler workarounds: The makerom tool in the N64 SDK was given the bss segment size as a const
* literal, and since this literal was < 0x10000 it was loaded in one instruction. We don't have access
* to the bss segment size until we link everything so we cannot do the same thing. Instead we must load
* only the lower 16 bits of the bss size for matching.
* When AVOID_UB is enabled, don't do this and instead load the full symbol value, otherwise not all of
* bss may be cleared. */
+#if defined(__sgi)
#define LOAD_BSS_SIZE(reg) li reg, %half(_bootSegmentBssSize)
#else
-#define LOAD_BSS_SIZE(reg) la reg, _bootSegmentBssSize
+#define LOAD_BSS_SIZE(reg) ori reg, zero, %lo(_bootSegmentBssSize)
+#endif
+#else
+#define LOAD_BSS_SIZE(reg) LA(reg, _bootSegmentBssSize)
#endif
LEAF(entrypoint)
/* Clear boot segment .bss */
- la t0, _bootSegmentBssStart
+ LA( t0, _bootSegmentBssStart)
LOAD_BSS_SIZE(t1)
.clear_bss:
sw zero, 0(t0)
@@ -28,17 +45,17 @@ LEAF(entrypoint)
bnez t1, .clear_bss
/* Set up stack and enter program code */
- la sp, sBootThreadStack + BOOT_STACK_SIZE
- la t2, bootproc
+ LA( sp, BOOT_STACK_TOP)
+ LA( t2, bootproc)
jr t2
END(entrypoint)
-#ifdef __GNUC__
-/* Pad to a total size of 0x60 */
-.fill 0x60 - (. - entrypoint)
-#else
-/* IDO can't take absolute differences of symbols.. */
+#ifdef __sgi
+/* IDO can't take absolute differences of symbols so the size of the above is hardcoded */
.repeat (0x60 - 0x34)
.byte 0
.endr
+#else
+/* Pad to a total size taking into account the size of the above */
+.fill PAD_TO - (. - entrypoint)
#endif
diff --git a/src/makerom/rom_header.s b/src/makerom/rom_header.s
index d3d938cda..6b6fe8aa3 100644
--- a/src/makerom/rom_header.s
+++ b/src/makerom/rom_header.s
@@ -9,6 +9,9 @@
/* 0x08 */ ENTRYPOINT(0x80000400)
/* 0x0C */ OS_VERSION(2, 0, LIBULTRA_VERSION)
/* 0x10 */ CHECKSUM()
+
+#if !PLATFORM_IQUE
+
/* 0x18 */ PADDING(8)
/* 0x20 */ ROM_NAME("THE LEGEND OF ZELDA")
/* 0x34 */ PADDING(7)
@@ -26,3 +29,9 @@
/* 0x3E */ REGION(PAL)
#endif
/* 0x3F */ GAME_REVISION(OOT_REVISION)
+
+#else
+
+ .fill 0x40 - 0x18
+
+#endif