MCPcopy Create free account
hub / github.com/qilingframework/qiling / SymbolTable

Class SymbolTable

qiling/loader/macho_parser/data.py:77–115  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

75
76
77class SymbolTable:
78 def __init__(self, lc, data):
79 self.offset = lc.symbol_table_offset
80 self.sym_num = lc.number_of_symbols
81 self.content = data[self.offset : self.offset + self.sym_num * 0x10]
82
83 self.symbols = []
84 for i in range(self.sym_num):
85 tmp = Symbol64(self.content[16*i:16*(i + 1)])
86 self.symbols.append(tmp)
87
88 def update(self, base):
89 for sym in self.symbols:
90 sym.n_value += base
91
92 def details(self, index, size, strtab):
93 result = {}
94 for local_idx, sym in enumerate(self.symbols[index: index + size]):
95 if sym.n_strx != 1: # Why I have an index 1 from string table?
96 symname = strtab[sym.n_strx]
97 tmp = {}
98 tmp["n_strx"] = sym.n_strx
99 tmp["n_type"] = sym.n_type
100 tmp["n_sect"] = sym.n_sect
101 tmp["n_desc"] = sym.n_desc
102 tmp["n_value"] = sym.n_value
103 tmp["index"] = local_idx + index
104 if symname in result:
105# print("Symbol name:", symname)
106# from pprint import pprint
107# pprint(tmp)
108# pprint(result[symname])
109 if sym.n_value == 0:
110 continue
111 result[symname] = tmp
112 return result
113
114 # def __str__(self):
115 # return (" SymbolTable: content {}".format(self.content))
116
117
118import bisect

Callers 1

parseDataMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected