diff options
-rw-r--r-- | Makefile | 9 | ||||
-rw-r--r-- | asm/main.s | 6 | ||||
-rw-r--r-- | asm/rom2.s | 2 | ||||
-rw-r--r-- | asm/rom3.s | 5 | ||||
-rw-r--r-- | asm/rom_header.s | 8 | ||||
-rw-r--r-- | ld_script.txt | 51 |
6 files changed, 56 insertions, 25 deletions
@@ -31,7 +31,7 @@ MWCCVERSION := 2.0/base CROSS := arm-linux-gnueabi- -MWCCARM := tools/mwccarm/2.0/base/mwccarm.exe +MWCCARM := tools/mwccarm/$(MWCCVERSION)/mwccarm.exe AS := $(CROSS)as CC := $(MWCCARM) @@ -65,8 +65,11 @@ $(BUILD_DIR)/%.o: %.c $(BUILD_DIR)/%.o: %.s $(AS) $(ASFLAGS) -MD $(BUILD_DIR)/$*.d -o $@ $< -$(ELF): $(O_FILES) $(LD_SCRIPT) undefined_syms.txt - $(LD) -T undefined_syms.txt -T $(LD_SCRIPT) -o $(ELF) +$(BUILD_DIR)/$(LD_SCRIPT): $(LD_SCRIPT) + $(CPP) $(VERSION_CFLAGS) -MMD -MP -MT $@ -MF $@.d -I include/ -I . -DBUILD_DIR=$(BUILD_DIR) -o $@ $< + +$(ELF): $(O_FILES) $(BUILD_DIR)/$(LD_SCRIPT) undefined_syms.txt + $(LD) -T undefined_syms.txt -T $(BUILD_DIR)/$(LD_SCRIPT) -o $(ELF) -Map $(BUILD_DIR)/$(TARGET).map $(ROM): $(ELF) $(OBJCOPY) -O binary $< $@ @@ -2,8 +2,8 @@ .text - arm_func_start Entry_ARM9 -Entry_ARM9: @ 0x02000800 + arm_func_start Entry +Entry: @ 0x02000800 mov ip, #0x4000000 str ip, [ip, #0x208] _02000808: @@ -86,7 +86,7 @@ _0200092C: .4byte 0x027FFF9C _02000930: .4byte 0x01FF8000 _02000934: .4byte 0x02000C55 @ NdsMain _02000938: .4byte 0xFFFF0000 - arm_func_end Entry_ARM9 + arm_func_end Entry arm_func_start sub_200093C sub_200093C: @@ -10,4 +10,4 @@ sub_20EC5CC: .global sub_20EC694 sub_20EC694: -.incbin "baserom.nds", 0xF0694, 0x3F0F96C +.incbin "baserom.nds", 0xF0694, 0x1b090 diff --git a/asm/rom3.s b/asm/rom3.s new file mode 100644 index 00000000..ddb524ba --- /dev/null +++ b/asm/rom3.s @@ -0,0 +1,5 @@ +/* rom3.s TODO: Disassemble */ + +.section .text + +.incbin "baserom.nds", 0x10B724, 0x3EF48DC diff --git a/asm/rom_header.s b/asm/rom_header.s index e850d0f8..2dc62ad5 100644 --- a/asm/rom_header.s +++ b/asm/rom_header.s @@ -29,13 +29,13 @@ RomVersion: .space 1 ARM9ROMOffset: -.word 0x00004000 +.word _arm9SegmentRomStart ARM9EntryAddress: -.word 0x02000800 +.word Entry ARM9RAMAddress: -.word 0x02000000 +.word _arm9SegmentStart ARM9CodeSize: -.word 0x00107724 +.word _arm9SegmentSize ARM7ROMOffset: .word 0x0030D000 ARM7EntryAddress: diff --git a/ld_script.txt b/ld_script.txt index e904d75e..33584719 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -1,16 +1,39 @@ +/* Linker Script to build Pokemon Diamond */ + +#define BEGIN_SEG(name, addr) \ + _##name##SegmentStart = ADDR(.name); \ + _##name##SegmentRomStart = __romPos; \ + .name addr : AT(__romPos) + +#define END_SEG(name) \ + _##name##SegmentEnd = ADDR(.name) + SIZEOF(.name); \ + _##name##SegmentRomEnd = __romPos + SIZEOF(.name); \ + _##name##SegmentSize = SIZEOF(.name); \ + __romPos += SIZEOF(.name); + SECTIONS { - header : - { - build/asm/rom_header.o(.text); - } - - . = 0x4000; - rom_code : - { - build/asm/secure.o(.text); - build/asm/main.o(.text); - build/asm/rom.o(.text); - build/src/sub_02000DF4.o(.text); - build/asm/rom2.o(.text); - } + __romPos = 0; + BEGIN_SEG(header, 0x0) + { + build/asm/rom_header.o(.text); + } + END_SEG(header) + + __romPos += 0x3E00; + + BEGIN_SEG(arm9, 0x2000000) + { + build/asm/secure.o(.text); + build/asm/main.o(.text); + build/asm/rom.o(.text); + build/src/sub_02000DF4.o(.text); + build/asm/rom2.o(.text); + } + END_SEG(arm9) + + BEGIN_SEG(rom3, 0x2000000 + SIZEOF(arm9)) + { + build/asm/rom3.o(.text); + } + END_SEG(rom3) } |