-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathresolveLinkerErrors.py
51 lines (40 loc) · 1.24 KB
/
resolveLinkerErrors.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/env python3
# very experimental python script that goes through a linker error file and resolves any undefined labels while splitting
with open("errors.txt", "r") as f:
lines = f.readlines()
lbls = []
for line in lines:
#print (line)
if line.startswith("lbl_"):
#localstr = line.strip("lbl_")
localstr = line.strip("\n")
print (localstr)
lbls.append(localstr)
with open("asm/_Main/text.s", "r") as asm:
asms = asm.readlines()
prevLine = ""
output = []
for l in asms:
l = l.strip("\n")
for lbl in lbls:
#print(l)
#print("/* " + lbl)
if l.startswith(lbl):
print(l)
output.append(".global " + lbl + "\n")
#if prevLine.startswith("func_"):
# prevLine = l
# output.append(l + "\n")
# continue
#else:
# for lbl in lbls:
# lstr = l.strip(":")
# if lstr == lbl:
# output.append(f".global {lbl}\n")
# prevLine = l
# break
output.append(l + "\n")
prevLine = l
with open("output.asm", "w") as w:
for o in output:
w.write(o)