in preprocess/asm_obj.py [0:0]
def __ins_node__(self):
for i, line in enumerate(self.lines):
flag = 0
op_id = -1
for op in line.split():
if op in self.op2id:
flag = 1
op_id = self.op2id[op]
break
if not flag:
# if not flagged, this is a operation we are not supporting, add that
print(line)
self.lines[i] += 'nop'
op_id = self.op2id['nop']
# add instruction node
pc = line.split(':')[0].strip()
node = Node(name='ins_'+self.id2op[op_id],
node_id=self.num_nodes,
node_type='ins',
ins_id=i,
pc=pc)
# add subarray for this pc and add node
self.nodes.append([])
self.nodes[i].append(node)
# build pc to node mapping for building jump edges
self.pc2node[pc] = node
# for selecting subgraphs
self.id2node[self.num_nodes] = node
self.num_nodes += 1
# add control-flow edges for next instructions
if i > 0:
self.__add_edge__(Edge(name='',
edge_type=self.edge_type_2_id['next-ins'],
src=self.nodes[i-1][0].id,
tgt=self.nodes[i][0].id))
# add control-flow edges for jump instructions in self.op_types[0]
for i, line in enumerate(self.lines):
for j, op in enumerate(line.split()):
if self.__get_op_type__(op) == 0 and len(line.split()) > j+1 and '%' not in line.split()[j+1] and '$' not in line.split()[j+1]:
pc = line.split()[j+1].strip()
if isInt(pc):
if pc in self.pc2node:
self.__add_edge__(Edge(name='',
edge_type=self.edge_type_2_id['next-ins'],
src=self.nodes[i][0].id,
tgt=self.pc2node[pc].id))
break