Auto-generate LCF

This commit is contained in:
Aetias
2023-09-16 09:51:55 +02:00
parent 078e0df4f9
commit e82e69f4f2
4 changed files with 311 additions and 721 deletions
+7 -3
View File
@@ -1,8 +1,8 @@
ROOT := $(shell pwd)
BUILD_DIR := $(ROOT)/build
TOOLS_DIR := $(ROOT)/tools
LCF_FILE := $(ROOT)/arm9_linker_script.lcf
OBJS_FILE := $(ROOT)/arm9_objects.txt
LCF_FILE := $(BUILD_DIR)/arm9_linker_script.lcf
OBJS_FILE := $(BUILD_DIR)/arm9_objects.txt
ASM_FILES := $(wildcard asm/*.s)
CXX_FILES := $(wildcard src/*.cpp)
@@ -23,7 +23,7 @@ LD_FLAGS := -proc arm946e -nostdlib -interworking -m func_02000800 -map closure
all: arm9
.PHONY: arm9
arm9: setup $(ASM_OBJS) link
arm9: setup $(ASM_OBJS) lcf link
.PHONY: setup
setup:
@@ -33,6 +33,10 @@ setup:
clean:
rm -r build/
.PHONY: lcf
lcf: $(TOOLS_DIR)/lcf.py
python $(TOOLS_DIR)/lcf.py
$(ASM_OBJS): $(BUILD_DIR)/%.o: %.s
mkdir -p $(dir $@)
$(MW_ASM) $(ASM_FLAGS) $< -o $@
-528
View File
@@ -1,528 +0,0 @@
MEMORY
{
ARM9 : ORIGIN = 0x2000000, LENGTH = 0x0 > arm9.bin
ITCM : ORIGIN = 0x1ff8000, LENGTH = 0x0 >> arm9.bin
DTCM : ORIGIN = 0x2fe0000, LENGTH = 0x0 >> arm9.bin
AUTOLOADS : ORIGIN = 0, LENGTH = 0x0 >> arm9.bin
FOOTER : ORIGIN = 0, LENGTH = 0x0 >> arm9.bin
OV_TABLE : ORIGIN = AFTER(ARM9), LENGTH = 0x0 > arm9_ovt.bin
OV00 : ORIGIN = 0x20773c0, LENGTH = 0x0 > ov00.bin
OV01 : ORIGIN = 0x20eed40, LENGTH = 0x0 > ov01.bin
OV02 : ORIGIN = 0x20eed40, LENGTH = 0x0 > ov02.bin
OV03 : ORIGIN = 0x20eed40, LENGTH = 0x0 > ov03.bin
OV04 : ORIGIN = 0x2100ae0, LENGTH = 0x0 > ov04.bin
OV05 : ORIGIN = 0x2100ae0, LENGTH = 0x0 > ov05.bin
OV06 : ORIGIN = 0x2100ae0, LENGTH = 0x0 > ov06.bin
OV07 : ORIGIN = 0x2100ae0, LENGTH = 0x0 > ov07.bin
OV08 : ORIGIN = 0x2112c20, LENGTH = 0x0 > ov08.bin
OV09 : ORIGIN = 0x2112c20, LENGTH = 0x0 > ov09.bin
OV10 : ORIGIN = 0x2112c20, LENGTH = 0x0 > ov10.bin
OV11 : ORIGIN = 0x2112c20, LENGTH = 0x0 > ov11.bin
OV12 : ORIGIN = 0x2112c20, LENGTH = 0x0 > ov12.bin
OV13 : ORIGIN = 0x2112c20, LENGTH = 0x0 > ov13.bin
OV14 : ORIGIN = 0x211f640, LENGTH = 0x0 > ov14.bin
OV15 : ORIGIN = 0x211f640, LENGTH = 0x0 > ov15.bin
OV16 : ORIGIN = 0x211f640, LENGTH = 0x0 > ov16.bin
OV17 : ORIGIN = 0x215b4a0, LENGTH = 0x0 > ov17.bin
OV18 : ORIGIN = 0x215b4a0, LENGTH = 0x0 > ov18.bin
OV19 : ORIGIN = 0x216d6a0, LENGTH = 0x0 > ov19.bin
OV20 : ORIGIN = 0x216d6a0, LENGTH = 0x0 > ov20.bin
OV21 : ORIGIN = 0x216d6a0, LENGTH = 0x0 > ov21.bin
OV22 : ORIGIN = 0x216d6a0, LENGTH = 0x0 > ov22.bin
OV23 : ORIGIN = 0x216d6a0, LENGTH = 0x0 > ov23.bin
OV24 : ORIGIN = 0x216d6a0, LENGTH = 0x0 > ov24.bin
OV25 : ORIGIN = 0x216d6a0, LENGTH = 0x0 > ov25.bin
OV26 : ORIGIN = 0x216d6a0, LENGTH = 0x0 > ov26.bin
OV27 : ORIGIN = 0x216d6a0, LENGTH = 0x0 > ov27.bin
OV28 : ORIGIN = 0x216d6a0, LENGTH = 0x0 > ov28.bin
OV29 : ORIGIN = 0x216d6a0, LENGTH = 0x0 > ov29.bin
OV30 : ORIGIN = 0x217bd80, LENGTH = 0x0 > ov30.bin
OV31 : ORIGIN = 0x217bd80, LENGTH = 0x0 > ov31.bin
OV32 : ORIGIN = 0x217bd80, LENGTH = 0x0 > ov32.bin
OV33 : ORIGIN = 0x217bd80, LENGTH = 0x0 > ov33.bin
OV34 : ORIGIN = 0x217bd80, LENGTH = 0x0 > ov34.bin
OV35 : ORIGIN = 0x217bd80, LENGTH = 0x0 > ov35.bin
OV36 : ORIGIN = 0x217bd80, LENGTH = 0x0 > ov36.bin
OV37 : ORIGIN = 0x217bd80, LENGTH = 0x0 > ov37.bin
OV38 : ORIGIN = 0x217bd80, LENGTH = 0x0 > ov38.bin
OV39 : ORIGIN = 0x217bd80, LENGTH = 0x0 > ov39.bin
OV40 : ORIGIN = 0x217bd80, LENGTH = 0x0 > ov40.bin
OV41 : ORIGIN = 0x2189560, LENGTH = 0x0 > ov41.bin
OV42 : ORIGIN = 0x2189560, LENGTH = 0x0 > ov42.bin
OV43 : ORIGIN = 0x2189560, LENGTH = 0x0 > ov43.bin
OV44 : ORIGIN = 0x2189560, LENGTH = 0x0 > ov44.bin
OV45 : ORIGIN = 0x2189560, LENGTH = 0x0 > ov45.bin
OV46 : ORIGIN = 0x2190040, LENGTH = 0x0 > ov46.bin
OV47 : ORIGIN = 0x2190040, LENGTH = 0x0 > ov47.bin
OV48 : ORIGIN = 0x2190040, LENGTH = 0x0 > ov48.bin
OV49 : ORIGIN = 0x2195500, LENGTH = 0x0 > ov49.bin
OV50 : ORIGIN = 0x2195500, LENGTH = 0x0 > ov50.bin
OV51 : ORIGIN = 0x2195500, LENGTH = 0x0 > ov51.bin
OV52 : ORIGIN = 0x2198d00, LENGTH = 0x0 > ov52.bin
OV53 : ORIGIN = 0x2198d00, LENGTH = 0x0 > ov53.bin
OV54 : ORIGIN = 0x2198d00, LENGTH = 0x0 > ov54.bin
OV55 : ORIGIN = 0x2198d00, LENGTH = 0x0 > ov55.bin
OV56 : ORIGIN = 0x2198d00, LENGTH = 0x0 > ov56.bin
OV57 : ORIGIN = 0x2198d00, LENGTH = 0x0 > ov57.bin
OV58 : ORIGIN = 0x2198d00, LENGTH = 0x0 > ov58.bin
OV59 : ORIGIN = 0x2198d00, LENGTH = 0x0 > ov59.bin
OV60 : ORIGIN = 0x213dec0, LENGTH = 0x0 > ov60.bin
OV61 : ORIGIN = 0x213dec0, LENGTH = 0x0 > ov61.bin
}
SECTIONS
{
.arm9 :
{
main.o(.text)
main.o(.data)
main.o(.bss)
} > ARM9
.itcm :
{
itcm.o(.text)
} > ITCM
.dtcm :
{
dtcm.o(.data)
dtcm.o(.bss)
} > DTCM
.ov00 :
{
ov00.o(.text)
ov00.o(.data)
ov00.o(.bss)
} > OV00
.ov01 :
{
ov01.o(.text)
ov01.o(.data)
ov01.o(.bss)
} > OV01
.ov02 :
{
ov02.o(.text)
ov02.o(.data)
ov02.o(.bss)
} > OV02
.ov03 :
{
ov03.o(.text)
ov03.o(.data)
ov03.o(.bss)
} > OV03
.ov04 :
{
ov04.o(.text)
ov04.o(.data)
ov04.o(.bss)
} > OV04
.ov05 :
{
ov05.o(.text)
ov05.o(.data)
ov05.o(.bss)
} > OV05
.ov06 :
{
ov06.o(.text)
ov06.o(.data)
ov06.o(.bss)
} > OV06
.ov07 :
{
ov07.o(.text)
ov07.o(.data)
ov07.o(.bss)
} > OV07
.ov08 :
{
ov08.o(.text)
ov08.o(.data)
ov08.o(.bss)
} > OV08
.ov09 :
{
ov09.o(.text)
ov09.o(.data)
ov09.o(.bss)
} > OV09
.ov10 :
{
ov10.o(.text)
ov10.o(.data)
ov10.o(.bss)
} > OV10
.ov11 :
{
ov11.o(.text)
ov11.o(.data)
ov11.o(.bss)
} > OV11
.ov12 :
{
ov12.o(.text)
ov12.o(.data)
ov12.o(.bss)
} > OV12
.ov13 :
{
ov13.o(.text)
ov13.o(.data)
ov13.o(.bss)
} > OV13
.ov14 :
{
ov14.o(.text)
ov14.o(.data)
ov14.o(.bss)
} > OV14
.ov15 :
{
ov15.o(.text)
ov15.o(.data)
ov15.o(.bss)
} > OV15
.ov16 :
{
ov16.o(.text)
ov16.o(.data)
ov16.o(.bss)
} > OV16
.ov17 :
{
ov17.o(.text)
ov17.o(.data)
ov17.o(.bss)
} > OV17
.ov18 :
{
ov18.o(.text)
ov18.o(.data)
ov18.o(.bss)
} > OV18
.ov19 :
{
ov19.o(.text)
ov19.o(.data)
ov19.o(.bss)
} > OV19
.ov20 :
{
ov20.o(.text)
ov20.o(.data)
ov20.o(.bss)
} > OV20
.ov21 :
{
ov21.o(.text)
ov21.o(.data)
ov21.o(.bss)
} > OV21
.ov22 :
{
ov22.o(.text)
ov22.o(.data)
ov22.o(.bss)
} > OV22
.ov23 :
{
ov23.o(.text)
ov23.o(.data)
ov23.o(.bss)
} > OV23
.ov24 :
{
ov24.o(.text)
ov24.o(.data)
ov24.o(.bss)
} > OV24
.ov25 :
{
ov25.o(.text)
ov25.o(.data)
ov25.o(.bss)
} > OV25
.ov26 :
{
ov26.o(.text)
ov26.o(.data)
ov26.o(.bss)
} > OV26
.ov27 :
{
ov27.o(.text)
ov27.o(.data)
ov27.o(.bss)
} > OV27
.ov28 :
{
ov28.o(.text)
ov28.o(.data)
ov28.o(.bss)
} > OV28
.ov29 :
{
ov29.o(.text)
ov29.o(.data)
ov29.o(.bss)
} > OV29
.ov30 :
{
ov30.o(.text)
ov30.o(.data)
ov30.o(.bss)
} > OV30
.ov31 :
{
ov31.o(.text)
ov31.o(.data)
ov31.o(.bss)
} > OV31
.ov32 :
{
ov32.o(.text)
ov32.o(.data)
ov32.o(.bss)
} > OV32
.ov33 :
{
ov33.o(.text)
ov33.o(.data)
ov33.o(.bss)
} > OV33
.ov34 :
{
ov34.o(.text)
ov34.o(.data)
ov34.o(.bss)
} > OV34
.ov35 :
{
ov35.o(.text)
ov35.o(.data)
ov35.o(.bss)
} > OV35
.ov36 :
{
ov36.o(.text)
ov36.o(.data)
ov36.o(.bss)
} > OV36
.ov37 :
{
ov37.o(.text)
ov37.o(.data)
ov37.o(.bss)
} > OV37
.ov38 :
{
ov38.o(.text)
ov38.o(.data)
ov38.o(.bss)
} > OV38
.ov39 :
{
ov39.o(.text)
ov39.o(.data)
ov39.o(.bss)
} > OV39
.ov40 :
{
ov40.o(.text)
ov40.o(.data)
ov40.o(.bss)
} > OV40
.ov41 :
{
ov41.o(.text)
ov41.o(.data)
ov41.o(.bss)
} > OV41
.ov42 :
{
ov42.o(.text)
ov42.o(.data)
ov42.o(.bss)
} > OV42
.ov43 :
{
ov43.o(.text)
ov43.o(.data)
ov43.o(.bss)
} > OV43
.ov44 :
{
ov44.o(.text)
ov44.o(.data)
ov44.o(.bss)
} > OV44
.ov45 :
{
ov45.o(.text)
ov45.o(.data)
ov45.o(.bss)
} > OV45
.ov46 :
{
ov46.o(.text)
ov46.o(.data)
ov46.o(.bss)
} > OV46
.ov47 :
{
ov47.o(.text)
ov47.o(.data)
ov47.o(.bss)
} > OV47
.ov48 :
{
ov48.o(.text)
ov48.o(.data)
ov48.o(.bss)
} > OV48
.ov49 :
{
ov49.o(.text)
ov49.o(.data)
ov49.o(.bss)
} > OV49
.ov50 :
{
ov50.o(.text)
ov50.o(.data)
ov50.o(.bss)
} > OV50
.ov51 :
{
ov51.o(.text)
ov51.o(.data)
ov51.o(.bss)
} > OV51
.ov52 :
{
ov52.o(.text)
ov52.o(.data)
ov52.o(.bss)
} > OV52
.ov53 :
{
ov53.o(.text)
ov53.o(.data)
ov53.o(.bss)
} > OV53
.ov54 :
{
ov54.o(.text)
ov54.o(.data)
ov54.o(.bss)
} > OV54
.ov55 :
{
ov55.o(.text)
ov55.o(.data)
ov55.o(.bss)
} > OV55
.ov56 :
{
ov56.o(.text)
ov56.o(.data)
ov56.o(.bss)
} > OV56
.ov57 :
{
ov57.o(.text)
ov57.o(.data)
ov57.o(.bss)
} > OV57
.ov58 :
{
ov58.o(.text)
ov58.o(.data)
ov58.o(.bss)
} > OV58
.ov59 :
{
ov59.o(.text)
ov59.o(.data)
ov59.o(.bss)
} > OV59
.ov60 :
{
ov60.o(.text)
ov60.o(.data)
ov60.o(.bss)
} > OV60
.ov61 :
{
ov61.o(.text)
ov61.o(.data)
ov61.o(.bss)
} > OV61
}
-190
View File
@@ -1,190 +0,0 @@
asm/main.o
asm/itcm.o
asm/dtcm.o
-og OV00,0 -ol OV00
asm/ov00.o
-og OV01,0 -ol OV00
asm/ov01.o
-og OV02,0 -ol OV00
asm/ov02.o
-og OV03,0 -ol OV00
asm/ov03.o
-og OV04,0 -ol OV00
asm/ov04.o
-og OV05,0 -ol OV00
asm/ov05.o
-og OV06,0 -ol OV00
asm/ov06.o
-og OV07,0 -ol OV00
asm/ov07.o
-og OV08,0 -ol OV00
asm/ov08.o
-og OV09,0 -ol OV00
asm/ov09.o
-og OV10,0 -ol OV00
asm/ov10.o
-og OV11,0 -ol OV00
asm/ov11.o
-og OV12,0 -ol OV00
asm/ov12.o
-og OV13,0 -ol OV00
asm/ov13.o
-og OV14,0 -ol OV00
asm/ov14.o
-og OV15,0 -ol OV00
asm/ov15.o
-og OV16,0 -ol OV00
asm/ov16.o
-og OV17,0 -ol OV00
asm/ov17.o
-og OV18,0 -ol OV00
asm/ov18.o
-og OV19,0 -ol OV00
asm/ov19.o
-og OV20,0 -ol OV00
asm/ov20.o
-og OV21,0 -ol OV00
asm/ov21.o
-og OV22,0 -ol OV00
asm/ov22.o
-og OV23,0 -ol OV00
asm/ov23.o
-og OV24,0 -ol OV00
asm/ov24.o
-og OV25,0 -ol OV00
asm/ov25.o
-og OV26,0 -ol OV00
asm/ov26.o
-og OV27,0 -ol OV00
asm/ov27.o
-og OV28,0 -ol OV00
asm/ov28.o
-og OV29,0 -ol OV00
asm/ov29.o
-og OV30,0 -ol OV00
asm/ov30.o
-og OV31,0 -ol OV00
asm/ov31.o
-og OV32,0 -ol OV00
asm/ov32.o
-og OV33,0 -ol OV00
asm/ov33.o
-og OV34,0 -ol OV00
asm/ov34.o
-og OV35,0 -ol OV00
asm/ov35.o
-og OV36,0 -ol OV00
asm/ov36.o
-og OV37,0 -ol OV00
asm/ov37.o
-og OV38,0 -ol OV00
asm/ov38.o
-og OV39,0 -ol OV00
asm/ov39.o
-og OV40,0 -ol OV00
asm/ov40.o
-og OV41,0 -ol OV00
asm/ov41.o
-og OV42,0 -ol OV00
asm/ov42.o
-og OV43,0 -ol OV00
asm/ov43.o
-og OV44,0 -ol OV00
asm/ov44.o
-og OV45,0 -ol OV00
asm/ov45.o
-og OV46,0 -ol OV00
asm/ov46.o
-og OV47,0 -ol OV00
asm/ov47.o
-og OV48,0 -ol OV00
asm/ov48.o
-og OV49,0 -ol OV00
asm/ov49.o
-og OV50,0 -ol OV00
asm/ov50.o
-og OV51,0 -ol OV00
asm/ov51.o
-og OV52,0 -ol OV00
asm/ov52.o
-og OV53,0 -ol OV00
asm/ov53.o
-og OV54,0 -ol OV00
asm/ov54.o
-og OV55,0 -ol OV00
asm/ov55.o
-og OV56,0 -ol OV00
asm/ov56.o
-og OV57,0 -ol OV00
asm/ov57.o
-og OV58,0 -ol OV00
asm/ov58.o
-og OV59,0 -ol OV00
asm/ov59.o
-og OV60,0 -ol OV00
asm/ov60.o
-og OV61,0 -ol OV00
asm/ov61.o
+304
View File
@@ -0,0 +1,304 @@
class Overlay:
def __init__(self, name: str = None, after = None, origin: int = None, objects: list[str] = None):
self.name = name
self.objects = objects
self.after = after
self.origin = origin
ARM9_OBJECTS = [
'main.o'
]
ITCM_OBJECTS = [
'itcm.o'
]
DTCM_OBJECTS = [
'dtcm.o'
]
ov00 = Overlay(name='ov00', origin=0x20773c0, objects=[
'ov00.o'
])
ov01 = Overlay(name='ov01', after=ov00, objects=[
'ov01.o'
])
ov02 = Overlay(name='ov02', after=ov00, objects=[
'ov02.o'
])
ov03 = Overlay(name='ov03', after=ov00, objects=[
'ov03.o'
])
ov04 = Overlay(name='ov04', after=ov03, objects=[
'ov04.o'
])
ov05 = Overlay(name='ov05', after=ov03, objects=[
'ov05.o'
])
ov06 = Overlay(name='ov06', after=ov03, objects=[
'ov06.o'
])
ov07 = Overlay(name='ov07', after=ov03, objects=[
'ov07.o'
])
ov08 = Overlay(name='ov08', after=ov05, objects=[
'ov08.o'
])
ov09 = Overlay(name='ov09', after=ov05, objects=[
'ov09.o'
])
ov10 = Overlay(name='ov10', after=ov05, objects=[
'ov10.o'
])
ov11 = Overlay(name='ov11', after=ov05, objects=[
'ov11.o'
])
ov12 = Overlay(name='ov12', after=ov05, objects=[
'ov12.o'
])
ov13 = Overlay(name='ov13', after=ov05, objects=[
'ov13.o'
])
ov14 = Overlay(name='ov14', after=ov09, objects=[
'ov14.o'
])
ov15 = Overlay(name='ov15', after=ov09, objects=[
'ov15.o'
])
ov16 = Overlay(name='ov16', after=ov09, objects=[
'ov16.o'
])
ov17 = Overlay(name='ov17', after=ov14, objects=[
'ov17.o'
])
ov18 = Overlay(name='ov18', after=ov14, objects=[
'ov18.o'
])
ov19 = Overlay(name='ov19', after=ov18, objects=[
'ov19.o'
])
ov20 = Overlay(name='ov20', after=ov18, objects=[
'ov20.o'
])
ov21 = Overlay(name='ov21', after=ov18, objects=[
'ov21.o'
])
ov22 = Overlay(name='ov22', after=ov18, objects=[
'ov22.o'
])
ov23 = Overlay(name='ov23', after=ov18, objects=[
'ov23.o'
])
ov24 = Overlay(name='ov24', after=ov18, objects=[
'ov24.o'
])
ov25 = Overlay(name='ov25', after=ov18, objects=[
'ov25.o'
])
ov26 = Overlay(name='ov26', after=ov18, objects=[
'ov26.o'
])
ov27 = Overlay(name='ov27', after=ov18, objects=[
'ov27.o'
])
ov28 = Overlay(name='ov28', after=ov18, objects=[
'ov28.o'
])
ov29 = Overlay(name='ov29', after=ov18, objects=[
'ov29.o'
])
ov30 = Overlay(name='ov30', after=ov29, objects=[
'ov30.o'
])
ov31 = Overlay(name='ov31', after=ov29, objects=[
'ov31.o'
])
ov32 = Overlay(name='ov32', after=ov29, objects=[
'ov32.o'
])
ov33 = Overlay(name='ov33', after=ov29, objects=[
'ov33.o'
])
ov34 = Overlay(name='ov34', after=ov29, objects=[
'ov34.o'
])
ov35 = Overlay(name='ov35', after=ov29, objects=[
'ov35.o'
])
ov36 = Overlay(name='ov36', after=ov29, objects=[
'ov36.o'
])
ov37 = Overlay(name='ov37', after=ov29, objects=[
'ov37.o'
])
ov38 = Overlay(name='ov38', after=ov29, objects=[
'ov38.o'
])
ov39 = Overlay(name='ov39', after=ov29, objects=[
'ov39.o'
])
ov40 = Overlay(name='ov40', after=ov29, objects=[
'ov40.o'
])
ov41 = Overlay(name='ov41', after=ov30, objects=[
'ov41.o'
])
ov42 = Overlay(name='ov42', after=ov30, objects=[
'ov42.o'
])
ov43 = Overlay(name='ov43', after=ov30, objects=[
'ov43.o'
])
ov44 = Overlay(name='ov44', after=ov30, objects=[
'ov44.o'
])
ov45 = Overlay(name='ov45', after=ov30, objects=[
'ov45.o'
])
ov46 = Overlay(name='ov46', after=ov44, objects=[
'ov46.o'
])
ov47 = Overlay(name='ov47', after=ov44, objects=[
'ov47.o'
])
ov48 = Overlay(name='ov48', after=ov44, objects=[
'ov48.o'
])
ov49 = Overlay(name='ov49', after=ov48, objects=[
'ov49.o'
])
ov50 = Overlay(name='ov50', after=ov48, objects=[
'ov50.o'
])
ov51 = Overlay(name='ov51', after=ov48, objects=[
'ov51.o'
])
ov52 = Overlay(name='ov52', after=ov48, objects=[
'ov52.o'
])
ov53 = Overlay(name='ov53', after=ov50, objects=[
'ov53.o'
])
ov54 = Overlay(name='ov54', after=ov50, objects=[
'ov54.o'
])
ov55 = Overlay(name='ov55', after=ov50, objects=[
'ov55.o'
])
ov56 = Overlay(name='ov56', after=ov50, objects=[
'ov56.o'
])
ov57 = Overlay(name='ov57', after=ov50, objects=[
'ov57.o'
])
ov58 = Overlay(name='ov58', after=ov50, objects=[
'ov58.o'
])
ov59 = Overlay(name='ov59', after=ov50, objects=[
'ov59.o'
])
ov60 = Overlay(name='ov60', after=ov12, objects=[
'ov60.o'
])
ov61 = Overlay(name='ov61', after=ov12, objects=[
'ov61.o'
])
OVERLAYS = [
ov00, ov01, ov02, ov03, ov04, ov05, ov06, ov07, ov08, ov09,
ov10, ov11, ov12, ov13, ov14, ov15, ov16, ov17, ov18, ov19,
ov20, ov21, ov22, ov23, ov24, ov25, ov26, ov27, ov28, ov29,
ov30, ov31, ov32, ov33, ov34, ov35, ov36, ov37, ov38, ov39,
ov40, ov41, ov42, ov43, ov44, ov45, ov46, ov47, ov48, ov49,
ov50, ov51, ov52, ov53, ov54, ov55, ov56, ov57, ov58, ov59,
ov60, ov61
]
BUILD = 'build/'
with open(f'{BUILD}arm9_linker_script.lcf', 'w') as file:
file.write('MEMORY {\n')
file.write(' ARM9 : ORIGIN = 0x2000000 > arm9.bin\n')
file.write(' ITCM : ORIGIN = 0x1ff8000 >> arm9.bin\n')
file.write(' DTCM : ORIGIN = 0x27e0000 >> arm9.bin\n')
file.write(' AUTOLOADS : ORIGIN = 0 >> arm9.bin\n')
file.write(' FOOTER : ORIGIN = 0 >> arm9.bin\n')
file.write('\n')
file.write(' OV_TABLE : ORIGIN = AFTER(ARM9) > arm9_ovt.bin\n')
file.write('\n')
for ov in OVERLAYS:
file.write(f' {ov.name} : ORIGIN = ')
if ov.origin is not None:
file.write(hex(ov.origin))
elif ov.after is not None:
file.write(f'AFTER({ov.after.name})')
file.write(f' > {ov.name}.bin\n')
file.write('}\n')
file.write('\n')
file.write('SECTIONS {\n')
file.write(' .arm9 : {\n')
for obj in ARM9_OBJECTS:
file.write(f' {obj}(.text)\n')
file.write(f' {obj}(.rodata)\n')
file.write(f' {obj}(.data)\n')
file.write(f' {obj}(.bss)\n')
file.write(' } > ARM9\n')
file.write('\n')
file.write(' .itcm : {\n')
for obj in ITCM_OBJECTS:
file.write(f' {obj}(.text)\n')
file.write(f' {obj}(.rodata)\n')
file.write(f' {obj}(.bss)\n')
file.write(' } > ITCM\n')
file.write('\n')
file.write(' .dtcm : {\n')
for obj in DTCM_OBJECTS:
file.write(f' {obj}(.data)\n')
file.write(f' {obj}(.bss)\n')
file.write(' } > DTCM\n')
file.write('\n')
for ov in OVERLAYS:
file.write(f' .{ov.name} : ' + '{\n')
file.write(f' {ov.name}_start = .;\n')
for obj in ov.objects: file.write(f' {obj}(.text)\n')
for obj in ov.objects: file.write(f' {obj}(.rodata)\n')
file.write('\n')
file.write(f' {ov.name}_sinit_start = .;\n')
for obj in ov.objects: file.write(f' {obj}(.sinit)\n')
file.write(f' {ov.name}_sinit_end = .;\n')
file.write('\n')
for obj in ov.objects: file.write(f' {obj}(.data)\n')
file.write(f' {ov.name}_end = .;\n')
file.write(f' {ov.name}_size = {ov.name}_end - {ov.name}_start;\n')
file.write('\n')
file.write(f' {ov.name}_bss_start = .;\n')
for obj in ov.objects: file.write(f' {obj}(.bss)\n')
file.write(f' {ov.name}_bss_end = .;\n')
file.write(f' {ov.name}_bss_size = {ov.name}_bss_end - {ov.name}_bss_start;\n')
file.write(' } > ' + ov.name + '\n')
file.write('\n')
file.write(' .arm9_ovt : {\n')
for (index, ov) in enumerate(OVERLAYS):
file.write(' ')
file.write(f'WRITEW {index}; ')
file.write(f'WRITEW {ov.name}_start; ')
file.write(f'WRITEW {ov.name}_size; ')
file.write(f'WRITEW {ov.name}_bss_size; ')
file.write(f'WRITEW {ov.name}_sinit_start; ')
file.write(f'WRITEW {ov.name}_sinit_end; ')
file.write('WRITEW 0; ') # file id will be inserted later
file.write('WRITEW 0; ') # compression flags, overlay is compressed later
file.write('\n')
file.write(' } > OV_TABLE\n')
file.write('}\n')
with open(f'{BUILD}arm9_objects.txt', 'w') as file:
DIR = 'asm/'
for obj in ARM9_OBJECTS: file.write(f'{DIR}{obj}\n')
for obj in ITCM_OBJECTS: file.write(f'{DIR}{obj}\n')
for obj in DTCM_OBJECTS: file.write(f'{DIR}{obj}\n')
file.write('\n')
for ov in OVERLAYS:
file.write(f'-og {ov.name},0 -ol {ov.name}\n')
for obj in ov.objects: file.write(f' {DIR}{obj}\n')
file.write('\n')