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,3 +1,3 @@
chbversion: str = "0.3.0-20260930"
chbversion: str = "0.3.20261001"

minimum_required_chb_version = "0.6.0_20260802"
97 changes: 97 additions & 0 deletions chb/arm/opcodes/ARMSignedExtendAddByte.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
# ------------------------------------------------------------------------------
# CodeHawk Binary Analyzer
# Author: Henny Sipma
# ------------------------------------------------------------------------------
# The MIT License (MIT)
#
# Copyright (c) 2026 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
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
# ------------------------------------------------------------------------------

from typing import List, TYPE_CHECKING

from chb.app.InstrXData import InstrXData

from chb.arm.ARMDictionaryRecord import armregistry
from chb.arm.ARMOpcode import ARMOpcode, ARMOpcodeXData, simplify_result
from chb.arm.ARMOperand import ARMOperand

import chb.util.fileutil as UF

from chb.util.IndexedTable import IndexedTableValue

if TYPE_CHECKING:
from chb.arm.ARMDictionary import ARMDictionary
from chb.invariants.XVariable import XVariable
from chb.invariants.XXpr import XXpr


class ARMSignedExtendAddByteXData(ARMOpcodeXData):
"""SXTAB <rd>, <rn>, <rm>"""

def __init__(self, xdata: InstrXData) -> None:
ARMOpcodeXData.__init__(self, xdata)

@property
def vrd(self) -> "XVariable":
return self.var(0, "vrd")

@property
def xrn(self) -> "XXpr":
return self.xpr(0, "xrn")

@property
def xxrn(self) -> "XXpr":
return self.xpr(2, "xxrn")

@property
def xrm(self) -> "XXpr":
return self.xpr(1, "xrm")

@property
def xxrm(self) -> "XXpr":
return self.xpr(3, "xxrm")


@armregistry.register_tag("SXTAB", ARMOpcode)
class ARMSignedExtendAddByte(ARMOpcode):
"""
tags[1]: <c>
args[0]: index of rd in armdictionary
args[1]: index of rn in armdictionary
args[2]: index of rm in armdictionary
"""

def __init__(self, d: "ARMDictionary", ixval: IndexedTableValue) -> None:
ARMOpcode.__init__(self, d, ixval)
self.check_key(2, 3, "SignedExtendAddByte")

@property
def operands(self) -> List[ARMOperand]:
return [self.armd.arm_operand(self.args[i]) for i in [0, 1, 2]]

def annotation(self, xdata: InstrXData) -> str:
xd = ARMSignedExtendAddByteXData(xdata)
if xd.is_ok:
lhs = str(xd.vrd)
result = str(xd.xxrn) + " + sign_extend_byte(" + str(xd.xxrm) + ")"
return lhs + " := " + result
else:
return "Error value"
75 changes: 75 additions & 0 deletions chb/arm/opcodes/ARMVectorFusedMultiplySubtract.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# ------------------------------------------------------------------------------
# CodeHawk Binary Analyzer
# Author: Henny Sipma
# ------------------------------------------------------------------------------
# The MIT License (MIT)
#
# Copyright (c) 2026 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
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
# ------------------------------------------------------------------------------

from typing import List, TYPE_CHECKING

from chb.app.InstrXData import InstrXData

from chb.arm.ARMDictionaryRecord import armregistry
from chb.arm.ARMOpcode import ARMOpcode, simplify_result
from chb.arm.ARMOperand import ARMOperand

import chb.util.fileutil as UF

from chb.util.IndexedTable import IndexedTableValue

if TYPE_CHECKING:
from chb.arm.ARMDictionary import ARMDictionary
from chb.arm.ARMVfpDatatype import ARMVfpDatatype


@armregistry.register_tag("VFMS", ARMOpcode)
class ARMVectorFusedMultiplySubtract(ARMOpcode):
"""
VFMS<c>.<dt> <Dd>, <Dn>, <Dm>

tags[1]: <c>
args[0]: index of datatype in armdictionary
args[1]: index of Dd in armdictionary
args[2]: index of Dn in armdictionary
args[3]: index of Dm in armdictionary
"""

def __init__(self, d: "ARMDictionary", ixval: IndexedTableValue) -> None:
ARMOpcode.__init__(self, d, ixval)
self.check_key(2, 4, "VectorFusedMultiplySubtract")

@property
def operands(self) -> List[ARMOperand]:
return [self.armd.arm_operand(self.args[i]) for i in [1, 2, 3]]

def mnemonic_extension(self) -> str:
cc = ARMOpcode.mnemonic_extension(self)
vfpdt = str(self.vfp_datatype)
return cc + vfpdt

@property
def vfp_datatype(self) -> "ARMVfpDatatype":
return self.armd.arm_vfp_datatype(self.args[0])

def annotation(self, xdata: InstrXData) -> str:
return "pending"
35 changes: 33 additions & 2 deletions chb/arm/opcodes/opcodes_covered.json
Original file line number Diff line number Diff line change
Expand Up @@ -3108,14 +3108,29 @@
},
"TC": "DA"
},
"SXTAB": {
"name": "SignedExtendAddByte",
"encodings": {
"all": [
{
"T": "A1",
"E": "<cc><3>< 10><rn><rd>ro000111<rm>",
"D": "Y",
"U": ["7330a2e6"]
}
]
},
"TC": "DA"
},
"SXTB": {
"name": "SignedExtendByte",
"encodings": {
"all": [
{
"T": "A1",
"E": "<cc><3>< 10><15><rd>ro0< 7><rm>",
"D": "Y"
"D": "Y",
"U": ["7430afe6"]
},
{
"T": "T1",
Expand Down Expand Up @@ -3938,7 +3953,10 @@
"T": "A1"
},
{
"T": "A2"
"T": "A2",
"E": "<cc><7>01D10<vn><vd>101sN0M0<vm>",
"D": "Y",
"U": ["007ba8ee"]
},
{
"T": "T1"
Expand All @@ -3954,6 +3972,19 @@
]
}
},
"VFMS": {
"name": "VectorFusedMultiplySubtract",
"encodings": {
"all": [
{
"T": "A2",
"E": "<cc><7>01D10<vn><vd>101sN1M0<vm>",
"D": "Y",
"U": ["e20be1ee"]
}
]
}
},
"VLD1": {
"name": "VectorLoadOne",
"encodings": {
Expand Down
3 changes: 3 additions & 0 deletions chb/cmdline/AnalysisManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ def disassemble(
save_asm: str = "yes",
save_asm_cfg_info: bool = False,
save_asm_callgraph: bool = False,
save_asm_instructions: bool = False,
print_datasections: List[str] = []) -> None:
cwd = os.getcwd()
chklogger.logger.debug("change directory to %s", self.path)
Expand All @@ -246,6 +247,8 @@ def disassemble(
cmd.append("-save_asm_cfg_info")
if save_asm_callgraph:
cmd.append("-save_asm_callgraph")
if save_asm_instructions:
cmd.append("-save_asm_instructions")
if collectdiagnostics:
cmd.append("-diagnostics")
if self.mips:
Expand Down
4 changes: 4 additions & 0 deletions chb/cmdline/chkx
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,10 @@ def parse() -> argparse.Namespace:
"--save_asm_callgraph",
action="store_true",
help="save list of callgraph edges (without argument info) in xml")
analyzecmd.add_argument(
"--save_asm_instructions",
action="store_true",
help="save list of assembly instructions in xml")
analyzecmd.add_argument(
"--construct_all_functions",
action="store_true",
Expand Down
2 changes: 2 additions & 0 deletions chb/cmdline/commandutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,7 @@ def analyzecmd(args: argparse.Namespace) -> NoReturn:
save_asm: bool = args.save_asm
save_asm_cfg_info: bool = args.save_asm_cfg_info
save_asm_callgraph: bool = args.save_asm_callgraph
save_asm_instructions: bool = args.save_asm_instructions
print_datasections: List[str] = args.print_datasections
thumb: List[str] = args.thumb
floatabi: Optional[str] = args.float_abi
Expand Down Expand Up @@ -576,6 +577,7 @@ def analyzecmd(args: argparse.Namespace) -> NoReturn:
preamble_cutoff=preamble_cutoff,
save_asm_cfg_info=save_asm_cfg_info,
save_asm_callgraph=save_asm_callgraph,
save_asm_instructions=save_asm_instructions,
print_datasections=print_datasections)
except subprocess.CalledProcessError as e:
print_error(str(e.output))
Expand Down