1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2024-11-13 04:39:36 +00:00

New relocation-generating program (#1016)

* Update makefiles

* git subrepo clone git@github.com:EllipticEllipsis/fado.git tools/fado

subrepo:
  subdir:   "tools/fado"
  merged:   "46c4d751a"
upstream:
  origin:   "git@github.com:EllipticEllipsis/fado.git"
  branch:   "master"
  commit:   "46c4d751a"
git-subrepo:
  version:  "0.4.3"
  origin:   "https://github.com/ingydotnet/git-subrepo.git"
  commit:   "2f68596"

* git subrepo pull tools/fado

subrepo:
  subdir:   "tools/fado"
  merged:   "88114ebce"
upstream:
  origin:   "git@github.com:EllipticEllipsis/fado.git"
  branch:   "master"
  commit:   "88114ebce"
git-subrepo:
  version:  "0.4.3"
  origin:   "https://github.com/ingydotnet/git-subrepo.git"
  commit:   "2f68596"

* A few ideas for computing dependencies

* Remove reserved identifiers from spec.h and util.h
and add required headers

* Fix a couple more headers

* Program for reloc prerequisites

* git subrepo pull tools/fado

subrepo:
  subdir:   "tools/fado"
  merged:   "36a905f72"
upstream:
  origin:   "git@github.com:EllipticEllipsis/fado.git"
  branch:   "master"
  commit:   "36a905f72"
git-subrepo:
  version:  "0.4.3"
  origin:   "https://github.com/ingydotnet/git-subrepo.git"
  commit:   "2f68596"

* Update makefile to make dependency files and use overlay's name

* git subrepo pull tools/fado

subrepo:
  subdir:   "tools/fado"
  merged:   "43c339a59"
upstream:
  origin:   "git@github.com:EllipticEllipsis/fado.git"
  branch:   "master"
  commit:   "43c339a59"
git-subrepo:
  version:  "0.4.3"
  origin:   "https://github.com/ingydotnet/git-subrepo.git"
  commit:   "2f68596"

* Change awk to grep, delete ZAPD files, gitignore elf

* Delete all the cfg files

* Fix memory leaks

* Rename and add coloured errors

* Makefile tweaks
- preprocess spec before grep
- split order prerequisites via phony target to reduce dependency edges
- remove `resources` target
- remove separate overlays targets
- use `$(SPEC)` throughout
- change to using filenames of relocs for overlay names via `$*`
- Rearrange targets to better reflect their categories

* Update gitignore

* Review

* Add a check for the reloc file name

* get_segment_by_name

* get_stmt_id_by_stmt_name

* Cleaning up

* algorithm change

* function rename

* Fix typos

Co-authored-by: angie <angheloalf95@gmail.com>
This commit is contained in:
EllipticEllipsis 2022-02-06 19:40:26 +00:00 committed by GitHub
parent cf048f849a
commit eadc477187
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
511 changed files with 3947 additions and 1104 deletions

View file

@ -78,6 +78,7 @@ MKLDSCRIPT := tools/mkldscript
MKDMADATA := tools/mkdmadata
ELF2ROM := tools/elf2rom
ZAPD := tools/ZAPD/ZAPD.out
FADO := tools/fado/fado.elf
OPTFLAGS := -O2
ASFLAGS := -march=vr4300 -32 -Iinclude
@ -118,9 +119,12 @@ O_FILES := $(foreach f,$(S_FILES:.s=.o),build/$f) \
$(foreach f,$(C_FILES:.c=.o),build/$f) \
$(foreach f,$(wildcard baserom/*),build/$f.o)
OVL_RELOC_FILES := $(shell $(CPP) $(CPPFLAGS) $(SPEC) | grep -o '[^"]*_reloc.o' )
# Automatic dependency files
# (Only asm_processor dependencies are handled for now)
DEP_FILES := $(O_FILES:.o=.asmproc.d)
# (Only asm_processor dependencies and reloc dependencies are handled for now)
DEP_FILES := $(O_FILES:.o=.asmproc.d) $(OVL_RELOC_FILES:.o=.d)
TEXTURE_FILES_PNG := $(foreach dir,$(ASSET_BIN_DIRS),$(wildcard $(dir)/*.png))
TEXTURE_FILES_JPG := $(foreach dir,$(ASSET_BIN_DIRS),$(wildcard $(dir)/*.jpg))
@ -177,21 +181,6 @@ ifeq ($(COMPARE),1)
@md5sum -c checksum.md5
endif
$(ROM): $(ELF)
$(ELF2ROM) -cic 6105 $< $@
$(ELF): $(TEXTURE_FILES_OUT) $(ASSET_FILES_OUT) $(O_FILES) build/ldscript.txt build/undefined_syms.txt
$(LD) -T build/undefined_syms.txt -T build/ldscript.txt --no-check-sections --accept-unknown-input-arch --emit-relocs -Map build/z64.map -o $@
build/$(SPEC): $(SPEC)
$(CPP) $(CPPFLAGS) $< > $@
build/ldscript.txt: build/$(SPEC)
$(MKLDSCRIPT) $< $@
build/undefined_syms.txt: undefined_syms.txt
$(CPP) $(CPPFLAGS) $< > build/undefined_syms.txt
clean:
$(RM) -r $(ROM) $(ELF) build
@ -211,14 +200,42 @@ setup:
python3 extract_baserom.py
python3 extract_assets.py -j$(N_THREADS)
resources: $(ASSET_FILES_OUT)
test: $(ROM)
$(EMULATOR) $(EMU_FLAGS) $<
.PHONY: all clean setup test distclean assetclean
#### Various Recipes ####
$(ROM): $(ELF)
$(ELF2ROM) -cic 6105 $< $@
$(ELF): $(TEXTURE_FILES_OUT) $(ASSET_FILES_OUT) $(O_FILES) $(OVL_RELOC_FILES) build/ldscript.txt build/undefined_syms.txt
$(LD) -T build/undefined_syms.txt -T build/ldscript.txt --no-check-sections --accept-unknown-input-arch --emit-relocs -Map build/z64.map -o $@
## Order-only prerequisites
# These ensure e.g. the O_FILES are built before the OVL_RELOC_FILES.
# The intermediate phony targets avoid quadratically-many dependencies between the targets and prerequisites.
o_files: $(O_FILES)
$(OVL_RELOC_FILES): | o_files
asset_files: $(TEXTURE_FILES_OUT) $(ASSET_FILES_OUT)
$(O_FILES): | asset_files
.PHONY: o_files asset_files
build/$(SPEC): $(SPEC)
$(CPP) $(CPPFLAGS) $< > $@
build/ldscript.txt: build/$(SPEC)
$(MKLDSCRIPT) $< $@
build/undefined_syms.txt: undefined_syms.txt
$(CPP) $(CPPFLAGS) $< > $@
build/baserom/%.o: baserom/%
$(OBJCOPY) -I binary -O elf32-big $< $@
@ -226,7 +243,7 @@ build/asm/%.o: asm/%.s
$(AS) $(ASFLAGS) $< -o $@
build/data/%.o: data/%.s
iconv --from UTF-8 --to EUC-JP $< | $(AS) $(ASFLAGS) -o $@
$(AS) $(ASFLAGS) $< -o $@
build/assets/text/%.enc.h: assets/text/%.h assets/text/charmap.txt
python3 tools/msgenc.py assets/text/charmap.txt $< $@
@ -246,13 +263,6 @@ build/dmadata_table_spec.h: build/$(SPEC)
build/src/boot/z_std_dma.o: build/dmadata_table_spec.h
build/src/dmadata/dmadata.o: build/dmadata_table_spec.h
build/src/overlays/%.o: src/overlays/%.c
$(CC) -c $(CFLAGS) $(MIPS_VERSION) $(OPTFLAGS) -o $@ $<
$(CC_CHECK) $<
$(ZAPD) bovl -eh -i $@ -cfg $< --outputpath $(@D)/$(notdir $(@D))_reloc.s
-test -f $(@D)/$(notdir $(@D))_reloc.s && $(AS) $(ASFLAGS) $(@D)/$(notdir $(@D))_reloc.s -o $(@D)/$(notdir $(@D))_reloc.o
@$(OBJDUMP) -d $@ > $(@:.o=.s)
build/src/%.o: src/%.c
$(CC) -c $(CFLAGS) $(MIPS_VERSION) $(OPTFLAGS) -o $@ $<
$(CC_CHECK) $<
@ -270,6 +280,10 @@ build/src/libultra/libc/llcvt.o: src/libultra/libc/llcvt.c
python3 tools/set_o32abi_bit.py $@
@$(OBJDUMP) -d $@ > $(@:.o=.s)
build/src/overlays/%_reloc.o: build/$(SPEC)
$(FADO) $$(tools/reloc_prereq $< $(notdir $*)) -n $(notdir $*) -o $(@:.o=.s) -M $(@:.o=.d)
$(AS) $(ASFLAGS) $(@:.o=.s) -o $@
build/%.inc.c: %.png
$(ZAPD) btex -eh -tt $(subst .,,$(suffix $*)) -i $< -o $@

View file

@ -1,2 +0,0 @@
ovl_Arms_Hook
z_arms_hook.c

View file

@ -1,2 +0,0 @@
ovl_Arrow_Fire
z_arrow_fire.c

View file

@ -1,2 +0,0 @@
ovl_Arrow_Ice
z_arrow_ice.c

View file

@ -1,2 +0,0 @@
ovl_Arrow_Light
z_arrow_light.c

View file

@ -1,2 +0,0 @@
ovl_Bg_Bdan_Objects
z_bg_bdan_objects.c

View file

@ -1,2 +0,0 @@
ovl_Bg_Bdan_Switch
z_bg_bdan_switch.c

View file

@ -1,2 +0,0 @@
ovl_Bg_Bom_Guard
z_bg_bom_guard.c

View file

@ -1,2 +0,0 @@
ovl_Bg_Bombwall
z_bg_bombwall.c

View file

@ -1,2 +0,0 @@
ovl_Bg_Bowl_Wall
z_bg_bowl_wall.c

View file

@ -1,2 +0,0 @@
ovl_Bg_Breakwall
z_bg_breakwall.c

View file

@ -1,2 +0,0 @@
ovl_Bg_Ddan_Jd
z_bg_ddan_jd.c

View file

@ -1,2 +0,0 @@
ovl_Bg_Ddan_Kd
z_bg_ddan_kd.c

View file

@ -1,2 +0,0 @@
ovl_Bg_Dodoago
z_bg_dodoago.c

View file

@ -1,2 +0,0 @@
ovl_Bg_Dy_Yoseizo
z_bg_dy_yoseizo.c

View file

@ -1,2 +0,0 @@
ovl_Bg_Ganon_Otyuka
z_bg_ganon_otyuka.c

View file

@ -1,2 +0,0 @@
ovl_Bg_Gate_Shutter
z_bg_gate_shutter.c

View file

@ -1,2 +0,0 @@
ovl_Bg_Gjyo_Bridge
z_bg_gjyo_bridge.c

View file

@ -1,2 +0,0 @@
ovl_Bg_Gnd_Darkmeiro
z_bg_gnd_darkmeiro.c

View file

@ -1,2 +0,0 @@
ovl_Bg_Gnd_Firemeiro
z_bg_gnd_firemeiro.c

View file

@ -1,2 +0,0 @@
ovl_Bg_Gnd_Iceblock
z_bg_gnd_iceblock.c

View file

@ -1,2 +0,0 @@
ovl_Bg_Gnd_Nisekabe
z_bg_gnd_nisekabe.c

View file

@ -1,2 +0,0 @@
ovl_Bg_Gnd_Soulmeiro
z_bg_gnd_soulmeiro.c

View file

@ -1,2 +0,0 @@
ovl_Bg_Haka
z_bg_haka.c

View file

@ -1,2 +0,0 @@
ovl_Bg_Haka_Gate
z_bg_haka_gate.c

View file

@ -1,2 +0,0 @@
ovl_Bg_Haka_Huta
z_bg_haka_huta.c

View file

@ -1,2 +0,0 @@
ovl_Bg_Haka_Megane
z_bg_haka_megane.c

View file

@ -1,2 +0,0 @@
ovl_Bg_Haka_MeganeBG
z_bg_haka_meganebg.c

View file

@ -1,2 +0,0 @@
ovl_Bg_Haka_Sgami
z_bg_haka_sgami.c

View file

@ -1,2 +0,0 @@
ovl_Bg_Haka_Ship
z_bg_haka_ship.c

View file

@ -1,2 +0,0 @@
ovl_Bg_Haka_Trap
z_bg_haka_trap.c

View file

@ -1,2 +0,0 @@
ovl_Bg_Haka_Tubo
z_bg_haka_tubo.c

View file

@ -1,2 +0,0 @@
ovl_Bg_Haka_Water
z_bg_haka_water.c

View file

@ -1,2 +0,0 @@
ovl_Bg_Haka_Zou
z_bg_haka_zou.c

View file

@ -1,2 +0,0 @@
ovl_Bg_Heavy_Block
z_bg_heavy_block.c

View file

@ -1,2 +0,0 @@
ovl_Bg_Hidan_Curtain
z_bg_hidan_curtain.c

View file

@ -1,2 +0,0 @@
ovl_Bg_Hidan_Dalm
z_bg_hidan_dalm.c

View file

@ -1,2 +0,0 @@
ovl_Bg_Hidan_Firewall
z_bg_hidan_firewall.c

View file

@ -1,2 +0,0 @@
ovl_Bg_Hidan_Fslift
z_bg_hidan_fslift.c

View file

@ -1,2 +0,0 @@
ovl_Bg_Hidan_Fwbig
z_bg_hidan_fwbig.c

View file

@ -1,2 +0,0 @@
ovl_Bg_Hidan_Hamstep
z_bg_hidan_hamstep.c

View file

@ -1,2 +0,0 @@
ovl_Bg_Hidan_Hrock
z_bg_hidan_hrock.c

View file

@ -1,2 +0,0 @@
ovl_Bg_Hidan_Kousi
z_bg_hidan_kousi.c

View file

@ -1,2 +0,0 @@
ovl_Bg_Hidan_Kowarerukabe
z_bg_hidan_kowarerukabe.c

View file

@ -1,2 +0,0 @@
ovl_Bg_Hidan_Rock
z_bg_hidan_rock.c

View file

@ -1,2 +0,0 @@
ovl_Bg_Hidan_Rsekizou
z_bg_hidan_rsekizou.c

View file

@ -1,2 +0,0 @@
ovl_Bg_Hidan_Sekizou
z_bg_hidan_sekizou.c

View file

@ -1,2 +0,0 @@
ovl_Bg_Hidan_Sima
z_bg_hidan_sima.c

View file

@ -1,2 +0,0 @@
ovl_Bg_Hidan_Syoku
z_bg_hidan_syoku.c

View file

@ -1,2 +0,0 @@
ovl_Bg_Ice_Objects
z_bg_ice_objects.c

View file

@ -1,2 +0,0 @@
ovl_Bg_Ice_Shelter
z_bg_ice_shelter.c

View file

@ -1,2 +0,0 @@
ovl_Bg_Ice_Shutter
z_bg_ice_shutter.c

View file

@ -1,2 +0,0 @@
ovl_Bg_Ice_Turara
z_bg_ice_turara.c

View file

@ -1,2 +0,0 @@
ovl_Bg_Ingate
z_bg_ingate.c

View file

@ -1,2 +0,0 @@
ovl_Bg_Jya_1flift
z_bg_jya_1flift.c

View file

@ -1,2 +0,0 @@
ovl_Bg_Jya_Amishutter
z_bg_jya_amishutter.c

View file

@ -1,2 +0,0 @@
ovl_Bg_Jya_Bigmirror
z_bg_jya_bigmirror.c

View file

@ -1,2 +0,0 @@
ovl_Bg_Jya_Block
z_bg_jya_block.c

View file

@ -1,2 +0,0 @@
ovl_Bg_Jya_Bombchuiwa
z_bg_jya_bombchuiwa.c

View file

@ -1,2 +0,0 @@
ovl_Bg_Jya_Bombiwa
z_bg_jya_bombiwa.c

View file

@ -1,2 +0,0 @@
ovl_Bg_Jya_Cobra
z_bg_jya_cobra.c

View file

@ -1,2 +0,0 @@
ovl_Bg_Jya_Goroiwa
z_bg_jya_goroiwa.c

View file

@ -1,2 +0,0 @@
ovl_Bg_Jya_Haheniron
z_bg_jya_haheniron.c

View file

@ -1,2 +0,0 @@
ovl_Bg_Jya_Ironobj
z_bg_jya_ironobj.c

View file

@ -1,2 +0,0 @@
ovl_Bg_Jya_Kanaami
z_bg_jya_kanaami.c

View file

@ -1,2 +0,0 @@
ovl_Bg_Jya_Lift
z_bg_jya_lift.c

View file

@ -1,2 +0,0 @@
ovl_Bg_Jya_Megami
z_bg_jya_megami.c

View file

@ -1,2 +0,0 @@
ovl_Bg_Jya_Zurerukabe
z_bg_jya_zurerukabe.c

View file

@ -1,2 +0,0 @@
ovl_Bg_Menkuri_Eye
z_bg_menkuri_eye.c

View file

@ -1,2 +0,0 @@
ovl_Bg_Menkuri_Kaiten
z_bg_menkuri_kaiten.c

View file

@ -1,2 +0,0 @@
ovl_Bg_Menkuri_Nisekabe
z_bg_menkuri_nisekabe.c

View file

@ -1,2 +0,0 @@
ovl_Bg_Mizu_Bwall
z_bg_mizu_bwall.c

View file

@ -1,2 +0,0 @@
ovl_Bg_Mizu_Movebg
z_bg_mizu_movebg.c

View file

@ -1,2 +0,0 @@
ovl_Bg_Mizu_Shutter
z_bg_mizu_shutter.c

View file

@ -1,2 +0,0 @@
ovl_Bg_Mizu_Uzu
z_bg_mizu_uzu.c

View file

@ -1,2 +0,0 @@
ovl_Bg_Mizu_Water
z_bg_mizu_water.c

View file

@ -1,2 +0,0 @@
ovl_Bg_Mjin
z_bg_mjin.c

View file

@ -1,2 +0,0 @@
ovl_Bg_Mori_Bigst
z_bg_mori_bigst.c

View file

@ -1,2 +0,0 @@
ovl_Bg_Mori_Elevator
z_bg_mori_elevator.c

View file

@ -1,2 +0,0 @@
ovl_Bg_Mori_Hashigo
z_bg_mori_hashigo.c

View file

@ -1,2 +0,0 @@
ovl_Bg_Mori_Hashira4
z_bg_mori_hashira4.c

View file

@ -1,2 +0,0 @@
ovl_Bg_Mori_Hineri
z_bg_mori_hineri.c

View file

@ -1,2 +0,0 @@
ovl_Bg_Mori_Idomizu
z_bg_mori_idomizu.c

View file

@ -1,2 +0,0 @@
ovl_Bg_Mori_Kaitenkabe
z_bg_mori_kaitenkabe.c

View file

@ -1,2 +0,0 @@
ovl_Bg_Mori_Rakkatenjo
z_bg_mori_rakkatenjo.c

View file

@ -1,2 +0,0 @@
ovl_Bg_Po_Event
z_bg_po_event.c

View file

@ -1,2 +0,0 @@
ovl_Bg_Po_Syokudai
z_bg_po_syokudai.c

View file

@ -1,2 +0,0 @@
ovl_Bg_Pushbox
z_bg_pushbox.c

View file

@ -1,2 +0,0 @@
ovl_Bg_Relay_Objects
z_bg_relay_objects.c

View file

@ -1,2 +0,0 @@
ovl_Bg_Spot00_Break
z_bg_spot00_break.c

View file

@ -1,2 +0,0 @@
ovl_Bg_Spot00_Hanebasi
z_bg_spot00_hanebasi.c

View file

@ -1,2 +0,0 @@
ovl_Bg_Spot01_Fusya
z_bg_spot01_fusya.c

View file

@ -1,2 +0,0 @@
ovl_Bg_Spot01_Idohashira
z_bg_spot01_idohashira.c

View file

@ -1,2 +0,0 @@
ovl_Bg_Spot01_Idomizu
z_bg_spot01_idomizu.c

View file

@ -1,2 +0,0 @@
ovl_Bg_Spot01_Idosoko
z_bg_spot01_idosoko.c

View file

@ -1,2 +0,0 @@
ovl_Bg_Spot01_Objects2
z_bg_spot01_objects2.c

View file

@ -1,2 +0,0 @@
ovl_Bg_Spot02_Objects
z_bg_spot02_objects.c

View file

@ -1,2 +0,0 @@
ovl_Bg_Spot03_Taki
z_bg_spot03_taki.c

View file

@ -1,2 +0,0 @@
ovl_Bg_Spot05_Soko
z_bg_spot05_soko.c

View file

@ -1,2 +0,0 @@
ovl_Bg_Spot06_Objects
z_bg_spot06_objects.c

Some files were not shown because too many files have changed in this diff Show more