Skip to content

Commit

Permalink
Revert ld_script
Browse files Browse the repository at this point in the history
  • Loading branch information
GriffinRichards committed Sep 17, 2024
1 parent e5edb9b commit 247e787
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ ld_script_sapphire.txt
*.id2
*.nam
*.til
*.ld
tags
types_*.taghl
*.swp
Expand Down
21 changes: 10 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -370,24 +370,23 @@ $(foreach src, $(C_ASM_SRCS), $(eval $(call ASM_DEP_PREPROC,$(src:%.s=$(OBJ_DIR)
$(foreach src, $(REGULAR_DATA_ASM_SRCS), $(eval $(call ASM_DEP_PREPROC,$(src:%.s=$(OBJ_DIR)/%),$(src))))
endif

$(OBJ_DIR)/sym_%.ld: sym_%.txt
$(CPP) -P $(CPPFLAGS) $< | sed -e "s#tools/#../../tools/#g" > $@

# Linker script
ifeq ($(MODERN),0)
LD_SCRIPT := ld_script.ld
LD_SCRIPT_DEPS := $(OBJ_DIR)/sym_bss.ld $(OBJ_DIR)/sym_common.ld $(OBJ_DIR)/sym_ewram.ld
LD_SCRIPT := $(OBJ_DIR)/ld_script.ld
else
LD_SCRIPT := ld_script_modern.ld
LD_SCRIPT_DEPS :=
LD_SCRIPT := $(OBJ_DIR)/ld_script_modern.ld
endif

# Final rules
$(LD_SCRIPT): $(LD_SCRIPT:$(OBJ_DIR)/%.ld=%.txt) $(OBJ_DIR)/sym_common.ld $(OBJ_DIR)/sym_ewram.ld $(OBJ_DIR)/sym_bss.ld
sed -e "s#tools/#../../tools/#g" $< >$@
$(OBJ_DIR)/sym_%.ld: sym_%.txt
$(CPP) -P $(CPPFLAGS) $< | sed -e "s#tools/#../../tools/#g" > $@

# Elf from object files
$(ELF): $(LD_SCRIPT) $(LD_SCRIPT_DEPS) $(OBJS)
@cd $(OBJ_DIR) && $(LD) $(LDFLAGS) -T ../../$< --print-memory-usage -o ../../$@ $(OBJS_REL) $(LIB) | cat
$(FIX) $@ -t"$(TITLE)" -c$(GAME_CODE) -m$(MAKER_CODE) -r$(GAME_REVISION) --silent
$(ELF): $(LD_SCRIPT) $(OBJS)
@echo "cd $(OBJ_DIR) && $(LD) -T $(LD_SCRIPT:$(OBJ_DIR)/%=%) -Map ../../$(MAP) -o ../../$@ <objects> <lib>"
@cd $(OBJ_DIR) && $(LD) -T $(LD_SCRIPT:$(OBJ_DIR)/%=%) -Map ../../$(MAP) -o ../../$@ $(OBJS_REL) $(LIB)
$(FIX) $@ -p -t"$(TITLE)" -c$(GAME_CODE) -m$(MAKER_CODE) -r$(GAME_REVISION) --silent

$(ROM): $(ELF)
$(OBJCOPY) -O binary --gap-fill 0xFF --pad-to 0x9000000 $< $@
Expand Down
File renamed without changes.
File renamed without changes.

0 comments on commit 247e787

Please sign in to comment.