compile straight to elf with debug symbols

This commit is contained in:
red031000 2023-07-28 01:37:24 +01:00
parent 0b20e08e26
commit 187c09eff2
No known key found for this signature in database
GPG Key ID: D27E50C050AE0CE1
8 changed files with 21 additions and 24 deletions

View File

@ -32,7 +32,7 @@ void BuildAnalyzer::AnalyzeObject(path fname_s) {
}
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()) {
}) != program.GetProgramHeaders().cend() && word > 0x01000000) {
#ifndef NDEBUG
try {
unsigned addr = (&word - &*data.cbegin()) * 4 + xmap.at({fname_b.string(), shname});

View File

@ -8,7 +8,7 @@ fi
build_name=$1
url=$2
build_subdir=${1//poke/}.us
arm9name=${arm9name:-main.nef}
arm9name=${arm9name:-main.elf}
map_file=$(dirname "$0")/../../build/${build_subdir}/${arm9name}.xMAP
if [ ! -f $map_file ]; then
echo "$map_file does not exist!"

View File

@ -57,7 +57,7 @@ sub: ; @$(MAKE) -C sub
ROMSPEC := rom.rsf
MAKEROM_FLAGS := $(DEFINES)
$(NEF): libsyscall
$(ELF): libsyscall
libsyscall:
$(MAKE) -C lib/syscall all install INSTALL_PREFIX=$(abspath $(WORK_DIR)/$(BUILD_DIR)) GAME_CODE=$(GAME_CODE)

View File

@ -99,19 +99,18 @@ $(ALL_LIB_OBJS): DEFINES = $(GLB_DEFINES)
ALL_BUILDDIRS := $(sort $(ALL_BUILDDIRS) $(foreach obj,$(ALL_OBJS),$(dir $(obj))))
NEF := $(BUILD_DIR)/$(NEFNAME).nef
ELF := $(NEF:%.nef=%.elf)
LCF := $(NEF:%.nef=%.lcf)
RESPONSE := $(NEF:%.nef=%.response)
SBIN := $(NEF:%.nef=%.sbin)
XMAP := $(NEF).xMAP
ELF := $(BUILD_DIR)/$(ELFNAME).elf
LCF := $(ELF:%.elf=%.lcf)
RESPONSE := $(ELF:%.elf=%.response)
SBIN := $(ELF:%.elf=%.sbin)
XMAP := $(ELF).xMAP
EXCCFLAGS := -Cpp_exceptions off
MWCFLAGS = $(DEFINES) $(OPTFLAGS) -enum int -lang c99 $(EXCCFLAGS) -gccext,on -proc $(PROC) -msgstyle gcc -gccinc -i ./include -i ./include/library -i $(WORK_DIR)/files -I$(WORK_DIR)/lib/include -ipa file -interworking -inline on,noauto -char signed -W all -W pedantic -W noimpl_signedunsigned -W noimplicitconv -W nounusedarg -W nomissingreturn -W error
MWCFLAGS = $(DEFINES) $(OPTFLAGS) -sym on -enum int -lang c99 $(EXCCFLAGS) -gccext,on -proc $(PROC) -msgstyle gcc -gccinc -i ./include -i ./include/library -i $(WORK_DIR)/files -I$(WORK_DIR)/lib/include -ipa file -interworking -inline on,noauto -char signed -W all -W pedantic -W noimpl_signedunsigned -W noimplicitconv -W nounusedarg -W nomissingreturn -W error
MWASFLAGS = $(DEFINES) -proc $(PROC_S) -gccinc -i . -i ./include -i $(WORK_DIR)/asm/include -i $(WORK_DIR)/files -i $(WORK_DIR)/lib/asm/include -i $(WORK_DIR)/lib/NitroDWC/asm/include -i $(WORK_DIR)/lib/NitroSDK/asm/include -i $(WORK_DIR)/lib/syscall/asm/include -I$(WORK_DIR)/lib/include -DSDK_ASM
MWLDFLAGS := -proc $(PROC) -nopic -nopid -interworking -map closure,unused -symtab sort -m _start -msgstyle gcc
MWASFLAGS = $(DEFINES) -proc $(PROC_S) -g -gccinc -i . -i ./include -i $(WORK_DIR)/asm/include -i $(WORK_DIR)/files -i $(WORK_DIR)/lib/asm/include -i $(WORK_DIR)/lib/NitroDWC/asm/include -i $(WORK_DIR)/lib/NitroSDK/asm/include -i $(WORK_DIR)/lib/syscall/asm/include -I$(WORK_DIR)/lib/include -DSDK_ASM
MWLDFLAGS := -proc $(PROC) -sym on -nopic -nopid -interworking -map closure,unused -symtab sort -m _start -msgstyle gcc
ARFLAGS := rcS
MW_COMPILE = $(WINE) $(MWCC) $(MWCFLAGS)
@ -119,7 +118,7 @@ MW_ASSEMBLE = $(WINE) $(MWAS) $(MWASFLAGS)
export MWCIncludes := lib/include
LSF := $(addsuffix .lsf,$(NEFNAME))
LSF := $(addsuffix .lsf,$(ELFNAME))
ifneq ($(LSF),)
OVERLAYS := $(shell $(GREP) -o "^Overlay \w+" $(LSF) | cut -d' ' -f2)
else
@ -212,12 +211,9 @@ $(RESPONSE): $(LSF) $(RESPONSE_TEMPLATE)
# Locate crt0.o
CRT0_OBJ := lib/asm/crt0.o
$(NEF): $(LCF) $(RESPONSE) $(ALL_OBJS)
cd $(BUILD_DIR) && LM_LICENSE_FILE=$(BACK_REL)/$(LM_LICENSE_FILE) $(WINE) $(MWLD) $(MWLDFLAGS) $(LIBS) -o $(BACK_REL)/$(NEF) $(LCF:$(BUILD_DIR)/%=%) @$(RESPONSE:$(BUILD_DIR)/%=%) $(CRT0_OBJ)
.INTERMEDIATE: $(BUILD_DIR)/obj.list
$(SBIN): build/%.sbin: build/%.nef
$(SBIN): build/%.sbin: build/%.elf
ifeq ($(SBIN),$(BUILD_DIR)/main.sbin)
# Overlay 123 is encrypted in the retail ROM, so we need to reencrypt it after building it
cd $(BUILD_DIR) && ../../$(MOD123ENCRY) encry main OVY_123_enc.sbin 123 && mv OVY_123_enc.sbin OVY_123.sbin
@ -226,7 +222,8 @@ ifeq ($(COMPARE),1)
$(SHA1SUM) --quiet -c $*.sha1
endif
$(ELF): %.elf: %.nef
$(NTRMERGE) $*
$(ELF): $(LCF) $(RESPONSE) $(ALL_OBJS)
cd $(BUILD_DIR) && LM_LICENSE_FILE=$(BACK_REL)/$(LM_LICENSE_FILE) $(WINE) $(MWLD) $(MWLDFLAGS) $(LIBS) -o $(BACK_REL)/$(ELF) $(LCF:$(BUILD_DIR)/%=%) @$(RESPONSE:$(BUILD_DIR)/%=%) $(CRT0_OBJ)
# $(NTRMERGE) $*
print-% : ; $(info $* is a $(flavor $*) variable set to [$($*)]) @true

View File

@ -30,7 +30,7 @@ $(error Unsupported game language: $(GAME_LANGUAGE))
endif
BUILD_DIR := build/$(buildname)
NEFNAME := main
ELFNAME := main
GF_DEFINES := -D$(GAME_VERSION) -DGAME_REMASTER=$(GAME_REMASTER) -D$(GAME_LANGUAGE)
ifeq ($(NO_GF_ASSERT),)

View File

@ -3,14 +3,14 @@ Arm9
Static $(BUILD_DIR)/main.sbin_LZ
OverlayDefs $(BUILD_DIR)/main_defs.sbin_LZ
OverlayTable $(BUILD_DIR)/main_table.sbin_LZ
Nef $(BUILD_DIR)/main.nef
Elf $(BUILD_DIR)/main.elf
}
Arm7
{
Static sub/build/ichneumon_sub.sbin
OverlayDefs sub/build/ichneumon_sub_defs.sbin
Nef sub/build/ichneumon_sub.nef
Elf sub/build/ichneumon_sub.elf
}
Property

View File

@ -3,7 +3,7 @@ BUILD_DIR := build
# all paths referring up from BUILD_DIR must be relative.
BACK_REL := ..
TOOLSDIR := ../tools
NEFNAME := ichneumon_sub
ELFNAME := ichneumon_sub
MWCCVER := 2.0/sp2p3
PROC := arm7tdmi
PROC_S := arm4t

View File

@ -112,7 +112,7 @@ def main():
scrcmds.append([line.split()[1], []])
pat = re.compile(r'\s+[0-9A-F]{8}\s+[0-9A-F]{8}\s+\.text\s+(?P<symbol>\w+)\s+\((?P<object>\S+)\)')
with open(os.path.join(project_root, 'build/heartgold.us/main.nef.xMAP')) as fp:
with open(os.path.join(project_root, 'build/heartgold.us/main.elf.xMAP')) as fp:
for line in fp:
if (m := pat.match(line)) is not None and any(x[0] == m['symbol'] for x in scrcmds):
objects[m['object']].append(m['symbol'])