pcode-graph 4.2.0__tar.gz → 4.2.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. {pcode_graph-4.2.0 → pcode_graph-4.2.1}/CHANGELOG +4 -0
  2. {pcode_graph-4.2.0 → pcode_graph-4.2.1}/PKG-INFO +1 -1
  3. {pcode_graph-4.2.0 → pcode_graph-4.2.1}/pcode_graph/analysis/alias_analysis.py +26 -4
  4. {pcode_graph-4.2.0 → pcode_graph-4.2.1}/tests/memory_test.py +15 -0
  5. {pcode_graph-4.2.0 → pcode_graph-4.2.1}/.github/workflows/release.yml +0 -0
  6. {pcode_graph-4.2.0 → pcode_graph-4.2.1}/.github/workflows/test.yml +0 -0
  7. {pcode_graph-4.2.0 → pcode_graph-4.2.1}/.gitignore +0 -0
  8. {pcode_graph-4.2.0 → pcode_graph-4.2.1}/LICENSE +0 -0
  9. {pcode_graph-4.2.0 → pcode_graph-4.2.1}/README.md +0 -0
  10. {pcode_graph-4.2.0 → pcode_graph-4.2.1}/pcode_graph/__init__.py +0 -0
  11. {pcode_graph-4.2.0 → pcode_graph-4.2.1}/pcode_graph/__main__.py +0 -0
  12. {pcode_graph-4.2.0 → pcode_graph-4.2.1}/pcode_graph/analysis/cfg.py +0 -0
  13. {pcode_graph-4.2.0 → pcode_graph-4.2.1}/pcode_graph/analysis/def_use.py +0 -0
  14. {pcode_graph-4.2.0 → pcode_graph-4.2.1}/pcode_graph/analysis/interning.py +0 -0
  15. {pcode_graph-4.2.0 → pcode_graph-4.2.1}/pcode_graph/analysis/load_store.py +0 -0
  16. {pcode_graph-4.2.0 → pcode_graph-4.2.1}/pcode_graph/analysis/native_pcode.py +0 -0
  17. {pcode_graph-4.2.0 → pcode_graph-4.2.1}/pcode_graph/analysis/pass_base.py +0 -0
  18. {pcode_graph-4.2.0 → pcode_graph-4.2.1}/pcode_graph/analysis/passes.py +0 -0
  19. {pcode_graph-4.2.0 → pcode_graph-4.2.1}/pcode_graph/analysis/program.py +0 -0
  20. {pcode_graph-4.2.0 → pcode_graph-4.2.1}/pcode_graph/analysis/unreachable.py +0 -0
  21. {pcode_graph-4.2.0 → pcode_graph-4.2.1}/pcode_graph/arch.py +0 -0
  22. {pcode_graph-4.2.0 → pcode_graph-4.2.1}/pcode_graph/asm.py +0 -0
  23. {pcode_graph-4.2.0 → pcode_graph-4.2.1}/pcode_graph/basic_blocks.py +0 -0
  24. {pcode_graph-4.2.0 → pcode_graph-4.2.1}/pcode_graph/bit_utils.py +0 -0
  25. {pcode_graph-4.2.0 → pcode_graph-4.2.1}/pcode_graph/characterization.py +0 -0
  26. {pcode_graph-4.2.0 → pcode_graph-4.2.1}/pcode_graph/checker.py +0 -0
  27. {pcode_graph-4.2.0 → pcode_graph-4.2.1}/pcode_graph/cli.py +0 -0
  28. {pcode_graph-4.2.0 → pcode_graph-4.2.1}/pcode_graph/emulator.py +0 -0
  29. {pcode_graph-4.2.0 → pcode_graph-4.2.1}/pcode_graph/gnn_exporter.py +0 -0
  30. {pcode_graph-4.2.0 → pcode_graph-4.2.1}/pcode_graph/graph.py +0 -0
  31. {pcode_graph-4.2.0 → pcode_graph-4.2.1}/pcode_graph/lief_importer.py +0 -0
  32. {pcode_graph-4.2.0 → pcode_graph-4.2.1}/pcode_graph/log.py +0 -0
  33. {pcode_graph-4.2.0 → pcode_graph-4.2.1}/pcode_graph/maker.py +0 -0
  34. {pcode_graph-4.2.0 → pcode_graph-4.2.1}/pcode_graph/nx_exporter.py +0 -0
  35. {pcode_graph-4.2.0 → pcode_graph-4.2.1}/pcode_graph/pcode.py +0 -0
  36. {pcode_graph-4.2.0 → pcode_graph-4.2.1}/pcode_graph/registers.py +0 -0
  37. {pcode_graph-4.2.0 → pcode_graph-4.2.1}/pcode_graph/simplifier.py +0 -0
  38. {pcode_graph-4.2.0 → pcode_graph-4.2.1}/pcode_graph/torch_utils.py +0 -0
  39. {pcode_graph-4.2.0 → pcode_graph-4.2.1}/pcode_graph/translator.py +0 -0
  40. {pcode_graph-4.2.0 → pcode_graph-4.2.1}/pcode_graph/view.py +0 -0
  41. {pcode_graph-4.2.0 → pcode_graph-4.2.1}/pcode_graph/visitor.py +0 -0
  42. {pcode_graph-4.2.0 → pcode_graph-4.2.1}/pyproject.toml +0 -0
  43. {pcode_graph-4.2.0 → pcode_graph-4.2.1}/requirements.txt +0 -0
  44. {pcode_graph-4.2.0 → pcode_graph-4.2.1}/tests/__init__.py +0 -0
  45. {pcode_graph-4.2.0 → pcode_graph-4.2.1}/tests/analysis_test.py +0 -0
  46. {pcode_graph-4.2.0 → pcode_graph-4.2.1}/tests/basic_block_test.py +0 -0
  47. {pcode_graph-4.2.0 → pcode_graph-4.2.1}/tests/callother_test.py +0 -0
  48. {pcode_graph-4.2.0 → pcode_graph-4.2.1}/tests/charac_test.py +0 -0
  49. {pcode_graph-4.2.0 → pcode_graph-4.2.1}/tests/cli_test.py +0 -0
  50. {pcode_graph-4.2.0 → pcode_graph-4.2.1}/tests/conftest.py +0 -0
  51. {pcode_graph-4.2.0 → pcode_graph-4.2.1}/tests/def_use_test.py +0 -0
  52. {pcode_graph-4.2.0 → pcode_graph-4.2.1}/tests/emulator_test.py +0 -0
  53. {pcode_graph-4.2.0 → pcode_graph-4.2.1}/tests/exporter_test.py +0 -0
  54. {pcode_graph-4.2.0 → pcode_graph-4.2.1}/tests/fixtures.py +0 -0
  55. {pcode_graph-4.2.0 → pcode_graph-4.2.1}/tests/helpers.py +0 -0
  56. {pcode_graph-4.2.0 → pcode_graph-4.2.1}/tests/lief_importer_test.py +0 -0
  57. {pcode_graph-4.2.0 → pcode_graph-4.2.1}/tests/load_store_test.py +0 -0
  58. {pcode_graph-4.2.0 → pcode_graph-4.2.1}/tests/maker_test.py +0 -0
  59. {pcode_graph-4.2.0 → pcode_graph-4.2.1}/tests/memory_state_test.py +0 -0
  60. {pcode_graph-4.2.0 → pcode_graph-4.2.1}/tests/translator_test.py +0 -0
  61. {pcode_graph-4.2.0 → pcode_graph-4.2.1}/tests/utils_test.py +0 -0
  62. {pcode_graph-4.2.0 → pcode_graph-4.2.1}/todo.md +0 -0
@@ -1,3 +1,7 @@
1
+ # 4.2.1
2
+
3
+ - Fix recursion error in memory analysis.
4
+
1
5
  # 4.2.0
2
6
 
3
7
  - Optimize memory consumption and speed of analyses.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: pcode_graph
3
- Version: 4.2.0
3
+ Version: 4.2.1
4
4
  Summary: Build, display and vectorize semantic graphs from binary code
5
5
  Project-URL: Homepage, https://github.com/quarkslab/pcode_graph
6
6
  Project-URL: Issues, https://github.com/quarkslab/pcode_graph/issues
@@ -148,6 +148,8 @@ class MemoryAnalyzer(PassBase):
148
148
 
149
149
  self.stack_pointer = STACK_POINTERS.get(program.arch)
150
150
  self._output_values: dict[OpIndex, AbstractValue] = {}
151
+ # Unevaluated definitions met by _evaluate_from
152
+ self._missing: list[OpIndex] | None = None
151
153
  self._loads: dict[OpIndex, MemoryAccess] = {}
152
154
  self._stores: dict[OpIndex, MemoryAccess | None] = {}
153
155
 
@@ -163,7 +165,6 @@ class MemoryAnalyzer(PassBase):
163
165
  if not self.program.reachable(index):
164
166
  continue
165
167
  if op.output is not None:
166
- # Evaluating in program order bounds the recursion depth
167
168
  self._output_value(index, wrap(op.output))
168
169
  if op.opcode == OpCode.LOAD:
169
170
  access = self._compute_access(index, op.output.size)
@@ -198,10 +199,31 @@ class MemoryAnalyzer(PassBase):
198
199
  if op.output is None or wrap(op.output) != var:
199
200
  return None
200
201
  if index not in self._output_values:
202
+ if op.opcode not in ADDRESS_OPCODES:
203
+ self._output_values[index] = None
204
+ elif self._missing is None:
205
+ self._evaluate_from(index)
206
+ else:
207
+ # Evaluated later by _evaluate_from
208
+ self._missing.append(index)
209
+ return self._output_values.get(index)
210
+
211
+ def _evaluate_from(self, root: OpIndex) -> None:
212
+ """Evaluates the given operation after its dependencies, without recursion."""
213
+
214
+ pending = [root]
215
+ while pending:
216
+ index = pending[-1]
201
217
  # Breaks cycles in loops
202
- self._output_values[index] = None
203
- self._output_values[index] = self._evaluate(index, op)
204
- return self._output_values[index]
218
+ self._output_values.setdefault(index, None)
219
+ self._missing = []
220
+ value = self._evaluate(index, self.program.operations[index])
221
+ if self._missing:
222
+ pending += self._missing
223
+ else:
224
+ self._output_values[index] = value
225
+ pending.pop()
226
+ self._missing = None
205
227
 
206
228
  def _evaluate(self, index: OpIndex, op: PcodeOp) -> AbstractValue:
207
229
  if op.opcode not in ADDRESS_OPCODES:
@@ -270,6 +270,21 @@ def test_long_stack_pointer_chain(outdir: Path, x86_64: ArchContext, log):
270
270
  assert len(program.memory.forwarded_loads) == 1
271
271
 
272
272
 
273
+ def test_long_chain_defined_after_use(outdir: Path, x86_64: ArchContext, log):
274
+ # The load precedes the stack pointer definitions in program order
275
+ program = make_program_from_asm(
276
+ "jmp body; use: mov rbx, [rsp]; ret; body: mov [rsp], rax;"
277
+ + "add rsp, 8;" * 2000
278
+ + "sub rsp, 16000; jmp use",
279
+ x86_64,
280
+ outdir,
281
+ )
282
+
283
+ # Both the mov and the ret read the single store
284
+ assert len(set(map(tuple, program.memory.forwarded_loads.values()))) == 1
285
+ assert len(program.memory.forwarded_loads) == 2
286
+
287
+
273
288
  @pytest.mark.parametrize(
274
289
  "arch_fixture", ["x86_64", "x86_32", "arm64", "arm32", "mips_64", "mips_32"]
275
290
  )
File without changes
File without changes
File without changes
File without changes
File without changes