|
39 | 39 |
|
40 | 40 | """ |
41 | 41 |
|
42 | | -from typing import Any, Dict, List, Sequence, Tuple, TYPE_CHECKING |
| 42 | +from typing import Any, Dict, List, Optional, Sequence, Tuple, TYPE_CHECKING |
43 | 43 |
|
44 | 44 | from chb.app.Register import Register |
45 | 45 |
|
@@ -96,6 +96,9 @@ def is_auxiliary_variable(self) -> bool: |
96 | 96 | def is_global_variable(self) -> bool: |
97 | 97 | return False |
98 | 98 |
|
| 99 | + def get_global_variable_address(self) -> Optional[str]: |
| 100 | + return None |
| 101 | + |
99 | 102 | @property |
100 | 103 | def is_global_value(self) -> bool: |
101 | 104 | return False |
@@ -297,6 +300,12 @@ def argument_index(self) -> int: |
297 | 300 | "Assembly variable is not a stack argument: " |
298 | 301 | + str(self)) |
299 | 302 |
|
| 303 | + def get_global_variable_address(self) -> Optional[str]: |
| 304 | + if self.is_global_variable: |
| 305 | + if self.offset.is_constant_value_offset: |
| 306 | + return hex(self.offset.offsetvalue()) |
| 307 | + return None |
| 308 | + |
300 | 309 | def has_unknown_base(self) -> bool: |
301 | 310 | return self.base.is_unknown |
302 | 311 |
|
@@ -417,6 +426,11 @@ def is_auxiliary_variable(self) -> bool: |
417 | 426 | def is_global_value(self) -> bool: |
418 | 427 | return self.auxvar.is_global_value |
419 | 428 |
|
| 429 | + def get_global_variable_address(self) -> Optional[str]: |
| 430 | + if self.is_global_value: |
| 431 | + return self.auxvar.get_global_variable_address() |
| 432 | + return None |
| 433 | + |
420 | 434 | @property |
421 | 435 | def is_stack_base_address(self) -> bool: |
422 | 436 | return self.auxvar.is_stack_base_address |
|
0 commit comments