angr.go.optimization_passes.string_compares¶
String comparisons the Go compiler lowers to a length check plus little-endian word compares of the bytes.
- class angr.go.optimization_passes.string_compares.LengthFacts¶
Bases:
objectWhat the dominating branches say about integer values (string lengths) at a block.
- __init__(rewriter)¶
- Parameters:
rewriter (GoBuiltinRewriter)
- at(block)¶
(value, interval) pairs, nearest guard first.
- Return type:
list[tuple[Expression,_Interval]]- Parameters:
block (Block)
- class angr.go.optimization_passes.string_compares.StringCompareFolder¶
Bases:
objectlen(s) == ndominating a chain of word compares*(*uintK)(s.ptr + k) == cthat together cover the n bytes of a printable string and all fail to the same place: the first compare becomess == "..."and the rest become jumps. When the length check itself leads to the chain and fails to the same place, it becomes the string compare instead. “The same place” looks through jump-only blocks and constant branches.- __init__(rewriter, facts)¶
- Parameters:
rewriter (GoBuiltinRewriter)
facts (LengthFacts)
- class angr.go.optimization_passes.string_compares.StringSwitchFlattener¶
Bases:
objectA string switch dispatches on the length and on single bytes before comparing whole strings. Once those compares are
s == "...", the dispatch only routes each literal to its own compare: it becomes a chain of the compares in address order, so the cases structure as one if/else-if chain overs.- __init__(rewriter)¶
- Parameters:
rewriter (GoBuiltinRewriter)