1
0
This commit is contained in:
Aiden
2026-05-27 21:37:50 +10:00
parent 21f0e455ee
commit 4364d0ed48
54 changed files with 30241 additions and 191 deletions

View File

@@ -287,6 +287,7 @@ def _logical_operand_accesses(
logical_address: int | None = None
if isinstance(offset, int):
logical_address = (int(table["logical_base_address"]) + offset) & 0xFFFF
selector = _selector_for_table_offset(table, offset)
access = _base_access(ins, functions, semantic_accesses)
access.update(
{
@@ -306,6 +307,9 @@ def _logical_operand_accesses(
if logical_address is not None:
access["logical_address"] = logical_address
access["logical_address_hex"] = h16(logical_address)
if selector is not None:
access["selector"] = selector
access["selector_hex"] = f"0x{selector:03X}"
accesses.append(access)
return accesses
@@ -342,6 +346,7 @@ def _direct_logical_address_access(
) -> JsonObject:
base = int(table["logical_base_address"])
offset = address - base
selector = _selector_for_table_offset(table, offset)
access = _base_access(ins, functions, semantic_accesses)
access.update(
{
@@ -359,6 +364,9 @@ def _direct_logical_address_access(
"access": _access_direction(ins, address) or "read_write_candidate",
}
)
if selector is not None:
access["selector"] = selector
access["selector_hex"] = f"0x{selector:03X}"
return access
@@ -373,6 +381,7 @@ def _direct_candidate_address_access(
offset = address - base
access = _base_access(ins, functions, semantic_accesses)
logical_offset = DIRECT_TABLE_TO_LOGICAL_OFFSET.get(base)
selector = _selector_for_table_offset(table, offset)
access.update(
{
"table": table["name"],
@@ -392,6 +401,9 @@ def _direct_candidate_address_access(
if logical_offset is not None:
access["semantic_negative_offset"] = logical_offset
access["semantic_negative_offset_hex"] = h16(logical_offset)
if selector is not None:
access["selector"] = selector
access["selector_hex"] = f"0x{selector:03X}"
return access
@@ -564,6 +576,8 @@ def _format_access_line(access: Mapping[str, Any]) -> str:
index_text = f"index dynamic via {access.get('index_register')} operand {operand}"
else:
index_text = f"offset {h16(int(index or 0))}"
if access.get("selector_hex"):
index_text += f" selector {access['selector_hex']}"
if access.get("logical_address_hex"):
index_text += f" -> {access['logical_address_hex']}"
elif access.get("direct_address_hex"):
@@ -599,6 +613,19 @@ def _summarize_functions(accesses: Iterable[Mapping[str, Any]]) -> list[JsonObje
return sorted(summaries.values(), key=lambda item: (-int(item["access_count"]), str(item["label"])))
def _selector_for_table_offset(table: Mapping[str, Any], offset: int | str) -> int | None:
if not isinstance(offset, int):
return None
element = str(table.get("element_candidate") or "")
if element == "word_value":
if offset % 2:
return None
return (offset // 2) & 0x01FF
if element == "bit_flags":
return offset & 0x01FF
return None
def _function_ranges(payload: Mapping[str, Any]) -> list[JsonObject]:
call_graph = payload.get("call_graph")
if not isinstance(call_graph, Mapping):