mirror of
https://github.com/zeldaret/tp
synced 2026-08-20 06:06:50 -04:00
Add basic dol shiftability
Fixed an incorrect function name
This commit is contained in:
+44
-4
@@ -33,11 +33,17 @@ VERSION = "1.0"
|
||||
sys.path.append("defs")
|
||||
|
||||
|
||||
def lcf_generate(output_path):
|
||||
def lcf_generate(output_path,shiftable,map_file):
|
||||
"""Script for generating .lcf files"""
|
||||
|
||||
import module0
|
||||
|
||||
if shiftable == True:
|
||||
print("Generating LCF for shiftability")
|
||||
map_file = open(map_file,'r')
|
||||
map_file = map_file.read()
|
||||
map_file = map_file.splitlines()
|
||||
|
||||
# load symbols from compiled files
|
||||
symbols = []
|
||||
for archive in ARCHIVES:
|
||||
@@ -95,7 +101,17 @@ def lcf_generate(output_path):
|
||||
if symbol["type"] == "LinkerGenerated": # linker handles these symbols
|
||||
continue
|
||||
|
||||
file.write(f"\t\"{symbol['label']}\" = 0x{symbol['addr']:08X};\n")
|
||||
addr = symbol['addr']
|
||||
if shiftable==True:
|
||||
for line in map_file:
|
||||
if type(symbol['name'])==str and line.find(' '+symbol['name']+' ')!=-1 and name[0] != "@" or type(symbol['label']) == str and line.find(' '+symbol['label']+' ')!=-1:
|
||||
linesplit = line.split()
|
||||
if len(linesplit) > 3 and linesplit[2]!="NOT":
|
||||
addr = int(linesplit[2],16)
|
||||
file.write(f"\t\"{symbol['label']}\" = 0x{addr:08X};\n")
|
||||
else:
|
||||
file.write(f"\t\"{symbol['label']}\" = 0x{addr:08X};\n")
|
||||
|
||||
file.write("\n")
|
||||
|
||||
# @stringBase0 is generated by the compiler. The dol2asm is using a trick to
|
||||
@@ -106,7 +122,18 @@ def lcf_generate(output_path):
|
||||
file.write("\t/* @stringBase0 */\n")
|
||||
for x in module0.SYMBOLS:
|
||||
if x["type"] == "StringBase":
|
||||
file.write('\t"%s" = 0x%08X;\n' % (x["label"], x["addr"]))
|
||||
addr = x['addr']
|
||||
if shiftable==True:
|
||||
obj = (module0.TRANSLATION_UNITS[x['tu']].split('/')[-1])+'.o'
|
||||
#print(obj)
|
||||
for line in map_file:
|
||||
if line.find(' '+obj)!=-1 and line.find(' '+x['name']+' ')!=-1 or line.find('\t'+obj)!=-1 and line.find(' '+x['name']+' ')!=-1:
|
||||
linesplit = line.split()
|
||||
if len(linesplit) > 3:
|
||||
addr = int(linesplit[2],16)
|
||||
file.write("\t\"%s\" = 0x%08X;\n" % (x['label'], addr))
|
||||
else:
|
||||
file.write("\t\"%s\" = 0x%08X;\n" % (x['label'], addr))
|
||||
|
||||
file.write("}\n")
|
||||
file.write("\n")
|
||||
@@ -384,7 +411,20 @@ def lcf():
|
||||
default="build/dolzel2/ldscript.lcf",
|
||||
)
|
||||
def dol(output_path):
|
||||
lcf_generate(output_path)
|
||||
lcf_generate(output_path,False,None)
|
||||
|
||||
@lcf.command(name="dol_shift")
|
||||
@click.option(
|
||||
"--output",
|
||||
"-o",
|
||||
"output_path",
|
||||
required=False,
|
||||
type=PathPath(file_okay=True, dir_okay=False),
|
||||
default="build/dolzel2/ldscript.lcf",
|
||||
)
|
||||
@click.option('--map','-m','map_file',required=False,type=PathPath(file_okay=True, dir_okay=False), default="build/dolzel2/dolzel2.map")
|
||||
def dol_shift(output_path,map_file):
|
||||
lcf_generate(output_path,True,map_file)
|
||||
|
||||
|
||||
@lcf.command(name="rel")
|
||||
|
||||
Reference in New Issue
Block a user