diff --git a/decompiler/pipeline/preprocessing/missing_definitions.py b/decompiler/pipeline/preprocessing/missing_definitions.py index e84cfacd5..3b2b1b0a6 100644 --- a/decompiler/pipeline/preprocessing/missing_definitions.py +++ b/decompiler/pipeline/preprocessing/missing_definitions.py @@ -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: diff --git a/tests/pipeline/preprocessing/test_insert_missing_definition.py b/tests/pipeline/preprocessing/test_insert_missing_definition.py index f292f2985..a2f968ea7 100644 --- a/tests/pipeline/preprocessing/test_insert_missing_definition.py +++ b/tests/pipeline/preprocessing/test_insert_missing_definition.py @@ -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) | -+ | | +--------------------+ | @@ -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