Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion chb/app/CHVersion.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
chbversion: str = "0.3.0-20250823"
chbversion: str = "0.3.0-20250825"
6 changes: 1 addition & 5 deletions chb/app/CfgBlock.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# ------------------------------------------------------------------------------
# The MIT License (MIT)
#
# Copyright (c) 2021-2024 Aarno Labs LLC
# Copyright (c) 2021-2025 Aarno Labs LLC
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -92,10 +92,6 @@ def is_in_trampoline(self) -> bool:
def is_trampoline(self) -> bool:
return False

@property
def is_trampoline_minimal_pair_2_and_3(self) -> bool:
return False

@property
def roles(self) -> Dict[str, str]:
return {}
Expand Down
8 changes: 1 addition & 7 deletions chb/arm/ARMCfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# ------------------------------------------------------------------------------
# The MIT License (MIT)
#
# Copyright (c) 2021-2024 Aarno Labs LLC
# Copyright (c) 2021-2025 Aarno Labs LLC
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -201,12 +201,6 @@ def get_inlinemap_addrs(start: str, size: int) -> List[str]:

trampolines[baddr] = trinfo = TrampolineInfo(patchevent)

if patchevent.is_trampoline_pair_minimal_2_and_3:
chklogger.logger.info("Trampoline pair minimal 2 and 3 %s", baddr)
trinfo.add_role("payload", baddr)
trampolineblocks[baddr] = baddr
continue

trinfo.add_role("setupblock", baddr)
trampolineblocks[baddr] = baddr

Expand Down
6 changes: 1 addition & 5 deletions chb/arm/ARMCfgBlock.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# ------------------------------------------------------------------------------
# The MIT License (MIT)
#
# Copyright (c) 2021-2024 Aarno Labs LLC
# Copyright (c) 2021-2025 Aarno Labs LLC
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -129,10 +129,6 @@ def lastaddr(self) -> str:
def is_trampoline(self) -> bool:
return self.trampoline_info.patchevent.is_trampoline

@property
def is_trampoline_minimal_pair_2_and_3(self) -> bool:
return self.trampoline_info.patchevent.is_trampoline_pair_minimal_2_and_3

@property
def trampoline_info(self) -> "TrampolineInfo":
return self._trinfo
Expand Down
16 changes: 1 addition & 15 deletions chb/cmdline/PatchResults.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,13 +320,9 @@ def logicalva(self) -> str:
def is_trampoline(self) -> bool:
return self.patchkind == "Trampoline"

@property
def is_trampoline_pair_minimal_2_and_3(self) -> bool:
return self.patchkind == "TrampolinePairMinimal2and3"

@property
def is_supported(self) -> bool:
return (self.is_trampoline or self.is_trampoline_pair_minimal_2_and_3)
return self.is_trampoline

def has_details(self) -> bool:
return "details" in self._d
Expand Down Expand Up @@ -435,16 +431,6 @@ def trampoline_addresses(self) -> List[Dict[str, str]]:
if e.case_fallthrough_jump is not None:
r["fallthrough-jump"] = e.case_fallthrough_jump
result.append(r)
elif e.is_trampoline_pair_minimal_2_and_3:
r["logicalva"] = e.logicalva
r["kind"] = "trampoline-pair-minimal-2-and-3"
if e.has_wrapper():
r["wrapper"] = e.wrapper.vahex
if e.has_fallthrough_destination() and e.fallthrough_destination:
r["fallthrough"] = e.fallthrough_destination
if e.case_fallthrough_jump is not None:
r["fallthrough-jump"] = e.case_fallthrough_jump
result.append(r)
return result


Expand Down
4 changes: 1 addition & 3 deletions chb/cmdline/astcmds.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,7 @@ def buildast(args: argparse.Namespace) -> NoReturn:
if patchresultsdata is not None:
patchresults = PatchResults(patchresultsdata)
for event in patchresults.events:
if (
event.is_trampoline
or event.is_trampoline_pair_minimal_2_and_3):
if event.is_trampoline:
if event.has_wrapper():
startaddr = event.wrapper.vahex
patchevents[startaddr] = event
Expand Down
10 changes: 3 additions & 7 deletions chb/cmdline/relationalcmds.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# ------------------------------------------------------------------------------
# The MIT License (MIT)
#
# Copyright (c) 2021-2024 Aarno Labs, LLC
# Copyright (c) 2021-2025 Aarno Labs, LLC
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -372,9 +372,7 @@ def _relational_compare_generate_json(xname1: str,
if patchresultsdata is not None:
patchresults = PatchResults(patchresultsdata)
for event in patchresults.events:
if (
event.is_trampoline
or event.is_trampoline_pair_minimal_2_and_3):
if event.is_trampoline:
if event.has_wrapper():
startaddr = event.wrapper.vahex
patchevents[startaddr] = event
Expand Down Expand Up @@ -600,9 +598,7 @@ def relational_compare_cfgs_cmd(args: argparse.Namespace) -> NoReturn:
if patchresultsdata is not None:
patchresults = PatchResults(patchresultsdata)
for event in patchresults.events:
if (
event.is_trampoline
or event.is_trampoline_pair_minimal_2_and_3):
if event.is_trampoline:
if event.has_wrapper():
startaddr = event.wrapper.vahex
patchevents[startaddr] = event
Expand Down
7 changes: 0 additions & 7 deletions chb/jsoninterface/JSONFunctionComparison.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,6 @@ def trampoline_address(self) -> Optional[str]:
if role == "setupblock":
return b_addr

else:
# the TrampolinePairMinimal2and3 patch has just one block: payload
# (which is called wrapper in the patch results file)
for (b_addr, role) in self.cfg2_blocks:
if role == "payload":
return b_addr

return None

def accept(self, visitor: "JSONObjectVisitor") -> None:
Expand Down
59 changes: 28 additions & 31 deletions chb/relational/FunctionRelationalAnalysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# ------------------------------------------------------------------------------
# The MIT License (MIT)
#
# Copyright (c) 2021-2024 Aarno Labs, LLC
# Copyright (c) 2021-2025 Aarno Labs, LLC
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -384,11 +384,6 @@ def block_analyses(self) -> Mapping[str, BlockRelationalAnalysis]:
trampoline = self.has_trampoline()
if trampoline is not None:
self.setup_trampoline_analysis(trampoline)
else:
trampoline_minimal_pair_2_and_3 = self.has_minimal_pair_2_and_3_trampoline()
if trampoline_minimal_pair_2_and_3 is not None:
self.setup_minimal_pair_2_and_3_trampoline_analysis(
trampoline_minimal_pair_2_and_3)

return self._blockanalyses

Expand All @@ -408,8 +403,8 @@ def setup_trampoline_analysis(self, b: str) -> None:
tpre[0] in cfg2unmapped
and tpost[0] in cfg2unmapped
and tpre[0] in cfg1unmapped):
# Case where trampoline has an early return and a fallthrough case
# (what we mark as the exit block)
# Case where trampoline has an early return and a fallthrough
# case (what we mark as the exit block)
roles["entry"] = self.basic_blocks2[tpre[0]]
roles["exit"] = self.basic_blocks2[tpost[0]]
for (role, addr) in trampoline.roles.items():
Expand All @@ -420,33 +415,40 @@ def setup_trampoline_analysis(self, b: str) -> None:
self.app2,
roles)
else:
chklogger.logger.warning("Found unhandled trampoline case. Should be an early return "
"trampoline (pre %s, post %s), but the blocks are not "
"in the unmapped lists. cfg1: %s, cfg2: %s",
tpre[0], tpost[0], cfg1unmapped, cfg2unmapped)
chklogger.logger.warning(
"Found unhandled trampoline case. Should be an early "
"return trampoline (pre %s, post %s), but the blocks "
" are not in the unmapped lists. cfg1: %s, cfg2: %s",
tpre[0], tpost[0], cfg1unmapped, cfg2unmapped)
elif len(tpre) == 1 and len(tpost) == 2:
# Trampoline has a continue statement.
# One of the post blocks is the fallthrough/exit, one is the loop continuation.
# One of the post blocks is the fallthrough/exit, one is the
# loop continuation.
# Need to figure out which one is which
if not 'continuepath' in trampoline.roles:
chklogger.logger.error("Found unsupported trampoline case, "
"There are 2 post trampoline blocks %s but no continuepath role %s",
tpost, trampoline.roles)
chklogger.logger.error(
"Found unsupported trampoline case, "
"There are 2 post trampoline blocks %s but no "
"continuepath role %s",
tpost, trampoline.roles)
return

cont = self.basic_blocks2[trampoline.roles['continuepath']]
cont_post = self.cfg2.edges[cont.baddr]
if len(cont_post) != 1:
chklogger.logger.error("Found unsupported trampoline case, "
"continue block %s has more than one outgoing edges: %s",
cont.baddr, cont_post)
chklogger.logger.error(
"Found unsupported trampoline case, "
"continue block %s has more than one outgoing edges: %s",
cont.baddr, cont_post)
return
fallthrough = self.basic_blocks2[trampoline.roles['fallthrough']]
fallthrough_post = self.cfg2.edges[fallthrough.baddr]
if len(fallthrough_post) != 1:
chklogger.logger.error("Found unsupported trampoline case, "
"fallthrough block %s has more than one outgoing edges: %s",
fallthrough.baddr, fallthrough_post)
chklogger.logger.error(
"Found unsupported trampoline case, "
"fallthrough block %s has more than one outgoing edges: "
"%s",
fallthrough.baddr, fallthrough_post)
return

roles["entry"] = self.basic_blocks2[tpre[0]]
Expand All @@ -459,9 +461,10 @@ def setup_trampoline_analysis(self, b: str) -> None:
self.app2,
roles)
else:
chklogger.logger.warning("Found unhandled trampoline case. Have %d pre-blocks "
"%d post-blocks. pre: %s, post %s",
len(tpre), len(tpost), tpre, tpost)
chklogger.logger.warning(
"Found unhandled trampoline case. Have %d pre-blocks "
"%d post-blocks. pre: %s, post %s",
len(tpre), len(tpost), tpre, tpost)

def setup_minimal_pair_2_and_3_trampoline_analysis(self, b: str) -> None:
chklogger.logger.info("Setup minimal_pair_2_and_3_trampoline at %s", b)
Expand Down Expand Up @@ -494,12 +497,6 @@ def has_trampoline(self) -> Optional[str]:
return b
return None

def has_minimal_pair_2_and_3_trampoline(self) -> Optional[str]:
for (b, cfgb) in self.cfgtc_blocks2.items():
if cfgb.is_trampoline_minimal_pair_2_and_3:
return b
return None

def blocks_changed(self) -> List[str]:
"""Return a list of block addresses that are not md5-equal."""

Expand Down
Loading