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: object

What 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: object

len(s) == n dominating a chain of word compares *(*uintK)(s.ptr + k) == c that together cover the n bytes of a printable string and all fail to the same place: the first compare becomes s == "..." 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:
fold()
Return type:

int

class angr.go.optimization_passes.string_compares.StringSwitchFlattener

Bases: object

A 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 over s.

__init__(rewriter)
Parameters:

rewriter (GoBuiltinRewriter)

flatten()
Return type:

int