Exemple #1
0
 def add_offset(self, intval):
     newoffset = self.offset.add(SV.SimDoubleWordValue(intval))
     return SimBaseAddress(self.base, newoffset, buffersize=self.buffersize)
 def set_image_base(self, value):
     self.imagebase = SSV.SimGlobalAddress(
         SV.SimDoubleWordValue(int(value, 16)))
Exemple #3
0
 def add_offset(self, intval):
     newoffset = self.offset.add(SV.SimDoubleWordValue(intval))
     return SimStackAddress(newoffset)
    def __init__(
        self,
        app,
        basename,  # name of executable
        imagebase,  # base address of the image (hex)
        startaddr,  # address to start simulation (hex)
        bigendian=False,
        simsupport=BMS.BaseMIPSimSupport(
            '0x0'),  # support class with custom initialization and stubs
        baseaddress=0,  # load address, to be added to imagebase
        libapp=None,  # library to statically include functions from
        xapp=None):  # target executable for dynamic loading
        self.app = app
        self.basename = basename
        self.baseaddress = baseaddress
        self.bigendian = bigendian
        self.simsupport = simsupport

        # context
        self.imagebase = SSV.mk_global_address(int(imagebase, 16))
        self.context = FunctionContext(self, app)
        self.programcounter = SSV.mk_global_address(int(startaddr,
                                                        16))  # SimAddress
        self.delayed_programcounter = None  # SimAddress

        # registers and memory
        self.registers = {}  # register name -> SimValue
        self.registers['zero'] = SV.SimDoubleWordValue(0)
        self.stackmem = MM.MIPSimStackMemory(self)
        self.globalmem = MM.MIPSimGlobalMemory(self, self.app)
        self.basemem = {}  # base -> MM.MIPSimBaseMemory

        # static library (optional)
        self.libapp = libapp
        if self.libapp:
            self.libstubs = {}  # int (int-address) -> (name,stub)
            self.libglobalmem = MM.MIPSimGlobalMemory(self, libapp)
            self.static_lib = {
            }  # function-name -> function address in static lib
            libimgbase = self.libapp.get_elf_header().get_image_base()
            self.libimagebase = SSV.SimGlobalAddress(
                SV.SimDoubleWordValue(int(libimgbase, 16)))

        self.instaticlib = False

        # target executable for dynamic loading (optional)
        self.xapp = xapp
        if self.xapp:
            self.xglobalmem = MM.MIPSimGlobalMemory(self, xapp)

        # log
        self.fnlog = {}  # iaddr -> msg list2

        # environment
        self.environment = {}  # string -> string
        self.nvram = {}  # string -> string ; non-volatile ram default values
        self.network_input = {}  # string -> f() -> string

        # library/application function stubs
        self.stubs = {}  # int (int-address) -> (name,stub)
        self.appstubs = {}  # int (int-address) -> (name,stub)
        self.dlstubs = {}  # name -> stub ; dynamically linked symbols

        # libc functions implemented by tables
        self.ctype_toupper = None
        self.ctype_b = None

        self._initialize()
        self.function_start_initialization()
        self.push_context(startaddr)