Hello,
I have a txt file like :
test.txt
Symbols from __ctype_tab.o:
Name Value Class Type Size Line Section
__ctype |00000000| D | OBJECT|00000004| |.data
__ctype_tab |00000000| r | OBJECT|00000101| |.rodata
Symbols from _ashldi3.o:
Name Value Class Type Size Line Section
__ashldi3 |00000000| T | FUNC|00000050| |.text
Symbols from _ashrdi3.o:
Name Value Class Type Size Line Section
__ashrdi3 |00000000| T | FUNC|00000058| |.text
Symbols from _fixdfdi.o:
Name Value Class Type Size Line Section
__fixdfdi |00000000| T | FUNC|0000004c| |.text
__fixunsdfdi | | U | NOTYPE| | |*UND*
Symbols from _fixsfdi.o:
Name Value Class Type Size Line Section
__fixsfdi |00000000| T | FUNC|0000004c| |.text
__fixunssfdi | | U | NOTYPE| | |*UND*
Symbols from _fixunssfdi.o:
Name Value Class Type Size Line Section
__cmpdi2 | | U | NOTYPE| | |*UND*
__fixunssfdi |00000000| T | FUNC|00000228| |.text
__floatdidf | | U | NOTYPE| | |*UND*
What i want to do is , i will be given a function whose type is NOTYPE . i need to search the txt and find under which .o it's defined(ie;with type FUNC).When i get the .o file,i may see other functions as NOTYPE. Then i have to search where those are defined.it goes on. Finally i want to return a list of names of all .o files which contained the functions.
My piece of code:
notypeDict , funcDict = {} , {}
notypeList , funcList = [] , []
currObj , prevObj = '' , ''
fp = open(r'C:\test.txt','r') # file path cms here
fileList = fp.readlines()
for line in fileList:
if '.o' in line: # line containg .o
currObj=line.split()[-1][0:-1]
if '|' not in line: # line containg |
pass
else: # other lines
dataList=[dataItem.strip() for dataItem in line.strip().split('|')] # a list of each word in line
name=dataList[0].strip() # name of the function
notypeDict[prevObj] = notypeList # notypeDict is a dictionary which contains .o as key and a list of NOTYPE function name
funcDict[prevObj] = funcList # funcDict is a dictionary which contains .o as key and a list of FUNC function names
if prevObj == currObj :
pass
if prevObj != currObj :
notypeList , funcList = [] , []
if dataList[3] == 'NOTYPE' :
notypeList.append(name)
if dataList[3] == 'FUNC' :
funcList.append(name)
prevObj = currObj
print 'notypeDict' , notypeDict
print '\n\nfuncDict' , funcDict
Here i will get two dictionaries, notypeDict and funcDict.
notypeDict has .o as key and a list of NOTYPE functions as value funcDict has .o as key and a list of FUNC functions as value.
I reached till here.
But don't getting ideas how to proceed to achieve my target.
I think my question is clear.
Please help me out.