mirror of
https://gitlab.com/ryandwyer/perfect-dark
synced 2026-09-01 09:22:53 -04:00
Get it working with a single ld script
This commit is contained in:
@@ -126,92 +126,54 @@ lang: $(LANG_BIN_FILES)
|
||||
################################################################################
|
||||
# Boot
|
||||
|
||||
$(B_DIR)/boot.elf: $(O_FILES)
|
||||
mkdir -p $(B_DIR)
|
||||
$(TOOLCHAIN)-ld -T ld/boot.ld -o $@
|
||||
|
||||
$(B_DIR)/ucode/boot.bin: $(B_DIR)/boot.elf
|
||||
$(B_DIR)/ucode/boot.bin: $(B_DIR)/stage1.bin
|
||||
mkdir -p $(B_DIR)/ucode
|
||||
$(TOOLCHAIN)-objcopy $< /tmp/boot.tmp -O binary
|
||||
dd if=/tmp/boot.tmp of="$@" bs=8272 count=1
|
||||
rm -f /tmp/boot.tmp
|
||||
B_DIR=$(B_DIR) tools/extract-segment boot
|
||||
|
||||
boot: $(B_DIR)/ucode/boot.bin
|
||||
|
||||
################################################################################
|
||||
# Library
|
||||
|
||||
$(B_DIR)/library.elf: $(O_FILES)
|
||||
mkdir -p $(B_DIR)
|
||||
$(TOOLCHAIN)-ld -T ld/library.ld -o $@
|
||||
|
||||
$(B_DIR)/ucode/library.bin: $(B_DIR)/library.elf
|
||||
$(B_DIR)/ucode/library.bin: $(B_DIR)/stage1.bin
|
||||
mkdir -p $(B_DIR)/ucode
|
||||
$(TOOLCHAIN)-objcopy $< /tmp/library.tmp -O binary
|
||||
dd if=/tmp/library.tmp of="$@" bs=356240 count=1
|
||||
rm -f /tmp/library.tmp
|
||||
B_DIR=$(B_DIR) tools/extract-segment library
|
||||
|
||||
library: $(B_DIR)/ucode/library.bin
|
||||
|
||||
################################################################################
|
||||
# Game setup file
|
||||
|
||||
$(B_DIR)/setup.elf: $(O_FILES)
|
||||
mkdir -p $(B_DIR)
|
||||
$(TOOLCHAIN)-ld -T ld/setup.ld -o $@
|
||||
|
||||
$(B_DIR)/ucode/setup.bin: $(B_DIR)/setup.elf
|
||||
$(B_DIR)/ucode/setup.bin: $(B_DIR)/stage1.bin
|
||||
mkdir -p $(B_DIR)/ucode
|
||||
$(TOOLCHAIN)-objcopy $< /tmp/setup.tmp -O binary
|
||||
dd if=/tmp/setup.tmp of="$@" bs=200256 count=1
|
||||
rm -f /tmp/setup.tmp
|
||||
B_DIR=$(B_DIR) tools/extract-segment setup
|
||||
|
||||
setup: $(B_DIR)/ucode/setup.bin
|
||||
|
||||
################################################################################
|
||||
# Rarezip
|
||||
|
||||
$(B_DIR)/rarezip.elf: $(O_FILES)
|
||||
mkdir -p $(B_DIR)
|
||||
$(TOOLCHAIN)-ld -T ld/rarezip.ld -o $@
|
||||
|
||||
$(B_DIR)/ucode/rarezip.bin: $(B_DIR)/rarezip.elf
|
||||
$(B_DIR)/ucode/rarezip.bin: $(B_DIR)/stage1.bin
|
||||
mkdir -p $(B_DIR)/ucode
|
||||
$(TOOLCHAIN)-objcopy $< $@ -O binary
|
||||
B_DIR=$(B_DIR) tools/extract-segment rarezip
|
||||
|
||||
rarezip: $(B_DIR)/ucode/rarezip.bin
|
||||
|
||||
################################################################################
|
||||
# Main game
|
||||
|
||||
$(B_DIR)/game.elf: $(O_FILES)
|
||||
mkdir -p $(B_DIR)
|
||||
$(TOOLCHAIN)-ld -T ld/game.ld -o $@
|
||||
|
||||
$(B_DIR)/gamerodata.elf: $(O_FILES)
|
||||
mkdir -p $(B_DIR)
|
||||
$(TOOLCHAIN)-ld -T ld/gamerodata.ld -o $@
|
||||
|
||||
$(B_DIR)/ucode/game.bin: $(B_DIR)/game.elf $(B_DIR)/gamerodata.elf
|
||||
$(B_DIR)/ucode/game.bin: $(B_DIR)/stage1.bin
|
||||
mkdir -p $(B_DIR)/ucode
|
||||
$(TOOLCHAIN)-objcopy $(B_DIR)/game.elf /tmp/game.tmp -O binary
|
||||
$(TOOLCHAIN)-objcopy $(B_DIR)/gamerodata.elf /tmp/gamerodata.tmp -O binary
|
||||
dd if=/tmp/game.tmp of="$@" bs=1734848 count=1
|
||||
dd if=/tmp/gamerodata.tmp of="$@" bs=74016 count=1 conv=notrunc oflag=append
|
||||
rm -f /tmp/game.tmp /tmp/gamerodata.tmp
|
||||
B_DIR=$(B_DIR) tools/extract-segment game
|
||||
|
||||
game: $(B_DIR)/ucode/game.bin
|
||||
|
||||
################################################################################
|
||||
# gVars
|
||||
|
||||
$(B_DIR)/gvars.elf: $(O_FILES)
|
||||
mkdir -p $(B_DIR)
|
||||
$(TOOLCHAIN)-ld -T ld/gvars.ld -o $@
|
||||
|
||||
$(B_DIR)/ucode/gvars.bin: $(B_DIR)/gvars.elf
|
||||
$(B_DIR)/ucode/gvars.bin: $(B_DIR)/stage1.bin
|
||||
mkdir -p $(B_DIR)/ucode
|
||||
$(TOOLCHAIN)-objcopy $< $@ -O binary
|
||||
B_DIR=$(B_DIR) tools/extract-segment gvars
|
||||
|
||||
gvars: $(B_DIR)/ucode/gvars.bin
|
||||
|
||||
@@ -232,6 +194,14 @@ test: all
|
||||
python tools/asmpreproc/asm-processor.py -O2 $< | $(QEMU_IRIX) -silent -L $(IRIX_ROOT) $(IRIX_ROOT)/usr/bin/cc -c $(CFLAGS) tools/asmpreproc/include-stdin.c -o $@ -O2
|
||||
python tools/asmpreproc/asm-processor.py -O2 $< --post-process $@ --assembler "$(TOOLCHAIN)-as -march=vr4300 -mabi=32" --asm-prelude tools/asmpreproc/prelude.s
|
||||
|
||||
$(B_DIR)/stage1.elf: $(O_FILES)
|
||||
mkdir -p $(B_DIR)
|
||||
$(TOOLCHAIN)-ld -T ld/stage1.ld --print-map -o $@ > $(B_DIR)/stage1.map
|
||||
|
||||
$(B_DIR)/stage1.bin: $(B_DIR)/stage1.elf
|
||||
mkdir -p $(B_DIR)/ucode
|
||||
$(TOOLCHAIN)-objcopy $< $@ -O binary
|
||||
|
||||
all: stagesetup lang boot library setup tiles rarezip game gvars
|
||||
|
||||
rom: all
|
||||
|
||||
-64
@@ -1,64 +0,0 @@
|
||||
/*OUTPUT_FORMAT ("elf32-bigmips")*/
|
||||
OUTPUT_ARCH (mips)
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
.game 0x0f000000 : AT(0) {
|
||||
src/game/game_000000.o (.text);
|
||||
src/game/chr/chrai.o (.text);
|
||||
src/game/chr/chraicommands.o (.text);
|
||||
src/game/game_0601b0.o (.text);
|
||||
}
|
||||
|
||||
.gamerodata 0x7f000000 + SIZEOF(.game) : AT(SIZEOF(.game)) {
|
||||
src/game/game_000000.o (.rodata);
|
||||
src/game/chr/chrai.o (.rodata);
|
||||
src/game/chr/chraicommands.o (.rodata);
|
||||
src/game/game_0601b0.o (.rodata);
|
||||
|
||||
src/game/game_000000.o (.data);
|
||||
src/game/chr/chrai.o (.data);
|
||||
src/game/chr/chraicommands.o (.data);
|
||||
src/game/game_0601b0.o (.data);
|
||||
}
|
||||
|
||||
.library 0x00003050 : AT(SIZEOF(.game) + SIZEOF(.gamerodata)) {
|
||||
src/library/library.o (.text);
|
||||
src/library/library.o (.data);
|
||||
}
|
||||
|
||||
.setup 0x80059fe0 : AT(SIZEOF(.game) + SIZEOF(.gamerodata) + SIZEOF(.library)) {
|
||||
src/setup/setup_000000.o (.data);
|
||||
src/setup/inventory.o (.data);
|
||||
src/setup/setup_0160b0.o (.data);
|
||||
src/setup/ailists.o (.data);
|
||||
src/setup/setup_020df0.o (.data);
|
||||
}
|
||||
|
||||
.gvars 0x8008ae20 : AT(SIZEOF(.game) + SIZEOF(.gamerodata) + SIZEOF(.library) + SIZEOF(.setup)) {
|
||||
src/gvars/gvars.o (.data);
|
||||
}
|
||||
|
||||
.boot 0x00001000 : AT(SIZEOF(.game) + SIZEOF(.gamerodata) + SIZEOF(.library) + SIZEOF(.setup) + SIZEOF(.gvars)) {
|
||||
src/boot/boot.o (.text);
|
||||
src/boot/boot.o (.data);
|
||||
}
|
||||
|
||||
/* We don't really care about these values here */
|
||||
setupSegmentStart = 0;
|
||||
setupSegmentRomStart = 0;
|
||||
rarezipSegmentStart = 0;
|
||||
rarezipSegmentRomStart = 0;
|
||||
ziplistSegmentRomStart = 0;
|
||||
|
||||
/DISCARD/ : {
|
||||
* (.MIPS.abiflags);
|
||||
* (.options);
|
||||
* (.gnu.attributes);
|
||||
* (.pdr);
|
||||
* (.mdebug);
|
||||
* (.gptab.bss);
|
||||
* (.gptab.data);
|
||||
* (.reginfo);
|
||||
}
|
||||
}
|
||||
@@ -1,63 +0,0 @@
|
||||
/*OUTPUT_FORMAT ("elf32-bigmips")*/
|
||||
OUTPUT_ARCH (mips)
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
.gamerodata 0x7f000000 + SIZEOF(.game) : AT(0) {
|
||||
src/game/game_000000.o (.rodata);
|
||||
src/game/chr/chrai.o (.rodata);
|
||||
src/game/chr/chraicommands.o (.rodata);
|
||||
src/game/game_0601b0.o (.rodata);
|
||||
|
||||
src/game/game_000000.o (.data);
|
||||
src/game/chr/chrai.o (.data);
|
||||
src/game/chr/chraicommands.o (.data);
|
||||
src/game/game_0601b0.o (.data);
|
||||
}
|
||||
|
||||
.game 0x7f000000 : AT(SIZEOF(.gamerodata)) {
|
||||
src/game/game_000000.o (.text);
|
||||
src/game/chr/chrai.o (.text);
|
||||
src/game/chr/chraicommands.o (.text);
|
||||
src/game/game_0601b0.o (.text);
|
||||
}
|
||||
|
||||
.library 0x7f003050 : AT(SIZEOF(.game) + SIZEOF(.gamerodata)) {
|
||||
src/library/library.o (.text);
|
||||
src/library/library.o (.data);
|
||||
}
|
||||
|
||||
.setup 0x80059fe0 : AT(SIZEOF(.game) + SIZEOF(.gamerodata) + SIZEOF(.library)) {
|
||||
src/setup/setup_000000.o (.data);
|
||||
src/setup/inventory.o (.data);
|
||||
src/setup/setup_0160b0.o (.data);
|
||||
src/setup/ailists.o (.data);
|
||||
src/setup/setup_020df0.o (.data);
|
||||
}
|
||||
|
||||
.gvars 0x8008ae20 : AT(SIZEOF(.game) + SIZEOF(.gamerodata) + SIZEOF(.library) + SIZEOF(.setup)) {
|
||||
src/gvars/gvars.o (.data);
|
||||
}
|
||||
|
||||
.boot 0x7f001000 : AT(SIZEOF(.game) + SIZEOF(.gamerodata) + SIZEOF(.library) + SIZEOF(.setup) + SIZEOF(.gvars)) {
|
||||
src/boot/boot.o (.text);
|
||||
src/boot/boot.o (.data);
|
||||
}
|
||||
|
||||
/* We don't really care about these values here */
|
||||
setupSegmentStart = 0;
|
||||
setupSegmentRomStart = 0;
|
||||
rarezipSegmentStart = 0;
|
||||
rarezipSegmentRomStart = 0;
|
||||
ziplistSegmentRomStart = 0;
|
||||
/DISCARD/ : {
|
||||
* (.MIPS.abiflags);
|
||||
* (.options);
|
||||
* (.gnu.attributes);
|
||||
* (.pdr);
|
||||
* (.mdebug);
|
||||
* (.gptab.bss);
|
||||
* (.gptab.data);
|
||||
* (.reginfo);
|
||||
}
|
||||
}
|
||||
-22
@@ -1,22 +0,0 @@
|
||||
/*OUTPUT_FORMAT ("elf32-bigmips")*/
|
||||
OUTPUT_ARCH (mips)
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
.gvars 0x8008ae20 : AT(0) {
|
||||
src/gvars/gvars.o (.text);
|
||||
src/gvars/gvars.o (.data);
|
||||
}
|
||||
|
||||
/DISCARD/ : {
|
||||
* (.MIPS.abiflags);
|
||||
* (.options);
|
||||
* (.gnu.attributes);
|
||||
* (.pdr);
|
||||
* (.mdebug);
|
||||
* (.gptab.bss);
|
||||
* (.gptab.data);
|
||||
* (.reginfo);
|
||||
* (.setup.data);
|
||||
}
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
/*OUTPUT_FORMAT ("elf32-bigmips")*/
|
||||
OUTPUT_ARCH (mips)
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
.library 0x00003050 : AT(0) {
|
||||
src/library/library.o (.text);
|
||||
src/library/library.o (.data);
|
||||
}
|
||||
|
||||
.setup 0x80059fe0 : AT(SIZEOF(.library)) {
|
||||
src/setup/setup_000000.o (.data);
|
||||
src/setup/inventory.o (.data);
|
||||
src/setup/setup_0160b0.o (.data);
|
||||
src/setup/ailists.o (.data);
|
||||
src/setup/setup_020df0.o (.data);
|
||||
}
|
||||
|
||||
.gvars 0x8008ae20 : AT(SIZEOF(.library) + SIZEOF(.setup)) {
|
||||
src/gvars/gvars.o (.data);
|
||||
}
|
||||
|
||||
.game 0x0f000000 : AT(SIZEOF(.library) + SIZEOF(.setup) + SIZEOF(.gvars)) {
|
||||
src/game/game_000000.o (.text);
|
||||
src/game/chr/chrai.o (.text);
|
||||
src/game/chr/chraicommands.o (.text);
|
||||
src/game/game_0601b0.o (.text);
|
||||
|
||||
src/game/game_000000.o (.data);
|
||||
src/game/chr/chrai.o (.data);
|
||||
src/game/chr/chraicommands.o (.data);
|
||||
src/game/game_0601b0.o (.data);
|
||||
}
|
||||
|
||||
.boot 0x1000 : AT(SIZEOF(.library) + SIZEOF(.setup) + SIZEOF(.gvars) + SIZEOF(.game)) {
|
||||
src/boot/boot.o (.text);
|
||||
src/boot/boot.o (.data);
|
||||
}
|
||||
|
||||
/* We don't really care about these values here */
|
||||
setupSegmentStart = 0;
|
||||
setupSegmentRomStart = 0;
|
||||
rarezipSegmentStart = 0;
|
||||
rarezipSegmentRomStart = 0;
|
||||
ziplistSegmentRomStart = 0;
|
||||
|
||||
/DISCARD/ : {
|
||||
* (.MIPS.abiflags);
|
||||
* (.options);
|
||||
* (.gnu.attributes);
|
||||
* (.pdr);
|
||||
* (.mdebug);
|
||||
* (.gptab.bss);
|
||||
* (.gptab.data);
|
||||
* (.reginfo);
|
||||
* (.setup.data);
|
||||
}
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
/*OUTPUT_FORMAT ("elf32-bigmips")*/
|
||||
OUTPUT_ARCH (mips)
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
.text 0x70200000 : AT(0x0000) {
|
||||
src/rarezip/rarezip.o (.text);
|
||||
src/rarezip/rarezip.o (.data);
|
||||
}
|
||||
|
||||
/DISCARD/ : {
|
||||
* (.MIPS.abiflags);
|
||||
* (.options);
|
||||
* (.gnu.attributes);
|
||||
* (.pdr);
|
||||
* (.mdebug);
|
||||
* (.gptab.bss);
|
||||
* (.gptab.data);
|
||||
* (.reginfo);
|
||||
}
|
||||
}
|
||||
|
||||
-57
@@ -1,57 +0,0 @@
|
||||
/*OUTPUT_FORMAT ("elf32-bigmips")*/
|
||||
OUTPUT_ARCH (mips)
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
.setup 0x80059fe0 : AT(0) {
|
||||
src/setup/setup_000000.o (.data);
|
||||
src/setup/inventory.o (.data);
|
||||
src/setup/setup_0160b0.o (.data);
|
||||
src/setup/ailists.o (.data);
|
||||
src/setup/setup_020df0.o (.data);
|
||||
}
|
||||
|
||||
.gvars 0x8008ae20 : AT(SIZEOF(.setup)) {
|
||||
src/gvars/gvars.o (.data);
|
||||
}
|
||||
|
||||
.library 0x7e000000 : AT(SIZEOF(.setup) + SIZEOF(.gvars)) {
|
||||
src/library/library.o (.text);
|
||||
src/library/library.o (.data);
|
||||
}
|
||||
|
||||
.game 0x7f000000 : AT(SIZEOF(.setup) + SIZEOF(.gvars) + SIZEOF(.library)) {
|
||||
src/game/game_000000.o (.text);
|
||||
src/game/chr/chrai.o (.text);
|
||||
src/game/chr/chraicommands.o (.text);
|
||||
src/game/game_0601b0.o (.text);
|
||||
|
||||
src/game/game_000000.o (.data);
|
||||
src/game/chr/chrai.o (.data);
|
||||
src/game/chr/chraicommands.o (.data);
|
||||
src/game/game_0601b0.o (.data);
|
||||
}
|
||||
|
||||
.boot 0x7d001000 : AT(SIZEOF(.setup) + SIZEOF(.gvars) + SIZEOF(.library) + SIZEOF(.game)) {
|
||||
src/boot/boot.o (.text);
|
||||
src/boot/boot.o (.data);
|
||||
}
|
||||
|
||||
/* We don't really care about these values here */
|
||||
setupSegmentStart = 0;
|
||||
setupSegmentRomStart = 0;
|
||||
rarezipSegmentStart = 0;
|
||||
rarezipSegmentRomStart = 0;
|
||||
ziplistSegmentRomStart = 0;
|
||||
|
||||
/DISCARD/ : {
|
||||
* (.MIPS.abiflags);
|
||||
* (.options);
|
||||
* (.gnu.attributes);
|
||||
* (.pdr);
|
||||
* (.mdebug);
|
||||
* (.gptab.bss);
|
||||
* (.gptab.data);
|
||||
* (.reginfo);
|
||||
}
|
||||
}
|
||||
@@ -8,12 +8,12 @@ SECTIONS
|
||||
rarezipSegmentRomStart = 0x4e850;
|
||||
ziplistSegmentRomStart = 0x4fc40;
|
||||
|
||||
.boot 0x00001000 : AT(0) {
|
||||
.boot 0x70001000 : AT(0) {
|
||||
src/boot/boot.o (.text);
|
||||
src/boot/boot.o (.data);
|
||||
}
|
||||
|
||||
.library 0x00003050 : AT(SIZEOF(.boot)) {
|
||||
.library 0x70003050 : AT(SIZEOF(.boot)) {
|
||||
src/library/library.o (.text);
|
||||
src/library/library.o (.data);
|
||||
}
|
||||
@@ -30,7 +30,7 @@ SECTIONS
|
||||
src/gvars/gvars.o (.data);
|
||||
}
|
||||
|
||||
.game 0x0f000000 : AT(SIZEOF(.boot) + SIZEOF(.library) + SIZEOF(.setup) + SIZEOF(.gvars)) {
|
||||
.game 0x7f000000 : AT(SIZEOF(.boot) + SIZEOF(.library) + SIZEOF(.setup) + SIZEOF(.gvars)) {
|
||||
src/game/game_000000.o (.text);
|
||||
src/game/chr/chrai.o (.text);
|
||||
src/game/chr/chraicommands.o (.text);
|
||||
@@ -47,6 +47,11 @@ SECTIONS
|
||||
src/game/game_0601b0.o (.rodata);
|
||||
}
|
||||
|
||||
.rarezip 0x70200000 : AT(SIZEOF(.boot) + SIZEOF(.library) + SIZEOF(.setup) + SIZEOF(.gvars) + SIZEOF(.game)) {
|
||||
src/rarezip/rarezip.o (.text);
|
||||
src/rarezip/rarezip.o (.data);
|
||||
}
|
||||
|
||||
/DISCARD/ : {
|
||||
* (.MIPS.abiflags);
|
||||
* (.options);
|
||||
@@ -56,6 +61,5 @@ SECTIONS
|
||||
* (.gptab.bss);
|
||||
* (.gptab.data);
|
||||
* (.reginfo);
|
||||
* (.setup.data);
|
||||
}
|
||||
}
|
||||
Executable
+11
@@ -0,0 +1,11 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Extracts a segment from the stage1 binary which has been built from source.
|
||||
|
||||
segment=$1
|
||||
|
||||
pos=$(grep "^\.$segment" $B_DIR/stage1.map | awk '{print $6}')
|
||||
len=$(grep "^\.$segment" $B_DIR/stage1.map | awk '{print $3}')
|
||||
|
||||
dd if=$B_DIR/stage1.bin of=$B_DIR/ucode/$segment.bin skip=$(($pos)) iflag=skip_bytes bs=$(($len)) count=1
|
||||
|
||||
Reference in New Issue
Block a user