mirror of https://github.com/zeldaret/mm.git
GCC Compiler Support (#1791)
* GCC Compiler Support * Update mkldscript
This commit is contained in:
parent
89b7bb0d71
commit
84a89c8f46
65
Makefile
65
Makefile
|
@ -40,6 +40,8 @@ COMPARE ?= 1
|
||||||
NON_MATCHING ?= 0
|
NON_MATCHING ?= 0
|
||||||
# If ORIG_COMPILER is 1, compile with QEMU_IRIX and the original compiler
|
# If ORIG_COMPILER is 1, compile with QEMU_IRIX and the original compiler
|
||||||
ORIG_COMPILER ?= 0
|
ORIG_COMPILER ?= 0
|
||||||
|
# If COMPILER is "gcc", compile with GCC instead of IDO.
|
||||||
|
COMPILER ?= ido
|
||||||
# if WERROR is 1, pass -Werror to CC_CHECK, so warnings would be treated as errors
|
# if WERROR is 1, pass -Werror to CC_CHECK, so warnings would be treated as errors
|
||||||
WERROR ?= 0
|
WERROR ?= 0
|
||||||
# Keep .mdebug section in build
|
# Keep .mdebug section in build
|
||||||
|
@ -69,9 +71,18 @@ N64_EMULATOR ?=
|
||||||
# Ensure the map file being created using English localization
|
# Ensure the map file being created using English localization
|
||||||
export LANG := C
|
export LANG := C
|
||||||
|
|
||||||
|
CFLAGS :=
|
||||||
|
CPPFLAGS :=
|
||||||
|
|
||||||
|
ifeq ($(COMPILER),gcc)
|
||||||
|
CPPFLAGS += -DCOMPILER_GCC
|
||||||
|
NON_MATCHING := 1
|
||||||
|
RUN_CC_CHECK := 0
|
||||||
|
endif
|
||||||
|
|
||||||
ifneq ($(NON_MATCHING),0)
|
ifneq ($(NON_MATCHING),0)
|
||||||
CFLAGS := -DNON_MATCHING
|
CFLAGS += -DNON_MATCHING -DAVOID_UB
|
||||||
CPPFLAGS := -DNON_MATCHING
|
CPPFLAGS += -DNON_MATCHING -DAVOID_UB
|
||||||
COMPARE := 0
|
COMPARE := 0
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
@ -92,8 +103,15 @@ ifneq ($(shell type $(MIPS_BINUTILS_PREFIX)ld >/dev/null 2>/dev/null; echo $$?),
|
||||||
$(error Unable to find $(MIPS_BINUTILS_PREFIX)ld. Please install or build MIPS binutils, commonly mips-linux-gnu. (or set MIPS_BINUTILS_PREFIX if your MIPS binutils install uses another prefix))
|
$(error Unable to find $(MIPS_BINUTILS_PREFIX)ld. Please install or build MIPS binutils, commonly mips-linux-gnu. (or set MIPS_BINUTILS_PREFIX if your MIPS binutils install uses another prefix))
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
# Detect compiler and set variables appropriately.
|
||||||
|
ifeq ($(COMPILER),gcc)
|
||||||
|
CC := $(MIPS_BINUTILS_PREFIX)gcc
|
||||||
|
else ifeq ($(COMPILER),ido)
|
||||||
CC := tools/ido_recomp/$(DETECTED_OS)/7.1/cc
|
CC := tools/ido_recomp/$(DETECTED_OS)/7.1/cc
|
||||||
CC_OLD := tools/ido_recomp/$(DETECTED_OS)/5.3/cc
|
CC_OLD := tools/ido_recomp/$(DETECTED_OS)/5.3/cc
|
||||||
|
else
|
||||||
|
$(error Unsupported compiler. Please use either ido or gcc as the COMPILER variable.)
|
||||||
|
endif
|
||||||
|
|
||||||
# if ORIG_COMPILER is 1, check that either QEMU_IRIX is set or qemu-irix package installed
|
# if ORIG_COMPILER is 1, check that either QEMU_IRIX is set or qemu-irix package installed
|
||||||
ifeq ($(ORIG_COMPILER),1)
|
ifeq ($(ORIG_COMPILER),1)
|
||||||
|
@ -177,18 +195,36 @@ SFCFLAGS := --matching
|
||||||
# We can't use the C preprocessor for this because it won't substitute inside string literals.
|
# We can't use the C preprocessor for this because it won't substitute inside string literals.
|
||||||
BUILD_DIR_REPLACE := sed -e 's|$$(BUILD_DIR)|$(BUILD_DIR)|g'
|
BUILD_DIR_REPLACE := sed -e 's|$$(BUILD_DIR)|$(BUILD_DIR)|g'
|
||||||
|
|
||||||
|
GBI_DEFINES := -DF3DEX_GBI_2 -DF3DEX_GBI_PL -DGBI_DOWHILE
|
||||||
|
|
||||||
|
ifeq ($(COMPILER),gcc)
|
||||||
|
# MIPS options
|
||||||
|
CFLAGS += -G 0 -march=vr4300 -mtune=vr4300 -mfix4300 -mabi=32 -mno-abicalls -mdivide-breaks
|
||||||
|
# C dialect options
|
||||||
|
CFLAGS += -nostdinc -fno-PIC -fno-common -ffreestanding -fbuiltin -fno-builtin-sinf -fno-builtin-cosf -funsigned-char
|
||||||
|
|
||||||
|
WARNINGS := $(CC_CHECK_WARNINGS)
|
||||||
|
ASFLAGS := -march=vr4300 -32 -G0
|
||||||
|
COMMON_DEFINES := $(GBI_DEFINES)
|
||||||
|
AS_DEFINES := $(COMMON_DEFINES) -DMIPSEB -D_LANGUAGE_ASSEMBLY -D_ULTRA64
|
||||||
|
C_DEFINES := $(COMMON_DEFINES) -D_LANGUAGE_C
|
||||||
|
ENDIAN :=
|
||||||
|
|
||||||
|
OPTFLAGS := -Os -ffast-math -ftrapping-math -fno-associative-math
|
||||||
|
MIPS_VERSION := -mips3
|
||||||
|
else
|
||||||
CFLAGS += -G 0 -non_shared -Xcpluscomm -nostdinc -Wab,-r4300_mul
|
CFLAGS += -G 0 -non_shared -Xcpluscomm -nostdinc -Wab,-r4300_mul
|
||||||
|
|
||||||
WARNINGS := -fullwarn -verbose -woff 624,649,838,712,516,513,596,564,594,807
|
WARNINGS := -fullwarn -verbose -woff 624,649,838,712,516,513,596,564,594,807
|
||||||
ASFLAGS := -march=vr4300 -32 -G0
|
ASFLAGS := -march=vr4300 -32 -G0
|
||||||
GBI_DEFINES := -DF3DEX_GBI_2 -DF3DEX_GBI_PL -DGBI_DOWHILE
|
|
||||||
COMMON_DEFINES := -D_MIPS_SZLONG=32 $(GBI_DEFINES)
|
COMMON_DEFINES := -D_MIPS_SZLONG=32 $(GBI_DEFINES)
|
||||||
AS_DEFINES := $(COMMON_DEFINES) -DMIPSEB -D_LANGUAGE_ASSEMBLY -D_ULTRA64
|
AS_DEFINES := $(COMMON_DEFINES) -DMIPSEB -D_LANGUAGE_ASSEMBLY -D_ULTRA64
|
||||||
C_DEFINES := $(COMMON_DEFINES) -DLANGUAGE_C -D_LANGUAGE_C
|
C_DEFINES := $(COMMON_DEFINES) -D_LANGUAGE_C
|
||||||
ENDIAN := -EB
|
ENDIAN := -EB
|
||||||
|
|
||||||
OPTFLAGS := -O2 -g3
|
OPTFLAGS := -O2 -g3
|
||||||
MIPS_VERSION := -mips2
|
MIPS_VERSION := -mips2
|
||||||
|
endif
|
||||||
|
|
||||||
# Use relocations and abi fpr names in the dump
|
# Use relocations and abi fpr names in the dump
|
||||||
OBJDUMP_FLAGS := --disassemble --reloc --disassemble-zeroes -Mreg-names=32
|
OBJDUMP_FLAGS := --disassemble --reloc --disassemble-zeroes -Mreg-names=32
|
||||||
|
@ -221,7 +257,12 @@ SPEC := spec
|
||||||
# create asm directories
|
# create asm directories
|
||||||
$(shell mkdir -p asm data extracted)
|
$(shell mkdir -p asm data extracted)
|
||||||
|
|
||||||
|
ifeq ($(COMPILER),ido)
|
||||||
|
SRC_DIRS := $(shell find src -type d -not -path src/gcc_fix)
|
||||||
|
else
|
||||||
SRC_DIRS := $(shell find src -type d)
|
SRC_DIRS := $(shell find src -type d)
|
||||||
|
endif
|
||||||
|
|
||||||
ASM_DIRS := $(shell find asm -type d -not -path "asm/non_matchings*") $(shell find data -type d)
|
ASM_DIRS := $(shell find asm -type d -not -path "asm/non_matchings*") $(shell find data -type d)
|
||||||
|
|
||||||
ifneq ($(wildcard $(EXTRACTED_DIR)/assets/audio),)
|
ifneq ($(wildcard $(EXTRACTED_DIR)/assets/audio),)
|
||||||
|
@ -369,6 +410,7 @@ $(shell mkdir -p $(foreach dir, \
|
||||||
$(dir:$(EXTRACTED_DIR)/%=$(BUILD_DIR)/%)))
|
$(dir:$(EXTRACTED_DIR)/%=$(BUILD_DIR)/%)))
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifeq ($(COMPILER),ido)
|
||||||
# directory flags
|
# directory flags
|
||||||
$(BUILD_DIR)/src/libultra/os/%.o: OPTFLAGS := -O1
|
$(BUILD_DIR)/src/libultra/os/%.o: OPTFLAGS := -O1
|
||||||
$(BUILD_DIR)/src/libultra/voice/%.o: OPTFLAGS := -O2
|
$(BUILD_DIR)/src/libultra/voice/%.o: OPTFLAGS := -O2
|
||||||
|
@ -417,7 +459,16 @@ $(BUILD_DIR)/src/audio/%.o: CC := $(ASM_PROC) $(ASM_PROC_FLAGS) $(CC) -- $(AS) $
|
||||||
$(BUILD_DIR)/src/overlays/%.o: CC := $(ASM_PROC) $(ASM_PROC_FLAGS) $(CC) -- $(AS) $(ASFLAGS) --
|
$(BUILD_DIR)/src/overlays/%.o: CC := $(ASM_PROC) $(ASM_PROC_FLAGS) $(CC) -- $(AS) $(ASFLAGS) --
|
||||||
|
|
||||||
$(BUILD_DIR)/assets/%.o: CC := $(ASM_PROC) $(ASM_PROC_FLAGS) $(CC) -- $(AS) $(ASFLAGS) --
|
$(BUILD_DIR)/assets/%.o: CC := $(ASM_PROC) $(ASM_PROC_FLAGS) $(CC) -- $(AS) $(ASFLAGS) --
|
||||||
|
else
|
||||||
|
# Note that if adding additional assets directories for modding reasons these flags must also be used there
|
||||||
|
$(BUILD_DIR)/assets/%.o: CFLAGS += -fno-zero-initialized-in-bss -fno-toplevel-reorder
|
||||||
|
$(BUILD_DIR)/src/%.o: CFLAGS += -fexec-charset=euc-jp
|
||||||
|
$(BUILD_DIR)/src/libultra/libc/ll.o: OPTFLAGS := -Ofast
|
||||||
|
$(BUILD_DIR)/src/overlays/%.o: CFLAGS += -fno-merge-constants -mno-explicit-relocs -mno-split-addresses
|
||||||
|
|
||||||
|
# Temporary: Hardcoded pointers in assets (specifically object_dmask and object_osn)
|
||||||
|
$(BUILD_DIR)/assets/%.o: WARNINGS += -Wno-error=int-conversion
|
||||||
|
endif
|
||||||
|
|
||||||
$(SHIFTJIS_O_FILES): CC_CHECK_WARNINGS += -Wno-multichar -Wno-type-limits -Wno-overflow
|
$(SHIFTJIS_O_FILES): CC_CHECK_WARNINGS += -Wno-multichar -Wno-type-limits -Wno-overflow
|
||||||
|
|
||||||
|
@ -551,9 +602,13 @@ $(BUILD_DIR)/%.o: %.s
|
||||||
$(CPP) $(CPPFLAGS) $(IINC) $< | $(AS) $(ASFLAGS) $(IINC) $(ENDIAN) -o $@
|
$(CPP) $(CPPFLAGS) $(IINC) $< | $(AS) $(ASFLAGS) $(IINC) $(ENDIAN) -o $@
|
||||||
|
|
||||||
$(BUILD_DIR)/assets/text/%.o: assets/text/%.c
|
$(BUILD_DIR)/assets/text/%.o: assets/text/%.c
|
||||||
|
ifneq ($(COMPILER),gcc)
|
||||||
# Preprocess text with modern cpp for varargs macros
|
# Preprocess text with modern cpp for varargs macros
|
||||||
$(CPP) -undef -D_LANGUAGE_C -D__sgi $(CPPFLAGS) $(IINC) $< -o $(@:.o=.c)
|
$(CPP) -undef -D_LANGUAGE_C -D__sgi $(CPPFLAGS) $(IINC) $< -o $(@:.o=.c)
|
||||||
$(CC) -c $(CFLAGS) $(WARNINGS) $(C_DEFINES) $(MIPS_VERSION) $(ENDIAN) $(OPTFLAGS) -o $@ $(@:.o=.c)
|
$(CC) -c $(CFLAGS) $(IINC) $(WARNINGS) $(C_DEFINES) $(MIPS_VERSION) $(ENDIAN) $(OPTFLAGS) -o $@ $(@:.o=.c)
|
||||||
|
else
|
||||||
|
$(CC) -c $(CFLAGS) $(IINC) $(WARNINGS) $(C_DEFINES) $(MIPS_VERSION) $(ENDIAN) $(OPTFLAGS) -o $@ $<
|
||||||
|
endif
|
||||||
|
|
||||||
$(BUILD_DIR)/assets/%.o: assets/%.c
|
$(BUILD_DIR)/assets/%.o: assets/%.c
|
||||||
$(CC) -c $(CFLAGS) $(IINC) $(WARNINGS) $(C_DEFINES) $(MIPS_VERSION) $(ENDIAN) $(OPTFLAGS) -o $@ $<
|
$(CC) -c $(CFLAGS) $(IINC) $(WARNINGS) $(C_DEFINES) $(MIPS_VERSION) $(ENDIAN) $(OPTFLAGS) -o $@ $<
|
||||||
|
|
3
spec
3
spec
|
@ -244,6 +244,9 @@ beginseg
|
||||||
include "$(BUILD_DIR)/src/boot/libc/strcpy.o"
|
include "$(BUILD_DIR)/src/boot/libc/strcpy.o"
|
||||||
include "$(BUILD_DIR)/src/boot/libc/memmove.o"
|
include "$(BUILD_DIR)/src/boot/libc/memmove.o"
|
||||||
include "$(BUILD_DIR)/src/boot/build.o"
|
include "$(BUILD_DIR)/src/boot/build.o"
|
||||||
|
#ifdef COMPILER_GCC
|
||||||
|
include "$(BUILD_DIR)/src/gcc_fix/missing_gcc_functions.o"
|
||||||
|
#endif
|
||||||
endseg
|
endseg
|
||||||
|
|
||||||
beginseg
|
beginseg
|
||||||
|
|
|
@ -0,0 +1,237 @@
|
||||||
|
/* --------------------------------------------------------------------------------*/
|
||||||
|
/* Depending on the toolchain used, an appropriate precompiled libgcc library */
|
||||||
|
/* may not exist and cannot be linked against. Until we have a better work around, */
|
||||||
|
/* necessary gcc functions are hosted here in order to properly compile. */
|
||||||
|
/* This file is NOT a part of the original game and only exists to help gcc work. */
|
||||||
|
/* --------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "global.h"
|
||||||
|
|
||||||
|
// Self-hosted libc memory functions, gcc assumes these exist even in a freestanding
|
||||||
|
// environment and there is no way to tell it otherwise.
|
||||||
|
|
||||||
|
int memcmp(const void* s1, const void* s2, size_t n) {
|
||||||
|
const u8* m1 = s1;
|
||||||
|
const u8* m2 = s2;
|
||||||
|
size_t i;
|
||||||
|
|
||||||
|
for (i = 0; i < n; i++) {
|
||||||
|
if (m1[i] < m2[i]) {
|
||||||
|
return -1;
|
||||||
|
} else if (m1[i] > m2[i]) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Conversions involving 64-bit integer types required by the O32 MIPS ABI.
|
||||||
|
|
||||||
|
// f32 -> u64, negative values become 0
|
||||||
|
u64 __fixunssfdi(f32 a) {
|
||||||
|
if (a > 0.0f) {
|
||||||
|
register union {
|
||||||
|
f64 f;
|
||||||
|
u64 i;
|
||||||
|
} m;
|
||||||
|
|
||||||
|
__asm__("cvt.l.s %0, %1" : "=f"(m.f) : "f"(a));
|
||||||
|
return m.i;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// f64 -> u64, negative values become 0
|
||||||
|
u64 __fixunsdfdi(f64 a) {
|
||||||
|
if (a > 0.0) {
|
||||||
|
register union {
|
||||||
|
f64 f;
|
||||||
|
u64 i;
|
||||||
|
} m;
|
||||||
|
|
||||||
|
__asm__("cvt.l.d %0, %1" : "=f"(m.f) : "f"(a));
|
||||||
|
return m.i;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// f32 -> s64
|
||||||
|
s64 __fixsfdi(f32 c) {
|
||||||
|
register union {
|
||||||
|
f64 f;
|
||||||
|
s64 i;
|
||||||
|
} m;
|
||||||
|
|
||||||
|
__asm__("cvt.l.s %0, %1" : "=f"(m.f) : "f"(c));
|
||||||
|
return m.i;
|
||||||
|
}
|
||||||
|
|
||||||
|
// f64 -> s64
|
||||||
|
s64 __fixdfdi(f64 c) {
|
||||||
|
register union {
|
||||||
|
f64 f;
|
||||||
|
s64 i;
|
||||||
|
} m;
|
||||||
|
|
||||||
|
__asm__("cvt.l.d %0, %1" : "=f"(m.f) : "f"(c));
|
||||||
|
return m.i;
|
||||||
|
}
|
||||||
|
|
||||||
|
// s64 -> f32
|
||||||
|
f32 __floatdisf(s64 c) {
|
||||||
|
register union {
|
||||||
|
f64 f;
|
||||||
|
s64 i;
|
||||||
|
} m;
|
||||||
|
register f32 v;
|
||||||
|
|
||||||
|
m.i = c;
|
||||||
|
__asm__("cvt.s.l %0, %1" : "=f"(v) : "f"(m.f));
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
|
||||||
|
// s64 -> f64
|
||||||
|
f64 __floatdidf(s64 c) {
|
||||||
|
register union {
|
||||||
|
f64 f;
|
||||||
|
s64 i;
|
||||||
|
} m;
|
||||||
|
register f64 v;
|
||||||
|
|
||||||
|
m.i = c;
|
||||||
|
__asm__("cvt.d.l %0, %1" : "=f"(v) : "f"(m.f));
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
|
||||||
|
// u64 -> f32
|
||||||
|
f32 __floatundisf(u64 c) {
|
||||||
|
register union {
|
||||||
|
f64 f;
|
||||||
|
u64 i;
|
||||||
|
} m;
|
||||||
|
register f32 v;
|
||||||
|
|
||||||
|
m.i = c;
|
||||||
|
__asm__("cvt.s.l %0, %1" : "=f"(v) : "f"(m.f));
|
||||||
|
if ((s64)c < 0) {
|
||||||
|
// cvt.s.l assumes signed input, adjust output
|
||||||
|
v += 4294967296.0f; // 2^32
|
||||||
|
}
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
|
||||||
|
// u64 -> f64
|
||||||
|
f64 __floatundidf(u64 c) {
|
||||||
|
register union {
|
||||||
|
f64 f;
|
||||||
|
u64 i;
|
||||||
|
} m;
|
||||||
|
register f64 v;
|
||||||
|
|
||||||
|
m.i = c;
|
||||||
|
__asm__("cvt.d.l %0, %1" : "=f"(v) : "f"(m.f));
|
||||||
|
if ((s64)c < 0) {
|
||||||
|
// cvt.d.l assumes signed input, adjust output
|
||||||
|
v += 18446744073709551616.0; // 2^64
|
||||||
|
}
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Compute x^m by binary exponentiation
|
||||||
|
|
||||||
|
f32 __powisf2(f32 x, s32 m) {
|
||||||
|
u32 n = (m < 0) ? -m : m;
|
||||||
|
f32 y = (n % 2 != 0) ? x : 1.0f;
|
||||||
|
|
||||||
|
while (n >>= 1) {
|
||||||
|
x = x * x;
|
||||||
|
|
||||||
|
if (n % 2 != 0) {
|
||||||
|
y = y * x;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return (m < 0) ? (1.0f / y) : y;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Compute division and modulo of 64-bit signed and unsigned integers
|
||||||
|
|
||||||
|
__asm__(" \n\
|
||||||
|
.set push \n\
|
||||||
|
.set noreorder \n\
|
||||||
|
.set gp=64 \n\
|
||||||
|
\n\
|
||||||
|
.global __umoddi3 \n\
|
||||||
|
__umoddi3: \n\
|
||||||
|
.type __umoddi3, @function \n\
|
||||||
|
.ent __umoddi3 \n\
|
||||||
|
sw $a0, 0x0($sp) \n\
|
||||||
|
sw $a1, 0x4($sp) \n\
|
||||||
|
sw $a2, 0x8($sp) \n\
|
||||||
|
sw $a3, 0xC($sp) \n\
|
||||||
|
ld $t6, 0($sp) \n\
|
||||||
|
ld $t7, 8($sp) \n\
|
||||||
|
dremu $v0, $t6, $t7 \n\
|
||||||
|
dsll32 $v1, $v0, 0 \n\
|
||||||
|
dsra32 $v1, $v1, 0 \n\
|
||||||
|
jr $ra \n\
|
||||||
|
dsra32 $v0, $v0, 0 \n\
|
||||||
|
.end __umoddi3 \n\
|
||||||
|
.size __umoddi3, . - __umoddi3 \n\
|
||||||
|
\n\
|
||||||
|
.global __udivdi3 \n\
|
||||||
|
__udivdi3: \n\
|
||||||
|
.type __udivdi3, @function \n\
|
||||||
|
.ent __udivdi3 \n\
|
||||||
|
sw $a0, 0x0($sp) \n\
|
||||||
|
sw $a1, 0x4($sp) \n\
|
||||||
|
sw $a2, 0x8($sp) \n\
|
||||||
|
sw $a3, 0xC($sp) \n\
|
||||||
|
ld $t6, 0($sp) \n\
|
||||||
|
ld $t7, 8($sp) \n\
|
||||||
|
ddivu $v0, $t6, $t7 \n\
|
||||||
|
dsll32 $v1, $v0, 0 \n\
|
||||||
|
dsra32 $v1, $v1, 0 \n\
|
||||||
|
jr $ra \n\
|
||||||
|
dsra32 $v0, $v0, 0 \n\
|
||||||
|
.end __udivdi3 \n\
|
||||||
|
.size __udivdi3, . - __udivdi3 \n\
|
||||||
|
\n\
|
||||||
|
.global __moddi3 \n\
|
||||||
|
__moddi3: \n\
|
||||||
|
.type __moddi3, @function \n\
|
||||||
|
.ent __moddi3 \n\
|
||||||
|
sw $a0, 0x0($sp) \n\
|
||||||
|
sw $a1, 0x4($sp) \n\
|
||||||
|
sw $a2, 0x8($sp) \n\
|
||||||
|
sw $a3, 0xC($sp) \n\
|
||||||
|
ld $t6, 0($sp) \n\
|
||||||
|
ld $t7, 8($sp) \n\
|
||||||
|
drem $v0, $t6, $t7 \n\
|
||||||
|
dsll32 $v1, $v0, 0 \n\
|
||||||
|
dsra32 $v1, $v1, 0 \n\
|
||||||
|
jr $ra \n\
|
||||||
|
dsra32 $v0, $v0, 0 \n\
|
||||||
|
.end __moddi3 \n\
|
||||||
|
.size __moddi3, . - __moddi3 \n\
|
||||||
|
\n\
|
||||||
|
.global __divdi3 \n\
|
||||||
|
__divdi3: \n\
|
||||||
|
.type __divdi3, @function \n\
|
||||||
|
.ent __divdi3 \n\
|
||||||
|
sw $a0, 0x0($sp) \n\
|
||||||
|
sw $a1, 0x4($sp) \n\
|
||||||
|
sw $a2, 0x8($sp) \n\
|
||||||
|
sw $a3, 0xC($sp) \n\
|
||||||
|
ld $t6, 0($sp) \n\
|
||||||
|
ld $t7, 8($sp) \n\
|
||||||
|
ddiv $v0, $t6, $t7 \n\
|
||||||
|
dsll32 $v1, $v0, 0 \n\
|
||||||
|
dsra32 $v1, $v1, 0 \n\
|
||||||
|
jr $ra \n\
|
||||||
|
dsra32 $v0, $v0, 0 \n\
|
||||||
|
.end __divdi3 \n\
|
||||||
|
.size __divdi3, . - __divdi3 \n\
|
||||||
|
\n\
|
||||||
|
.set pop \n\
|
||||||
|
\n");
|
|
@ -21,7 +21,8 @@
|
||||||
struct Segment *g_segments;
|
struct Segment *g_segments;
|
||||||
int g_segmentsCount;
|
int g_segmentsCount;
|
||||||
|
|
||||||
static void write_ld_script(FILE* fout) {
|
static void write_ld_script(FILE *fout)
|
||||||
|
{
|
||||||
int i;
|
int i;
|
||||||
int j;
|
int j;
|
||||||
|
|
||||||
|
@ -31,7 +32,8 @@ static void write_ld_script(FILE* fout) {
|
||||||
" _RomStart = _RomSize;\n\n",
|
" _RomStart = _RomSize;\n\n",
|
||||||
fout);
|
fout);
|
||||||
|
|
||||||
for (i = 0; i < g_segmentsCount; i++) {
|
for (i = 0; i < g_segmentsCount; i++)
|
||||||
|
{
|
||||||
const struct Segment *seg = &g_segments[i];
|
const struct Segment *seg = &g_segments[i];
|
||||||
|
|
||||||
// align start of ROM segment
|
// align start of ROM segment
|
||||||
|
@ -42,35 +44,28 @@ static void write_ld_script(FILE* fout) {
|
||||||
|
|
||||||
// initialized data (.text, .data, .rodata, .sdata)
|
// initialized data (.text, .data, .rodata, .sdata)
|
||||||
|
|
||||||
// Increment the start of the section
|
fprintf(fout, " _%sSegmentRomStartTemp = _RomSize;\n"
|
||||||
// if (seg->fields & (1 << STMT_increment))
|
|
||||||
// fprintf(fout, " . += 0x%08X;\n", seg->increment);
|
|
||||||
|
|
||||||
fprintf(fout,
|
|
||||||
" _%sSegmentRomStartTemp = _RomSize;\n"
|
|
||||||
" _%sSegmentRomStart = _%sSegmentRomStartTemp;\n"
|
" _%sSegmentRomStart = _%sSegmentRomStartTemp;\n"
|
||||||
" ..%s ",
|
" ..%s ", seg->name, seg->name, seg->name, seg->name);
|
||||||
seg->name, seg->name, seg->name, seg->name);
|
|
||||||
|
|
||||||
if (seg->fields & (1 << STMT_after))
|
if (seg->fields & (1 << STMT_after))
|
||||||
fprintf(fout, "_%sSegmentEnd ", seg->after);
|
fprintf(fout, "(_%sSegmentEnd + %i) & ~ %i ", seg->after, seg->align - 1, seg->align - 1);
|
||||||
else if (seg->fields & (1 << STMT_number))
|
else if (seg->fields & (1 << STMT_number))
|
||||||
fprintf(fout, "0x%02X000000 ", seg->number);
|
fprintf(fout, "0x%02X000000 ", seg->number);
|
||||||
else if (seg->fields & (1 << STMT_address))
|
else if (seg->fields & (1 << STMT_address))
|
||||||
fprintf(fout, "0x%08X ", seg->address);
|
fprintf(fout, "0x%08X ", seg->address);
|
||||||
|
else
|
||||||
|
fprintf(fout, "ALIGN(0x%X) ", seg->align);
|
||||||
|
|
||||||
// (AT(_RomSize) isn't necessary, but adds useful "load address" lines to the map file)
|
// (AT(_RomSize) isn't necessary, but adds useful "load address" lines to the map file)
|
||||||
fprintf(fout,
|
fprintf(fout, ": AT(_RomSize)\n {\n"
|
||||||
": AT(_RomSize)\n {\n"
|
|
||||||
" _%sSegmentStart = .;\n"
|
" _%sSegmentStart = .;\n"
|
||||||
" . = ALIGN(0x10);\n"
|
" . = ALIGN(0x10);\n"
|
||||||
" _%sSegmentTextStart = .;\n",
|
" _%sSegmentTextStart = .;\n",
|
||||||
seg->name, seg->name);
|
seg->name, seg->name);
|
||||||
|
|
||||||
if (seg->fields & (1 << STMT_align))
|
for (j = 0; j < seg->includesCount; j++)
|
||||||
fprintf(fout, " . = ALIGN(0x%X);\n", seg->align);
|
{
|
||||||
|
|
||||||
for (j = 0; j < seg->includesCount; j++) {
|
|
||||||
fprintf(fout, " %s (.text)\n", seg->includes[j].fpath);
|
fprintf(fout, " %s (.text)\n", seg->includes[j].fpath);
|
||||||
if (seg->includes[j].linkerPadding != 0)
|
if (seg->includes[j].linkerPadding != 0)
|
||||||
fprintf(fout, " . += 0x%X;\n", seg->includes[j].linkerPadding);
|
fprintf(fout, " . += 0x%X;\n", seg->includes[j].linkerPadding);
|
||||||
|
@ -79,39 +74,24 @@ static void write_ld_script(FILE* fout) {
|
||||||
|
|
||||||
fprintf(fout, " _%sSegmentTextEnd = .;\n", seg->name);
|
fprintf(fout, " _%sSegmentTextEnd = .;\n", seg->name);
|
||||||
|
|
||||||
fprintf(fout, " _%sSegmentTextSize = ABSOLUTE( _%sSegmentTextEnd - _%sSegmentTextStart );\n", seg->name,
|
fprintf(fout, " _%sSegmentTextSize = ABSOLUTE( _%sSegmentTextEnd - _%sSegmentTextStart );\n", seg->name, seg->name, seg->name);
|
||||||
seg->name, seg->name);
|
|
||||||
|
|
||||||
fprintf(fout, " _%sSegmentDataStart = .;\n", seg->name);
|
fprintf(fout, " _%sSegmentDataStart = .;\n", seg->name);
|
||||||
|
|
||||||
for (j = 0; j < seg->includesCount; j++) {
|
for (j = 0; j < seg->includesCount; j++)
|
||||||
fprintf(fout,
|
{
|
||||||
" %s (.data)\n"
|
fprintf(fout, " %s (.data)\n"
|
||||||
" . = ALIGN(0x10);\n",
|
" . = ALIGN(0x10);\n", seg->includes[j].fpath);
|
||||||
seg->includes[j].fpath);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
for (j = 0; j < seg->includesCount; j++)
|
|
||||||
fprintf(fout, " %s (.rodata)\n", seg->includes[j].fpath);
|
|
||||||
|
|
||||||
for (j = 0; j < seg->includesCount; j++)
|
|
||||||
fprintf(fout, " %s (.sdata)\n", seg->includes[j].fpath);
|
|
||||||
*/
|
|
||||||
|
|
||||||
// fprintf(fout, " . = ALIGN(0x10);\n");
|
|
||||||
fprintf(fout, " _%sSegmentDataEnd = .;\n", seg->name);
|
fprintf(fout, " _%sSegmentDataEnd = .;\n", seg->name);
|
||||||
|
|
||||||
fprintf(fout, " _%sSegmentDataSize = ABSOLUTE( _%sSegmentDataEnd - _%sSegmentDataStart );\n", seg->name,
|
fprintf(fout, " _%sSegmentDataSize = ABSOLUTE( _%sSegmentDataEnd - _%sSegmentDataStart );\n", seg->name, seg->name, seg->name);
|
||||||
seg->name, seg->name);
|
|
||||||
|
|
||||||
fprintf(fout, " _%sSegmentRoDataStart = .;\n", seg->name);
|
fprintf(fout, " _%sSegmentRoDataStart = .;\n", seg->name);
|
||||||
|
|
||||||
for (j = 0; j < seg->includesCount; j++) {
|
for (j = 0; j < seg->includesCount; j++)
|
||||||
fprintf(fout,
|
{
|
||||||
" %s (.rodata)\n"
|
|
||||||
" . = ALIGN(0x10);\n",
|
|
||||||
seg->includes[j].fpath);
|
|
||||||
// Compilers other than IDO, such as GCC, produce different sections such as
|
// Compilers other than IDO, such as GCC, produce different sections such as
|
||||||
// the ones named directly below. These sections do not contain values that
|
// the ones named directly below. These sections do not contain values that
|
||||||
// need relocating, but we need to ensure that the base .rodata section
|
// need relocating, but we need to ensure that the base .rodata section
|
||||||
|
@ -120,32 +100,22 @@ static void write_ld_script(FILE* fout) {
|
||||||
// the beginning of the entire rodata area in order to remain consistent.
|
// the beginning of the entire rodata area in order to remain consistent.
|
||||||
// Inconsistencies will lead to various .rodata reloc crashes as a result of
|
// Inconsistencies will lead to various .rodata reloc crashes as a result of
|
||||||
// either missing relocs or wrong relocs.
|
// either missing relocs or wrong relocs.
|
||||||
fprintf(fout,
|
fprintf(fout, " %s (.rodata)\n"
|
||||||
" %s (.rodata.str1.4)\n"
|
" %s (.rodata.str*)\n"
|
||||||
|
" %s (.rodata.cst*)\n"
|
||||||
" . = ALIGN(0x10);\n",
|
" . = ALIGN(0x10);\n",
|
||||||
seg->includes[j].fpath);
|
seg->includes[j].fpath, seg->includes[j].fpath, seg->includes[j].fpath);
|
||||||
fprintf(fout,
|
|
||||||
" %s (.rodata.cst4)\n"
|
|
||||||
" . = ALIGN(0x10);\n",
|
|
||||||
seg->includes[j].fpath);
|
|
||||||
fprintf(fout,
|
|
||||||
" %s (.rodata.cst8)\n"
|
|
||||||
" . = ALIGN(0x10);\n",
|
|
||||||
seg->includes[j].fpath);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(fout, " _%sSegmentRoDataEnd = .;\n", seg->name);
|
fprintf(fout, " _%sSegmentRoDataEnd = .;\n", seg->name);
|
||||||
|
|
||||||
fprintf(fout, " _%sSegmentRoDataSize = ABSOLUTE( _%sSegmentRoDataEnd - _%sSegmentRoDataStart );\n",
|
fprintf(fout, " _%sSegmentRoDataSize = ABSOLUTE( _%sSegmentRoDataEnd - _%sSegmentRoDataStart );\n", seg->name, seg->name, seg->name);
|
||||||
seg->name, seg->name, seg->name);
|
|
||||||
|
|
||||||
fprintf(fout, " _%sSegmentSDataStart = .;\n", seg->name);
|
fprintf(fout, " _%sSegmentSDataStart = .;\n", seg->name);
|
||||||
|
|
||||||
for (j = 0; j < seg->includesCount; j++)
|
for (j = 0; j < seg->includesCount; j++)
|
||||||
fprintf(fout,
|
fprintf(fout, " %s (.sdata)\n"
|
||||||
" %s (.sdata)\n"
|
" . = ALIGN(0x10);\n", seg->includes[j].fpath);
|
||||||
" . = ALIGN(0x10);\n",
|
|
||||||
seg->includes[j].fpath);
|
|
||||||
|
|
||||||
fprintf(fout, " _%sSegmentSDataEnd = .;\n", seg->name);
|
fprintf(fout, " _%sSegmentSDataEnd = .;\n", seg->name);
|
||||||
|
|
||||||
|
@ -163,8 +133,7 @@ static void write_ld_script(FILE* fout) {
|
||||||
|
|
||||||
fprintf(fout, " _RomSize += ( _%sSegmentOvlEnd - _%sSegmentTextStart );\n", seg->name, seg->name);
|
fprintf(fout, " _RomSize += ( _%sSegmentOvlEnd - _%sSegmentTextStart );\n", seg->name, seg->name);
|
||||||
|
|
||||||
fprintf(fout,
|
fprintf(fout, " _%sSegmentRomEndTemp = _RomSize;\n"
|
||||||
" _%sSegmentRomEndTemp = _RomSize;\n"
|
|
||||||
"_%sSegmentRomEnd = _%sSegmentRomEndTemp;\n\n",
|
"_%sSegmentRomEnd = _%sSegmentRomEndTemp;\n\n",
|
||||||
seg->name, seg->name, seg->name);
|
seg->name, seg->name, seg->name);
|
||||||
|
|
||||||
|
@ -173,159 +142,109 @@ static void write_ld_script(FILE* fout) {
|
||||||
fprintf(fout, " _RomSize = (_RomSize + %i) & ~ %i;\n", seg->romalign - 1, seg->romalign - 1);
|
fprintf(fout, " _RomSize = (_RomSize + %i) & ~ %i;\n", seg->romalign - 1, seg->romalign - 1);
|
||||||
|
|
||||||
// uninitialized data (.sbss, .scommon, .bss, COMMON)
|
// uninitialized data (.sbss, .scommon, .bss, COMMON)
|
||||||
fprintf(fout,
|
fprintf(fout, " ..%s.bss ADDR(..%s) + SIZEOF(..%s) (NOLOAD) :\n"
|
||||||
" ..%s.bss ADDR(..%s) + SIZEOF(..%s) (NOLOAD) :\n"
|
|
||||||
/*" ..%s.bss :\n"*/
|
/*" ..%s.bss :\n"*/
|
||||||
" {\n"
|
" {\n"
|
||||||
" . = ALIGN(0x10);\n"
|
" . = ALIGN(0x10);\n"
|
||||||
" _%sSegmentBssStart = .;\n",
|
" _%sSegmentBssStart = .;\n",
|
||||||
seg->name, seg->name, seg->name, seg->name);
|
seg->name, seg->name, seg->name, seg->name);
|
||||||
|
|
||||||
if (seg->fields & (1 << STMT_align))
|
for (j = 0; j < seg->includesCount; j++)
|
||||||
fprintf(fout, " . = ALIGN(0x%X);\n", seg->align);
|
fprintf(fout, " %s (.sbss)\n"
|
||||||
|
" . = ALIGN(0x10);\n", seg->includes[j].fpath);
|
||||||
|
|
||||||
for (j = 0; j < seg->includesCount; j++)
|
for (j = 0; j < seg->includesCount; j++)
|
||||||
fprintf(fout,
|
fprintf(fout, " %s (.scommon)\n"
|
||||||
" %s (.sbss)\n"
|
" . = ALIGN(0x10);\n", seg->includes[j].fpath);
|
||||||
" . = ALIGN(0x10);\n",
|
|
||||||
seg->includes[j].fpath);
|
|
||||||
|
|
||||||
for (j = 0; j < seg->includesCount; j++)
|
for (j = 0; j < seg->includesCount; j++)
|
||||||
fprintf(fout,
|
fprintf(fout, " %s (.bss)\n"
|
||||||
" %s (.scommon)\n"
|
" . = ALIGN(0x10);\n", seg->includes[j].fpath);
|
||||||
" . = ALIGN(0x10);\n",
|
|
||||||
seg->includes[j].fpath);
|
|
||||||
|
|
||||||
for (j = 0; j < seg->includesCount; j++)
|
for (j = 0; j < seg->includesCount; j++)
|
||||||
fprintf(fout,
|
fprintf(fout, " %s (COMMON)\n"
|
||||||
" %s (.bss)\n"
|
" . = ALIGN(0x10);\n", seg->includes[j].fpath);
|
||||||
" . = ALIGN(0x10);\n",
|
|
||||||
seg->includes[j].fpath);
|
|
||||||
|
|
||||||
for (j = 0; j < seg->includesCount; j++)
|
fprintf(fout, " . = ALIGN(0x10);\n"
|
||||||
fprintf(fout,
|
|
||||||
" %s (COMMON)\n"
|
|
||||||
" . = ALIGN(0x10);\n",
|
|
||||||
seg->includes[j].fpath);
|
|
||||||
|
|
||||||
fprintf(fout,
|
|
||||||
" . = ALIGN(0x10);\n"
|
|
||||||
" _%sSegmentBssEnd = .;\n"
|
" _%sSegmentBssEnd = .;\n"
|
||||||
" _%sSegmentEnd = .;\n"
|
" _%sSegmentEnd = .;\n"
|
||||||
" }\n"
|
" }\n"
|
||||||
" _%sSegmentBssSize = ABSOLUTE( _%sSegmentBssEnd - _%sSegmentBssStart );\n\n",
|
" _%sSegmentBssSize = ABSOLUTE( _%sSegmentBssEnd - _%sSegmentBssStart );\n\n",
|
||||||
seg->name, seg->name, seg->name, seg->name, seg->name);
|
seg->name, seg->name, seg->name, seg->name, seg->name);
|
||||||
|
|
||||||
// Increment the end of the segment
|
|
||||||
// if (seg->fields & (1 << STMT_increment))
|
|
||||||
// fprintf(fout, " . += 0x%08X;\n", seg->increment);
|
|
||||||
|
|
||||||
// fprintf(fout, " ..%s.ovl ADDR(..%s) + SIZEOF(..%s) :\n"
|
|
||||||
// /*" ..%s.bss :\n"*/
|
|
||||||
// " {\n",
|
|
||||||
// seg->name, seg->name, seg->name);
|
|
||||||
// fprintf(fout, " _%sSegmentOvlStart = .;\n", seg->name);
|
|
||||||
|
|
||||||
// for (j = 0; j < seg->includesCount; j++)
|
|
||||||
// fprintf(fout, " %s (.ovl)\n", seg->includes[j].fpath);
|
|
||||||
|
|
||||||
////fprintf(fout, " . = ALIGN(0x10);\n");
|
|
||||||
|
|
||||||
// fprintf(fout, " _%sSegmentOvlEnd = .;\n", seg->name);
|
|
||||||
|
|
||||||
// fprintf(fout, "\n }\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fputs(" _RomEnd = _RomSize;\n\n", fout);
|
fputs(" _RomEnd = _RomSize;\n\n", fout);
|
||||||
|
|
||||||
// Debugging sections
|
// Debugging sections
|
||||||
fputs(
|
fputs(
|
||||||
// mdebug debug sections
|
// mdebug sections
|
||||||
" .mdebug : { *(.mdebug) }"
|
" .pdr : { *(.pdr) }" "\n"
|
||||||
"\n"
|
" .mdebug : { *(.mdebug) }" "\n"
|
||||||
" .mdebug.abi32 : { *(.mdebug.abi32) }"
|
" .mdebug.abi32 : { *(.mdebug.abi32) }" "\n"
|
||||||
"\n"
|
|
||||||
// DWARF debug sections
|
// DWARF debug sections
|
||||||
// Symbols in the DWARF debugging sections are relative to the beginning of the section so we begin them at 0.
|
// Symbols in the DWARF debugging sections are relative to the beginning of the section so we begin them at 0.
|
||||||
// DWARF 1
|
// DWARF 1
|
||||||
" .debug 0 : { *(.debug) }"
|
" .debug 0 : { *(.debug) }" "\n"
|
||||||
"\n"
|
" .line 0 : { *(.line) }" "\n"
|
||||||
" .line 0 : { *(.line) }"
|
|
||||||
"\n"
|
|
||||||
// GNU DWARF 1 extensions
|
// GNU DWARF 1 extensions
|
||||||
" .debug_srcinfo 0 : { *(.debug_srcinfo) }"
|
" .debug_srcinfo 0 : { *(.debug_srcinfo) }" "\n"
|
||||||
"\n"
|
" .debug_sfnames 0 : { *(.debug_sfnames) }" "\n"
|
||||||
" .debug_sfnames 0 : { *(.debug_sfnames) }"
|
|
||||||
"\n"
|
|
||||||
// DWARF 1.1 and DWARF 2
|
// DWARF 1.1 and DWARF 2
|
||||||
" .debug_aranges 0 : { *(.debug_aranges) }"
|
" .debug_aranges 0 : { *(.debug_aranges) }" "\n"
|
||||||
"\n"
|
" .debug_pubnames 0 : { *(.debug_pubnames) }" "\n"
|
||||||
" .debug_pubnames 0 : { *(.debug_pubnames) }"
|
|
||||||
"\n"
|
|
||||||
// DWARF 2
|
// DWARF 2
|
||||||
" .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) }"
|
" .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) }" "\n"
|
||||||
"\n"
|
" .debug_abbrev 0 : { *(.debug_abbrev) }" "\n"
|
||||||
" .debug_abbrev 0 : { *(.debug_abbrev) }"
|
" .debug_line 0 : { *(.debug_line .debug_line.* .debug_line_end ) }" "\n"
|
||||||
"\n"
|
" .debug_frame 0 : { *(.debug_frame) }" "\n"
|
||||||
" .debug_line 0 : { *(.debug_line .debug_line.* .debug_line_end ) }"
|
" .debug_str 0 : { *(.debug_str) }" "\n"
|
||||||
"\n"
|
" .debug_loc 0 : { *(.debug_loc) }" "\n"
|
||||||
" .debug_frame 0 : { *(.debug_frame) }"
|
" .debug_macinfo 0 : { *(.debug_macinfo) }" "\n"
|
||||||
"\n"
|
|
||||||
" .debug_str 0 : { *(.debug_str) }"
|
|
||||||
"\n"
|
|
||||||
" .debug_loc 0 : { *(.debug_loc) }"
|
|
||||||
"\n"
|
|
||||||
" .debug_macinfo 0 : { *(.debug_macinfo) }"
|
|
||||||
"\n"
|
|
||||||
// SGI/MIPS DWARF 2 extensions
|
// SGI/MIPS DWARF 2 extensions
|
||||||
" .debug_weaknames 0 : { *(.debug_weaknames) }"
|
" .debug_weaknames 0 : { *(.debug_weaknames) }" "\n"
|
||||||
"\n"
|
" .debug_funcnames 0 : { *(.debug_funcnames) }" "\n"
|
||||||
" .debug_funcnames 0 : { *(.debug_funcnames) }"
|
" .debug_typenames 0 : { *(.debug_typenames) }" "\n"
|
||||||
"\n"
|
" .debug_varnames 0 : { *(.debug_varnames) }" "\n"
|
||||||
" .debug_typenames 0 : { *(.debug_typenames) }"
|
|
||||||
"\n"
|
|
||||||
" .debug_varnames 0 : { *(.debug_varnames) }"
|
|
||||||
"\n"
|
|
||||||
// DWARF 3
|
// DWARF 3
|
||||||
" .debug_pubtypes 0 : { *(.debug_pubtypes) }"
|
" .debug_pubtypes 0 : { *(.debug_pubtypes) }" "\n"
|
||||||
"\n"
|
" .debug_ranges 0 : { *(.debug_ranges) }" "\n"
|
||||||
" .debug_ranges 0 : { *(.debug_ranges) }"
|
// DWARF 5
|
||||||
"\n"
|
" .debug_addr 0 : { *(.debug_addr) }" "\n"
|
||||||
// DWARF Extension
|
" .debug_line_str 0 : { *(.debug_line_str) }" "\n"
|
||||||
" .debug_macro 0 : { *(.debug_macro) }"
|
" .debug_loclists 0 : { *(.debug_loclists) }" "\n"
|
||||||
"\n"
|
" .debug_macro 0 : { *(.debug_macro) }" "\n"
|
||||||
" .gnu.attributes 0 : { KEEP (*(.gnu.attributes)) }"
|
" .debug_names 0 : { *(.debug_names) }" "\n"
|
||||||
"\n",
|
" .debug_rnglists 0 : { *(.debug_rnglists) }" "\n"
|
||||||
fout);
|
" .debug_str_offsets 0 : { *(.debug_str_offsets) }" "\n"
|
||||||
|
" .debug_sup 0 : { *(.debug_sup) }\n"
|
||||||
|
// gnu attributes
|
||||||
|
" .gnu.attributes 0 : { KEEP (*(.gnu.attributes)) }" "\n", fout);
|
||||||
|
|
||||||
// Discard all other sections not mentioned above
|
// Discard all other sections not mentioned above
|
||||||
fputs(" /DISCARD/ :"
|
fputs(" /DISCARD/ :" "\n"
|
||||||
"\n"
|
" {" "\n"
|
||||||
" {"
|
" *(*);" "\n"
|
||||||
"\n"
|
" }" "\n", fout);
|
||||||
" *(*);"
|
|
||||||
"\n"
|
|
||||||
" }"
|
|
||||||
"\n",
|
|
||||||
fout);
|
|
||||||
fputs("}\n", fout);
|
fputs("}\n", fout);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void usage(const char* execname) {
|
static void usage(const char *execname)
|
||||||
fprintf(stderr,
|
{
|
||||||
"Nintendo 64 linker script generation tool v0.03\n"
|
fprintf(stderr, "Nintendo 64 linker script generation tool v0.03\n"
|
||||||
"usage: %s SPEC_FILE LD_SCRIPT\n"
|
"usage: %s SPEC_FILE LD_SCRIPT\n"
|
||||||
"SPEC_FILE file describing the organization of object files into segments\n"
|
"SPEC_FILE file describing the organization of object files into segments\n"
|
||||||
"LD_SCRIPT filename of output linker script\n",
|
"LD_SCRIPT filename of output linker script\n",
|
||||||
execname);
|
execname);
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char** argv) {
|
int main(int argc, char **argv)
|
||||||
|
{
|
||||||
FILE *ldout;
|
FILE *ldout;
|
||||||
void *spec;
|
void *spec;
|
||||||
size_t size;
|
size_t size;
|
||||||
|
|
||||||
if (argc != 3) {
|
if (argc != 3)
|
||||||
|
{
|
||||||
usage(argv[0]);
|
usage(argv[0]);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue