Skip to content

Commit

Permalink
fix (#402)
Browse files Browse the repository at this point in the history
  • Loading branch information
rihi authored Mar 28, 2024
1 parent d9b8337 commit 4d9cd14
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions decompiler/pipeline/preprocessing/missing_definitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,8 @@ def _memory_instruction_changes_variable(self, memory_instruction: Instruction,
return False
if self._is_assignment_of_variable_address(memory_instruction):
return False
if isinstance(variable, GlobalVariable): # Global variables could always change in memory instructions
return True
return self._uses_variable_related_to_aliased_variable(memory_instruction, variable)

def _uses_variable_related_to_aliased_variable(self, memory_instruction: Instruction, variable: Variable) -> bool:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1017,7 +1017,7 @@ def test_missing_definitions_for_global_variables_are_correct():
+--------------------+ +--------------------+
| 0. | | 0. |
| rand() | | rand() |
| var#0 = g#1 | | g#1 = g#0 |
| var#0 = g#1 | | g#1 -> g#0 |
| if(var#0 < 0xa) | -+ | var#0 = g#1 |
+--------------------+ | | if(var#0 < 0xa) | -+
| | +--------------------+ |
Expand Down Expand Up @@ -1055,7 +1055,7 @@ def test_missing_definitions_for_global_variables_are_correct():
cfg.add_edges_from([UnconditionalEdge(n0, n1), UnconditionalEdge(n0, n2), UnconditionalEdge(n1, n2)])
task = DecompilerTask("test", cfg)
InsertMissingDefinitions().run(task)
expected_inserted_definition = Assignment(globals[1], globals[0])
expected_inserted_definition = Relation(globals[1], globals[0])
inserted_definition: Assignment = n0.instructions[1]
assert inserted_definition == expected_inserted_definition
assert inserted_definition.writes_memory == 1
Expand Down

0 comments on commit 4d9cd14

Please sign in to comment.