-
Notifications
You must be signed in to change notification settings - Fork 0
/
symTable.py
60 lines (53 loc) · 1.6 KB
/
symTable.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
52
53
54
55
56
57
58
59
60
sym_dict={}
def symT(dindx,name,size,tsize,sym,define,addr,cont):
dict1={"Sym#"+str(dindx):{'Symname':name,'Size':size,'Tsize':tsize,'Sym/Label':sym,'Define':define,'Addr':addr,'Content':cont}}
sym_dict.update(dict1)
def printSymT():
print("SIndx\tName\tSize\tTSize\tSym/Lab\tDefine\tAddr\t\tContent")
for indx,content in sym_dict.items():
st=""
st+=str(indx)+'\t'
for key,val in content.items():
st+=str(val)+'\t'
print(st)
def symPresentN(label):
flag=0
for indx,content in sym_dict.items():
for key,val in content.items():
if key=='Symname' and label==val:
flag=1
elif key=='Define'and flag==1:
sym_dict[indx][key]='D'
flag=-1
break
if flag==1:
return 0
elif flag!=-1:
return -1
def checkSym(symbol):
strt=symbol.find('[')
end=symbol.find(']')
if strt==-1 and end==-1:
s=symbol
else:
s=symbol[strt+1:end]
for indx,content in sym_dict.items():
for key,val in content.items():
if key=='Symname':
if s==val:
return indx
else:
break
return symbol
def checkSym_opcode(searchL):
for indx,content in sym_dict.items():
if indx==searchL:
for key,val in content.items():
if key=='Addr':
return val
"""def printTable(dict):
for s_id,sym_info in dict.items():
print("\nS_id:",s_id)
for key in sym_info:
print(key+':'+str(sym_info[key]))
"""