mirror of
https://github.com/n64decomp/perfect_dark.git
synced 2025-02-12 01:45:43 +00:00
Fix build errors on Debian
This commit is contained in:
parent
33317b11ce
commit
a73335640a
8
Makefile
8
Makefile
@ -42,10 +42,12 @@ endif
|
||||
E_DIR := extracted/$(ROMID)
|
||||
B_DIR := build/$(ROMID)
|
||||
|
||||
ifeq ($(shell type mips64-elf-ld >/dev/null 2>/dev/null; echo $$?), 0)
|
||||
TOOLCHAIN := mips64-elf
|
||||
else ifeq ($(shell type mips-linux-gnu-ld >/dev/null 2>/dev/null; echo $$?), 0)
|
||||
ifeq ($(shell type mips-linux-gnu-ld >/dev/null 2>/dev/null; echo $$?), 0)
|
||||
# Debian, Ubuntu and Arch AUR
|
||||
TOOLCHAIN := mips-linux-gnu
|
||||
else ifeq ($(shell type mips64-elf-ld >/dev/null 2>/dev/null; echo $$?), 0)
|
||||
# Arch AUR
|
||||
TOOLCHAIN := mips64-elf
|
||||
else ifeq ($(shell type mips64-linux-gnu-ld >/dev/null 2>/dev/null; echo $$?), 0)
|
||||
TOOLCHAIN := mips64-linux-gnu
|
||||
else
|
||||
|
26
ld/pd.ld
26
ld/pd.ld
@ -44,6 +44,19 @@
|
||||
} \
|
||||
END_SEG(font##index)
|
||||
|
||||
/**
|
||||
* Placeholder segments are used to mark the locations where zipped content will
|
||||
* go. It's really just here so it appears in the linker map which allows
|
||||
* packrom to find it. We only care about the start address for this segment,
|
||||
* so the romheader object is used as it's nice and short.
|
||||
*/
|
||||
#define PLACEHOLDER_SEGMENT(name) \
|
||||
BEGIN_SEG(name) \
|
||||
{ \
|
||||
build/ROMID/romheader.o (.data); \
|
||||
} \
|
||||
END_SEG(name)
|
||||
|
||||
/******************************************************************************
|
||||
* ROM Allocations
|
||||
* ----------------------------------------------------------------------------
|
||||
@ -168,8 +181,9 @@ SECTIONS
|
||||
* the boot code calculates the lib address as boot start + boot length.
|
||||
*/
|
||||
|
||||
_libzipSegmentRomStart = __rompos;
|
||||
__rompos = 0x20000000;
|
||||
PLACEHOLDER_SEGMENT(libzip)
|
||||
|
||||
__rompos = 0x02000000;
|
||||
|
||||
BEGIN_SEG(lib)
|
||||
{
|
||||
@ -188,7 +202,11 @@ SECTIONS
|
||||
* recalculate it so that's what we do.
|
||||
*/
|
||||
|
||||
_datazipSegmentRomStart = _libzipSegmentRomStart + ROMALLOCATION_LIB;
|
||||
__savedrompos = __rompos;
|
||||
__rompos = _libzipSegmentRomStart + ROMALLOCATION_LIB;
|
||||
PLACEHOLDER_SEGMENT(datazip)
|
||||
|
||||
__rompos = __savedrompos;
|
||||
__rampos = 0x80001000 + SIZEOF(.boot) + SIZEOF(.lib);
|
||||
|
||||
BEGIN_SEG(data)
|
||||
@ -253,7 +271,7 @@ SECTIONS
|
||||
* -------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
_gamezipSegmentRomStart = __rompos;
|
||||
PLACEHOLDER_SEGMENT(gamezip)
|
||||
__rompos = __savedrompos;
|
||||
__rampos = 0x7f000000;
|
||||
|
||||
|
@ -90,10 +90,10 @@ def get_locations():
|
||||
ldmap = fd.read()
|
||||
fd.close()
|
||||
|
||||
matches = re.findall(r'^\s*0x([0-9a-f]+)\s+_(\S+)SegmentRomStart', ldmap, re.MULTILINE)
|
||||
matches = re.findall(r'^\.(\S+)\s+0x[0-9a-f]+\s+0x[0-9a-f]+\s+load address\s+0x([0-9a-f]+)', ldmap, re.MULTILINE)
|
||||
|
||||
def make_numeric(match):
|
||||
return {'addr': int(match[0], 16), 'name': match[1]}
|
||||
return {'addr': int(match[1], 16), 'name': match[0]}
|
||||
|
||||
return list(map(make_numeric, matches))
|
||||
|
||||
|
@ -73,27 +73,23 @@ class Tool:
|
||||
fd.close()
|
||||
|
||||
self.symbols = re.findall(r'^\s*0x([0-9a-f]+)\s+(\S+)$', ldmap, re.MULTILINE)
|
||||
self.segrampositions = re.findall(r'^\s*0x([0-9a-f]+)\s+_(\S+)SegmentStart', ldmap, re.MULTILINE)
|
||||
self.segrompositions = re.findall(r'^\s*0x([0-9a-f]+)\s+_(\S+)SegmentRomStart', ldmap, re.MULTILINE)
|
||||
|
||||
# Matching the following line:
|
||||
# .boot 0x0000000070001000 0x2050 load address 0x0000000000001000
|
||||
self.segpositions = re.findall(r'^\.(\S+)\s+0x([0-9a-f]+)\s+0x([0-9a-f]+)\s+load address\s+0x([0-9a-f]+)', ldmap, re.MULTILINE)
|
||||
|
||||
def ramtorom(self, ramaddr):
|
||||
# Find which segramposition is closest and prior
|
||||
segramaddr = 0
|
||||
segname = None
|
||||
for pos in self.segrampositions:
|
||||
addr = int(pos[0], 16)
|
||||
if addr <= ramaddr and addr > segramaddr:
|
||||
segramaddr = addr
|
||||
segname = pos[1]
|
||||
for pos in self.segpositions:
|
||||
segname = pos[0]
|
||||
rampos = int(pos[1], 16)
|
||||
length = int(pos[2], 16)
|
||||
rompos = int(pos[3], 16)
|
||||
|
||||
# Find where the segment is in ROM
|
||||
rompos = 0
|
||||
for pos in self.segrompositions:
|
||||
if pos[1] == segname:
|
||||
rompos = int(pos[0], 16)
|
||||
break
|
||||
if ramaddr >= rampos and ramaddr < rampos + length:
|
||||
return rompos + (ramaddr - rampos)
|
||||
|
||||
return rompos + (ramaddr - segramaddr)
|
||||
print('Couldn\'t translate RAM address 0x%08x to ROM' & romaddr)
|
||||
exit(1)
|
||||
|
||||
def get_function_address(self, funcname):
|
||||
startram = None
|
||||
|
Loading…
x
Reference in New Issue
Block a user