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.
- {pcode_graph-4.2.0 → pcode_graph-4.2.1}/CHANGELOG +4 -0
- {pcode_graph-4.2.0 → pcode_graph-4.2.1}/PKG-INFO +1 -1
- {pcode_graph-4.2.0 → pcode_graph-4.2.1}/pcode_graph/analysis/alias_analysis.py +26 -4
- {pcode_graph-4.2.0 → pcode_graph-4.2.1}/tests/memory_test.py +15 -0
- {pcode_graph-4.2.0 → pcode_graph-4.2.1}/.github/workflows/release.yml +0 -0
- {pcode_graph-4.2.0 → pcode_graph-4.2.1}/.github/workflows/test.yml +0 -0
- {pcode_graph-4.2.0 → pcode_graph-4.2.1}/.gitignore +0 -0
- {pcode_graph-4.2.0 → pcode_graph-4.2.1}/LICENSE +0 -0
- {pcode_graph-4.2.0 → pcode_graph-4.2.1}/README.md +0 -0
- {pcode_graph-4.2.0 → pcode_graph-4.2.1}/pcode_graph/__init__.py +0 -0
- {pcode_graph-4.2.0 → pcode_graph-4.2.1}/pcode_graph/__main__.py +0 -0
- {pcode_graph-4.2.0 → pcode_graph-4.2.1}/pcode_graph/analysis/cfg.py +0 -0
- {pcode_graph-4.2.0 → pcode_graph-4.2.1}/pcode_graph/analysis/def_use.py +0 -0
- {pcode_graph-4.2.0 → pcode_graph-4.2.1}/pcode_graph/analysis/interning.py +0 -0
- {pcode_graph-4.2.0 → pcode_graph-4.2.1}/pcode_graph/analysis/load_store.py +0 -0
- {pcode_graph-4.2.0 → pcode_graph-4.2.1}/pcode_graph/analysis/native_pcode.py +0 -0
- {pcode_graph-4.2.0 → pcode_graph-4.2.1}/pcode_graph/analysis/pass_base.py +0 -0
- {pcode_graph-4.2.0 → pcode_graph-4.2.1}/pcode_graph/analysis/passes.py +0 -0
- {pcode_graph-4.2.0 → pcode_graph-4.2.1}/pcode_graph/analysis/program.py +0 -0
- {pcode_graph-4.2.0 → pcode_graph-4.2.1}/pcode_graph/analysis/unreachable.py +0 -0
- {pcode_graph-4.2.0 → pcode_graph-4.2.1}/pcode_graph/arch.py +0 -0
- {pcode_graph-4.2.0 → pcode_graph-4.2.1}/pcode_graph/asm.py +0 -0
- {pcode_graph-4.2.0 → pcode_graph-4.2.1}/pcode_graph/basic_blocks.py +0 -0
- {pcode_graph-4.2.0 → pcode_graph-4.2.1}/pcode_graph/bit_utils.py +0 -0
- {pcode_graph-4.2.0 → pcode_graph-4.2.1}/pcode_graph/characterization.py +0 -0
- {pcode_graph-4.2.0 → pcode_graph-4.2.1}/pcode_graph/checker.py +0 -0
- {pcode_graph-4.2.0 → pcode_graph-4.2.1}/pcode_graph/cli.py +0 -0
- {pcode_graph-4.2.0 → pcode_graph-4.2.1}/pcode_graph/emulator.py +0 -0
- {pcode_graph-4.2.0 → pcode_graph-4.2.1}/pcode_graph/gnn_exporter.py +0 -0
- {pcode_graph-4.2.0 → pcode_graph-4.2.1}/pcode_graph/graph.py +0 -0
- {pcode_graph-4.2.0 → pcode_graph-4.2.1}/pcode_graph/lief_importer.py +0 -0
- {pcode_graph-4.2.0 → pcode_graph-4.2.1}/pcode_graph/log.py +0 -0
- {pcode_graph-4.2.0 → pcode_graph-4.2.1}/pcode_graph/maker.py +0 -0
- {pcode_graph-4.2.0 → pcode_graph-4.2.1}/pcode_graph/nx_exporter.py +0 -0
- {pcode_graph-4.2.0 → pcode_graph-4.2.1}/pcode_graph/pcode.py +0 -0
- {pcode_graph-4.2.0 → pcode_graph-4.2.1}/pcode_graph/registers.py +0 -0
- {pcode_graph-4.2.0 → pcode_graph-4.2.1}/pcode_graph/simplifier.py +0 -0
- {pcode_graph-4.2.0 → pcode_graph-4.2.1}/pcode_graph/torch_utils.py +0 -0
- {pcode_graph-4.2.0 → pcode_graph-4.2.1}/pcode_graph/translator.py +0 -0
- {pcode_graph-4.2.0 → pcode_graph-4.2.1}/pcode_graph/view.py +0 -0
- {pcode_graph-4.2.0 → pcode_graph-4.2.1}/pcode_graph/visitor.py +0 -0
- {pcode_graph-4.2.0 → pcode_graph-4.2.1}/pyproject.toml +0 -0
- {pcode_graph-4.2.0 → pcode_graph-4.2.1}/requirements.txt +0 -0
- {pcode_graph-4.2.0 → pcode_graph-4.2.1}/tests/__init__.py +0 -0
- {pcode_graph-4.2.0 → pcode_graph-4.2.1}/tests/analysis_test.py +0 -0
- {pcode_graph-4.2.0 → pcode_graph-4.2.1}/tests/basic_block_test.py +0 -0
- {pcode_graph-4.2.0 → pcode_graph-4.2.1}/tests/callother_test.py +0 -0
- {pcode_graph-4.2.0 → pcode_graph-4.2.1}/tests/charac_test.py +0 -0
- {pcode_graph-4.2.0 → pcode_graph-4.2.1}/tests/cli_test.py +0 -0
- {pcode_graph-4.2.0 → pcode_graph-4.2.1}/tests/conftest.py +0 -0
- {pcode_graph-4.2.0 → pcode_graph-4.2.1}/tests/def_use_test.py +0 -0
- {pcode_graph-4.2.0 → pcode_graph-4.2.1}/tests/emulator_test.py +0 -0
- {pcode_graph-4.2.0 → pcode_graph-4.2.1}/tests/exporter_test.py +0 -0
- {pcode_graph-4.2.0 → pcode_graph-4.2.1}/tests/fixtures.py +0 -0
- {pcode_graph-4.2.0 → pcode_graph-4.2.1}/tests/helpers.py +0 -0
- {pcode_graph-4.2.0 → pcode_graph-4.2.1}/tests/lief_importer_test.py +0 -0
- {pcode_graph-4.2.0 → pcode_graph-4.2.1}/tests/load_store_test.py +0 -0
- {pcode_graph-4.2.0 → pcode_graph-4.2.1}/tests/maker_test.py +0 -0
- {pcode_graph-4.2.0 → pcode_graph-4.2.1}/tests/memory_state_test.py +0 -0
- {pcode_graph-4.2.0 → pcode_graph-4.2.1}/tests/translator_test.py +0 -0
- {pcode_graph-4.2.0 → pcode_graph-4.2.1}/tests/utils_test.py +0 -0
- {pcode_graph-4.2.0 → pcode_graph-4.2.1}/todo.md +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: pcode_graph
|
|
3
|
-
Version: 4.2.
|
|
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
|
|
203
|
-
self.
|
|
204
|
-
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|