libmatch icon indicating copy to clipboard operation
libmatch copied to clipboard

AttributeError: graph

Open chunlin007 opened this issue 1 year ago • 0 comments

To use libmatch in my local enviroment (ubuntu-22.04). I got an error when I try to execute: ./utils/unblob -U --scoring -L ./objects/arm-none-eabi.lmdb -Y ./bins/Nucleo_i2c_master.elf ./bins/Nucleo_i2c_master_addrs.yml. Full error info. are as follow:

      Traceback (most recent call last):
    File "/libmatch/bdsig/lmdb.py", line 103, in match
      self.lm = LibMatch(lmd, self)
    File "/libmatch/bdsig/libmatch.py", line 22, in __init__
      self._compute()
    File "/libmatch/bdsig/libmatch.py", line 410, in _compute
      self._compute_second_order_matches(lib)
    File "/libmatch/bdsig/libmatch.py", line 98, in _compute_second_order_matches
      fd = self._second_order_heuristic(self.binary_lmd, lmd, maddr, faddr)
    File "/libmatch/bdsig/libmatch.py", line 75, in _second_order_heuristic
      return FunctionDiff(binary_lmd, lib_lmd, bin_func, lib_func)
    File "/libmatch/bdsig/functiondiff.py", line 256, in __init__
      self.attributes_b = self._compute_block_attributes(self.function_b)
    File "/libmatch/bdsig/functiondiff.py", line 455, in _compute_block_attributes
      distances_from_start = FunctionDiff._distances_from_function_start(function)
    File "/libmatch/bdsig/functiondiff.py", line 479, in _distances_from_function_start
      return networkx.single_source_shortest_path_length(function.graph,
    File "/libmatch/bdsig/lmd.py", line 156, in __getattr__
      raise AttributeError(a)
  AttributeError: graph
  Traceback (most recent call last):
    File "/libmatch/./utils/unblob", line 175, in <module>
      do_normal(opts)
    File "/libmatch/./utils/unblob", line 144, in do_normal
      symbol_map = lmdb.match(lmd, score=opts.scoring)
    File "/libmatch/bdsig/lmdb.py", line 103, in match
      self.lm = LibMatch(lmd, self)
    File "/libmatch/bdsig/libmatch.py", line 22, in __init__
      self._compute()
    File "/libmatch/bdsig/libmatch.py", line 410, in _compute
      self._compute_second_order_matches(lib)
    File "/libmatch/bdsig/libmatch.py", line 98, in _compute_second_order_matches
      fd = self._second_order_heuristic(self.binary_lmd, lmd, maddr, faddr)
    File "/libmatch/bdsig/libmatch.py", line 75, in _second_order_heuristic
      return FunctionDiff(binary_lmd, lib_lmd, bin_func, lib_func)
    File "/libmatch/bdsig/functiondiff.py", line 256, in __init__
      self.attributes_b = self._compute_block_attributes(self.function_b)
    File "/libmatch/bdsig/functiondiff.py", line 455, in _compute_block_attributes
      distances_from_start = FunctionDiff._distances_from_function_start(function)
    File "/libmatch/bdsig/functiondiff.py", line 479, in _distances_from_function_start
      return networkx.single_source_shortest_path_length(function.graph,
    File "/libmatch/bdsig/lmd.py", line 156, in __getattr__
      raise AttributeError(a)
  AttributeError: graph

I found that in my pc, I can create arm-none-eabi.lmdb by executing: ./utils/unblob -B ./objects/arm-none-eabi ./objects/arm-none-eabi.lmdb However, when we execute ./utils/unblob -U --scoring -L ./objects/arm-none-eabi.lmdb -Y ./bins/Nucleo_i2c_master.elf ./bins/Nucleo_i2c_master_addrs.yml unblob can load arm-none-eabi.lmdb with pickle.load, but without graph element in lmdb.lib_lmds[addr].normalization_functions.

How to solve this problem?

chunlin007 avatar Nov 07 '24 08:11 chunlin007