mirror of
https://github.com/geohot/qira
synced 2025-03-12 18:13:15 +03:00
start cleaning up static
This commit is contained in:
parent
e62e112428
commit
31fedda718
@ -1,6 +1,6 @@
|
||||
#!/bin/bash
|
||||
|
||||
# simple loop test
|
||||
docker run --workdir /qira --rm qira ./run_tests.sh
|
||||
docker run --workdir /qira --rm qira bash -c "./run_tests.sh && ./run_tests_static.sh"
|
||||
#docker run -p 3002:3002 --rm qira qira qira_tests/bin/loop
|
||||
|
||||
|
@ -43,7 +43,7 @@ def load_binary(static):
|
||||
static.add_memory_chunk(addr, segment.data().ljust(memsize, b"\x00"))
|
||||
|
||||
for section in elf.iter_sections():
|
||||
if static.debug >= 1:
|
||||
if static.debug >= 2:
|
||||
print("** found section", section.name, type(section))
|
||||
|
||||
if isinstance(section, RelocationSection):
|
||||
@ -53,7 +53,7 @@ def load_binary(static):
|
||||
|
||||
for rel in section.iter_relocations():
|
||||
symbol = symtable.get_symbol(rel['r_info_sym'])
|
||||
if static.debug >= 1: #suppress output for testing
|
||||
if static.debug >= 2: #suppress output for testing
|
||||
print("Relocation",rel, symbol.name)
|
||||
if rel['r_offset'] != 0 and symbol.name != "":
|
||||
static[rel['r_offset']]['name'] = "__"+symbol.name
|
||||
@ -85,7 +85,7 @@ def load_binary(static):
|
||||
for nsym, symbol in enumerate(section.iter_symbols()):
|
||||
#print symbol['st_info'], symbol.name, hex(symbol['st_value'])
|
||||
if symbol['st_value'] != 0 and symbol.name != "" and symbol['st_info']['type'] == "STT_FUNC":
|
||||
if static.debug >= 1:
|
||||
if static.debug >= 2:
|
||||
print("Symbol",hex(symbol['st_value']), symbol.name)
|
||||
static[symbol['st_value']]['name'] = symbol.name
|
||||
ncount += 1
|
||||
|
@ -46,20 +46,11 @@ import loader
|
||||
import analyzer
|
||||
|
||||
# the new interface for all things static
|
||||
# will only support radare2 for now
|
||||
# mostly tags, except for names and functions
|
||||
class Static:
|
||||
def __init__(self, path, debug=0):
|
||||
# create the static cache dir
|
||||
try:
|
||||
os.mkdir(qira_config.STATIC_CACHE_BASE)
|
||||
except:
|
||||
pass
|
||||
|
||||
def __init__(self, path, debug=1):
|
||||
self.tags = {}
|
||||
self.path = path
|
||||
self.scf = qira_config.STATIC_CACHE_BASE + sha1(open(self.path, "rb").read()).hexdigest()
|
||||
self.r2core = None
|
||||
self.debug = debug
|
||||
|
||||
# radare doesn't seem to have a concept of names
|
||||
@ -83,6 +74,12 @@ class Static:
|
||||
print("*** elf loaded")
|
||||
|
||||
"""
|
||||
# create the static cache dir
|
||||
try:
|
||||
os.mkdir(qira_config.STATIC_CACHE_BASE)
|
||||
except:
|
||||
pass
|
||||
self.scf = qira_config.STATIC_CACHE_BASE + sha1(open(self.path, "rb").read()).hexdigest()
|
||||
# check the cache
|
||||
if os.path.isfile(self.scf):
|
||||
# cache is global_tags + tags
|
||||
@ -239,7 +236,7 @@ class Static:
|
||||
def process(self):
|
||||
self.analyzer.analyze_functions(self)
|
||||
if self.debug >= 1:
|
||||
print("*** found %d functions" % len(self['functions']))
|
||||
print("*** static found %d functions" % len(self['functions']))
|
||||
|
||||
|
||||
# *** STATIC TEST STUFF ***
|
||||
|
Loading…
x
Reference in New Issue
Block a user