From 684db78a6b6868a6ac77ab2f92988c0bd7a97b1a Mon Sep 17 00:00:00 2001 From: red031000 Date: Thu, 27 Jul 2023 06:17:59 +0100 Subject: [PATCH] compile with debugging info so gdb can be attached --- .github/calcrom/BuildAnalyzer.cpp | 28 ++++++++++++++-------------- Makefile | 6 +++--- arm7/Makefile | 8 ++++---- arm9/Makefile | 12 ++++++------ arm9/lib/MSL_C/Makefile | 6 +++--- arm9/lib/Makefile | 6 +++--- arm9/lib/NitroSDK/Makefile | 6 +++--- arm9/lib/libnns/Makefile | 6 +++--- rom.rsf | 4 ++-- 9 files changed, 41 insertions(+), 41 deletions(-) diff --git a/.github/calcrom/BuildAnalyzer.cpp b/.github/calcrom/BuildAnalyzer.cpp index ac20df549..9aabc8ab5 100644 --- a/.github/calcrom/BuildAnalyzer.cpp +++ b/.github/calcrom/BuildAnalyzer.cpp @@ -28,29 +28,29 @@ void BuildAnalyzer::AnalyzeObject(path fname_s) { if (sectionType != SECTION_OTHER) { sizes[sectionType][sourceType] += (hdr.sh_size + 3) & ~3; auto data = elf.ReadSectionData(hdr); -//#ifndef NDEBUG -// unordered_set unique_addrs; -//#endif +#ifndef NDEBUG + unordered_set unique_addrs; +#endif for (const auto & word : data) { if (word == 0) { continue; // might be a relocation } if (find_if(program.GetProgramHeaders().cbegin(), program.GetProgramHeaders().cend(), [&word](const auto & phdr) { return phdr.p_vaddr <= word && word < phdr.p_vaddr + phdr.p_memsz; - }) != program.GetProgramHeaders().cend()) { -//#ifndef NDEBUG -// unique_addrs.insert(word); -//#endif + }) != program.GetProgramHeaders().cend() && word > 0x01000000) { +#ifndef NDEBUG + unique_addrs.insert(word); +#endif n_hardcoded++; } } -//#ifndef NDEBUG -// if (!version.empty()) { -// for (const auto & word : unique_addrs) { -// cerr << "hardcoded " << version << " pointer to " << hex << word << endl; -// } -// } -//#endif +#ifndef NDEBUG + if (!version.empty()) { + for (const auto & word : unique_addrs) { + cerr << "hardcoded " << version << " pointer to " << hex << word << endl; + } + } +#endif } else if (hdr.sh_type == SHT_RELA) { n_relocations += elf.GetSectionElementCount(hdr); } diff --git a/Makefile b/Makefile index 9cec59d86..603a1f86d 100644 --- a/Makefile +++ b/Makefile @@ -103,9 +103,9 @@ OBJDUMP := $(CROSS)objdump OBJCOPY := $(CROSS)objcopy # ./tools/mwccarm/2.0/base/mwasmarm.exe -proc arm5te asm/arm9_thumb.s -o arm9.o -MWASFLAGS = -proc arm5te -MWCFLAGS = -O4,p -gccext,on -proc arm946e -msgstyle gcc -gccinc -ipa file -fp soft -lang c99 -Cpp_exceptions off -inline on,noauto -i include -ir include-mw -ir arm9/lib/MSL_C/include -ir arm9/lib/libnns/include -ir arm9/lib/NitroSDK/include -interworking -DFS_IMPLEMENT -enum int -D$(GAME_VERSION) -D$(GAME_LANGUAGE) -W all -W pedantic -W noimpl_signedunsigned -W noimplicitconv -W nounusedarg -W nomissingreturn -W error -MWLDFLAGS = -map -nodead -w off -proc v5te -interworking -map -symtab -m _start -msgstyle gcc +MWASFLAGS = -proc arm5te -g +MWCFLAGS = -O4,p -sym on -gccext,on -proc arm946e -msgstyle gcc -gccinc -ipa file -fp soft -lang c99 -Cpp_exceptions off -inline on,noauto -i include -ir include-mw -ir arm9/lib/MSL_C/include -ir arm9/lib/libnns/include -ir arm9/lib/NitroSDK/include -interworking -DFS_IMPLEMENT -enum int -D$(GAME_VERSION) -D$(GAME_LANGUAGE) -W all -W pedantic -W noimpl_signedunsigned -W noimplicitconv -W nounusedarg -W nomissingreturn -W error +MWLDFLAGS = -map -sym on -nodead -w off -proc v5te -interworking -map -symtab -m _start -msgstyle gcc ####################### Other Tools ######################### diff --git a/arm7/Makefile b/arm7/Makefile index 1575ab40a..832c38add 100644 --- a/arm7/Makefile +++ b/arm7/Makefile @@ -96,9 +96,9 @@ OBJDUMP := $(CROSS)objdump OBJCOPY := $(CROSS)objcopy # ./tools/mwccarm/2.0/base/mwasmarm.exe -proc arm5te asm/arm7_thumb.s -o arm7.o -MWASFLAGS = -proc arm4t -i .. -MWCFLAGS = -O4,s -proc arm7tdmi -msgstyle gcc -gccinc -fp soft -lang c99 -Cpp_exceptions off -inline on,noauto -i ../include -ir ../include-mw -ir lib/include -interworking -DFS_IMPLEMENT -enum int -W all -W pedantic -W noimpl_signedunsigned -W noimplicitconv -W nounusedarg -W nomissingreturn -W error -MWLDFLAGS = -map -nodead -w off -proc v4t -interworking -map -symtab -m _start -msgstyle gcc +MWASFLAGS = -proc arm4t -g -i .. +MWCFLAGS = -O4,s -sym on -proc arm7tdmi -msgstyle gcc -gccinc -fp soft -lang c99 -Cpp_exceptions off -inline on,noauto -i ../include -ir ../include-mw -ir lib/include -interworking -DFS_IMPLEMENT -enum int -W all -W pedantic -W noimpl_signedunsigned -W noimplicitconv -W nounusedarg -W nomissingreturn -W error +MWLDFLAGS = -map -sym on -nodead -w off -proc v4t -interworking -map -symtab -m _start -msgstyle gcc ####################### Other Tools ######################### @@ -194,7 +194,7 @@ $(BUILD_DIR)/$(LD_SCRIPT): $(LD_SPEC) $(LD_TEMPLATE) $(ROM): $(O_FILES) $(BUILD_DIR)/$(LD_SCRIPT) $(BIN_FILES) echo "$(O_FILES) $(BIN_FILES)" > $(ELF).objlist $(LD) $(MWLDFLAGS) $(BUILD_DIR)/$(LD_SCRIPT) -o $(ELF) @$(ELF).objlist - $(OBJCOPY) --update-section arm7=$@ -j arm7 $(foreach ov,$(OVERLAYS),--update-section $(ov)=$(BUILD_DIR)/$(ov).sbin -j $(ov)) $(ELF) 2>/dev/null +# $(OBJCOPY) --update-section arm7=$@ -j arm7 $(foreach ov,$(OVERLAYS),--update-section $(ov)=$(BUILD_DIR)/$(ov).sbin -j $(ov)) $(ELF) 2>/dev/null # Make sure build directory exists before compiling anything DUMMY := $(shell mkdir -p $(ALL_DIRS)) diff --git a/arm9/Makefile b/arm9/Makefile index b9d9f44da..92210a212 100644 --- a/arm9/Makefile +++ b/arm9/Makefile @@ -116,10 +116,10 @@ ASM_PROCESSOR_DIR := ../tools/asm_processor ASM_PROCESSOR := $(ASM_PROCESSOR_DIR)/compile.sh # ./tools/mwccarm/2.0/base/mwasmarm.exe -proc arm5te asm/arm9_thumb.s -o arm9.o -MWASFLAGS = -proc arm5te -i ../include -i .. -D$(GAME_VERSION) -D$(GAME_LANGUAGE) -MWCFLAGS = -O4,p -gccext,on -proc arm946e -msgstyle gcc -gccinc -ipa file -fp soft -lang c99 -Cpp_exceptions off -inline on,noauto $(foreach dir,$(INCLUDE_DIRS),-i $(dir)) $(foreach dir,$(INCLUDE_RECURSIVE_DIRS),-ir $(dir)) -interworking -DFS_IMPLEMENT -enum int -D$(GAME_VERSION) -D$(GAME_LANGUAGE) -W all -W pedantic -W noimpl_signedunsigned -W noimplicitconv -W nounusedarg -W nomissingreturn -W error -MWCXXFLAGS = -O4,p -proc arm946e -msgstyle gcc -gccinc -fp soft -lang c99 -Cpp_exceptions off -inline on,noauto $(foreach dir,$(INCLUDE_DIRS),-i $(dir)) $(foreach dir,$(INCLUDE_RECURSIVE_DIRS),-ir $(dir)) -interworking -DFS_IMPLEMENT -enum int -D$(GAME_VERSION) -D$(GAME_LANGUAGE) -W all -W pedantic -W noimpl_signedunsigned -W noimplicitconv -W nounusedarg -W nomissingreturn -W error -MWLDFLAGS = -w off -proc v5te -interworking -map closure,unused -symtab sort -m _start -msgstyle gcc +MWASFLAGS = -proc arm5te -g -i ../include -i .. -D$(GAME_VERSION) -D$(GAME_LANGUAGE) +MWCFLAGS = -O4,p -sym on -gccext,on -proc arm946e -msgstyle gcc -gccinc -ipa file -fp soft -lang c99 -Cpp_exceptions off -inline on,noauto $(foreach dir,$(INCLUDE_DIRS),-i $(dir)) $(foreach dir,$(INCLUDE_RECURSIVE_DIRS),-ir $(dir)) -interworking -DFS_IMPLEMENT -enum int -D$(GAME_VERSION) -D$(GAME_LANGUAGE) -W all -W pedantic -W noimpl_signedunsigned -W noimplicitconv -W nounusedarg -W nomissingreturn -W error +MWCXXFLAGS = -O4,p -sym on -proc arm946e -msgstyle gcc -gccinc -fp soft -lang c99 -Cpp_exceptions off -inline on,noauto $(foreach dir,$(INCLUDE_DIRS),-i $(dir)) $(foreach dir,$(INCLUDE_RECURSIVE_DIRS),-ir $(dir)) -interworking -DFS_IMPLEMENT -enum int -D$(GAME_VERSION) -D$(GAME_LANGUAGE) -W all -W pedantic -W noimpl_signedunsigned -W noimplicitconv -W nounusedarg -W nomissingreturn -W error +MWLDFLAGS = -w off -sym on -proc v5te -interworking -map closure,unused -symtab sort -m _start -msgstyle gcc LIBS := -Llib -lsyscall ARFLAGS = rcS STATIC_LIBS := $(addprefix $(BUILD_DIR)/lib/,libsyscall.a) @@ -204,7 +204,7 @@ ALL_DIRS := $(BUILD_DIR) $(addprefix $(BUILD_DIR)/,$(SRC_DIRS) $(ASM_DIRS) $(LIB # TODO: Move out to lib/Makefile $(BUILD_DIR)/lib/%.o: MWCCVERSION = 1.2/sp2p3 -$(BUILD_DIR)/lib/%.o: MWCFLAGS = -O4,p -gccext,on -proc arm946e -msgstyle gcc -gccinc -fp soft -lang c99 -Cpp_exceptions off -inline on,noauto -i ../include -ir ../include-mw -ir lib/MSL_C/include -ir lib/libnns/include -ir lib/NitroSDK/include -interworking -DFS_IMPLEMENT -enum int -D$(GAME_VERSION) -D$(GAME_LANGUAGE) -W all -W pedantic -W noimpl_signedunsigned -W noimplicitconv -W nounusedarg -W nomissingreturn -W error +$(BUILD_DIR)/lib/%.o: MWCFLAGS = -O4,p -sym on -gccext,on -proc arm946e -msgstyle gcc -gccinc -fp soft -lang c99 -Cpp_exceptions off -inline on,noauto -i ../include -ir ../include-mw -ir lib/MSL_C/include -ir lib/libnns/include -ir lib/NitroSDK/include -interworking -DFS_IMPLEMENT -enum int -D$(GAME_VERSION) -D$(GAME_LANGUAGE) -W all -W pedantic -W noimpl_signedunsigned -W noimplicitconv -W nounusedarg -W nomissingreturn -W error $(BUILD_DIR)/lib/libnns/%.o: MWCCVERSION = 1.2/sp3 $(BUILD_DIR)/lib/MSL_C/%.o: MWCCVERSION = 2.0/sp1 @@ -241,7 +241,7 @@ $(BUILD_DIR)/$(LD_SCRIPT): $(LD_SPEC) $(BUILD_DIR)/$(LD_TEMPLATE) $(ROM): $(BUILD_DIR)/$(LD_SCRIPT) $(O_FILES) $(STATIC_LIBS) echo "$(O_FILES:$(BUILD_DIR)/%=%)" > $(ELF).objlist cd $(BUILD_DIR) && LM_LICENSE_FILE=../../$(LM_LICENSE_FILE) $(WINE) ../../$(MWLDARM) $(MWLDFLAGS) $(LIBS) -o ../../$(ELF) $(LD_SCRIPT) @../../$(ELF).objlist - $(OBJCOPY) $(foreach ov,arm9 $(OVERLAYS),--update-section $(ov)=$(BUILD_DIR)/$(ov).sbin -j $(ov)) $(ELF) 2>/dev/null +# $(OBJCOPY) $(foreach ov,arm9 $(OVERLAYS),--update-section $(ov)=$(BUILD_DIR)/$(ov).sbin -j $(ov)) $(ELF) 2>/dev/null ifeq ($(SHIFTED),0) SYSCALL_OBJS := $(BUILD_DIR)/lib/syscall/secure.o diff --git a/arm9/lib/MSL_C/Makefile b/arm9/lib/MSL_C/Makefile index 3043b1739..67f8b3f63 100644 --- a/arm9/lib/MSL_C/Makefile +++ b/arm9/lib/MSL_C/Makefile @@ -53,9 +53,9 @@ OBJDUMP := $(CROSS)objdump OBJCOPY := $(CROSS)objcopy # ./tools/mwccarm/2.0/base/mwasmarm.exe -proc arm5te asm/arm9_thumb.s -o arm9.o -MWASFLAGS = -proc arm5te -ir ../../.. -MWCFLAGS = O4,p -gccext,on -proc arm946e -msgstyle gcc -gccinc -fp soft -lang c99 -Cpp_exceptions off -inline on,noauto -i ../include -ir ../include-mw -ir lib/MSL_C/include -ir lib/libnns/include -ir lib/NitroSDK/include -interworking -DFS_IMPLEMENT -enum int -D$(GAME_VERSION) -D$(GAME_LANGUAGE) -W all -W pedantic -W noimpl_signedunsigned -W noimplicitconv -W nounusedarg -W nomissingreturn -W error -ipa file -MWLDFLAGS = -library -nodead -w off -proc v5te -interworking -pic +MWASFLAGS = -proc arm5te -g -ir ../../.. +MWCFLAGS = O4,p -sym on -gccext,on -proc arm946e -msgstyle gcc -gccinc -fp soft -lang c99 -Cpp_exceptions off -inline on,noauto -i ../include -ir ../include-mw -ir lib/MSL_C/include -ir lib/libnns/include -ir lib/NitroSDK/include -interworking -DFS_IMPLEMENT -enum int -D$(GAME_VERSION) -D$(GAME_LANGUAGE) -W all -W pedantic -W noimpl_signedunsigned -W noimplicitconv -W nounusedarg -W nomissingreturn -W error -ipa file +MWLDFLAGS = -library -sym on -nodead -w off -proc v5te -interworking -pic ARFLAGS = rcS export MWCIncludes := include diff --git a/arm9/lib/Makefile b/arm9/lib/Makefile index 88c7be0a6..05b70a779 100644 --- a/arm9/lib/Makefile +++ b/arm9/lib/Makefile @@ -53,9 +53,9 @@ OBJDUMP := $(CROSS)objdump OBJCOPY := $(CROSS)objcopy # ./tools/mwccarm/2.0/base/mwasmarm.exe -proc arm5te asm/arm9_thumb.s -o arm9.o -MWASFLAGS = -proc arm5te -ir ../.. -MWCFLAGS = -O4,p -inline on,noauto -proc arm946e -msgstyle gcc -gccinc -fp soft -lang c99 -Cpp_exceptions off -i include -ir include-mw -ir arm9/lib/MSL_C/include -ir arm9/lib/libnns/include -ir arm9/lib/NitroSDK/include -W all -W pedantic -W noimpl_signedunsigned -W noimplicitconv -W nounusedarg -W nomissingreturn -W error -MWLDFLAGS = -library -nodead -w off -proc v5te -interworking -pic -msgstyle gcc +MWASFLAGS = -proc arm5te -g -ir ../.. +MWCFLAGS = -O4,p -sym on -inline on,noauto -proc arm946e -msgstyle gcc -gccinc -fp soft -lang c99 -Cpp_exceptions off -i include -ir include-mw -ir arm9/lib/MSL_C/include -ir arm9/lib/libnns/include -ir arm9/lib/NitroSDK/include -W all -W pedantic -W noimpl_signedunsigned -W noimplicitconv -W nounusedarg -W nomissingreturn -W error +MWLDFLAGS = -library -sym on -nodead -w off -proc v5te -interworking -pic -msgstyle gcc ARFLAGS = rcS export MWCIncludes := MSL_C/include libnns/include NitroSDK/include diff --git a/arm9/lib/NitroSDK/Makefile b/arm9/lib/NitroSDK/Makefile index 1c30d1f02..8aa31d932 100644 --- a/arm9/lib/NitroSDK/Makefile +++ b/arm9/lib/NitroSDK/Makefile @@ -53,9 +53,9 @@ OBJDUMP := $(CROSS)objdump OBJCOPY := $(CROSS)objcopy # ./tools/mwccarm/2.0/base/mwasmarm.exe -proc arm5te asm/arm9_thumb.s -o arm9.o -MWASFLAGS = -proc arm5te -ir ../../.. -MWCFLAGS = -O4,p -gccext,on -proc arm946e -msgstyle gcc -gccinc -fp soft -lang c99 -Cpp_exceptions off -inline on,noauto -i ../include -ir ../include-mw -ir lib/MSL_C/include -ir lib/libnns/include -ir lib/NitroSDK/include -interworking -DFS_IMPLEMENT -enum int -D$(GAME_VERSION) -D$(GAME_LANGUAGE) -W all -W pedantic -W noimpl_signedunsigned -W noimplicitconv -W nounusedarg -W nomissingreturn -W error -MWLDFLAGS = -library -nodead -w off -proc v5te -interworking -pic -msgstyle gcc +MWASFLAGS = -proc arm5te -g -ir ../../.. +MWCFLAGS = -O4,p -sym on -gccext,on -proc arm946e -msgstyle gcc -gccinc -fp soft -lang c99 -Cpp_exceptions off -inline on,noauto -i ../include -ir ../include-mw -ir lib/MSL_C/include -ir lib/libnns/include -ir lib/NitroSDK/include -interworking -DFS_IMPLEMENT -enum int -D$(GAME_VERSION) -D$(GAME_LANGUAGE) -W all -W pedantic -W noimpl_signedunsigned -W noimplicitconv -W nounusedarg -W nomissingreturn -W error +MWLDFLAGS = -library -sym on -nodead -w off -proc v5te -interworking -pic -msgstyle gcc ARFLAGS = rcS export MWCIncludes := include diff --git a/arm9/lib/libnns/Makefile b/arm9/lib/libnns/Makefile index 35e3b8e03..dceb3cc3f 100644 --- a/arm9/lib/libnns/Makefile +++ b/arm9/lib/libnns/Makefile @@ -54,9 +54,9 @@ OBJDUMP := $(CROSS)objdump OBJCOPY := $(CROSS)objcopy # ./tools/mwccarm/2.0/base/mwasmarm.exe -proc arm5te asm/arm9_thumb.s -o arm9.o -MWASFLAGS = -proc arm5te -ir ../../.. -MWCFLAGS = -O4,p -gccext,on -proc arm946e -msgstyle gcc -gccinc -fp soft -lang c99 -Cpp_exceptions off -inline on,noauto -i ../include -ir ../include-mw -ir lib/MSL_C/include -ir lib/libnns/include -ir lib/NitroSDK/include -interworking -DFS_IMPLEMENT -enum int -D$(GAME_VERSION) -D$(GAME_LANGUAGE) -W all -W pedantic -W noimpl_signedunsigned -W noimplicitconv -W nounusedarg -W nomissingreturn -W error -MWLDFLAGS = -library -nodead -w off -proc v5te -interworking -pic -msgstyle gcc +MWASFLAGS = -proc arm5te -g -ir ../../.. +MWCFLAGS = -O4,p -sym on -gccext,on -proc arm946e -msgstyle gcc -gccinc -fp soft -lang c99 -Cpp_exceptions off -inline on,noauto -i ../include -ir ../include-mw -ir lib/MSL_C/include -ir lib/libnns/include -ir lib/NitroSDK/include -interworking -DFS_IMPLEMENT -enum int -D$(GAME_VERSION) -D$(GAME_LANGUAGE) -W all -W pedantic -W noimpl_signedunsigned -W noimplicitconv -W nounusedarg -W nomissingreturn -W error +MWLDFLAGS = -library -sym on -nodead -w off -proc v5te -interworking -pic -msgstyle gcc ARFLAGS = rcS export MWCIncludes := include diff --git a/rom.rsf b/rom.rsf index bf77484a8..8012d1ce2 100644 --- a/rom.rsf +++ b/rom.rsf @@ -3,14 +3,14 @@ Arm9 Static arm9/$(BUILD_DIR)/arm9.sbin OverlayDefs arm9/$(BUILD_DIR)/arm9_defs.sbin OverlayTable arm9/$(BUILD_DIR)/arm9_table.sbin - Nef arm9/$(BUILD_DIR)/arm9.elf + Elf arm9/$(BUILD_DIR)/arm9.elf } Arm7 { Static arm7/build/arm7.sbin OverlayDefs arm7/build/arm7_defs.sbin - Nef arm7/build/arm7.elf + Elf arm7/build/arm7.elf } Property