angr.analyses.decompiler.optimization_passes.switch_reused_entry_rewriter

class angr.analyses.decompiler.optimization_passes.switch_reused_entry_rewriter.SwitchReusedEntryRewriter

Bases: OptimizationPass

For each switch-case construct (identified by jump tables), rewrite the entry into a goto block when we detect situations where an entry node is reused by edges in switch-case constructs that are not the current one. This code reuse is usually caused by compiler code deduplication.

The max_entry_reuse_count parameter controls the maximum number of times an entry can be reused in different jump tables in the same function; exceeding this threshold probably indicates that the jump table recovery is incorrect and thus creating jump tables with too many duplicate entries.

The max_reused_entries parameter controls the maximum number of reused entries that can be found in a function before aborting this optimization.

ARCHES = None
PLATFORMS = None
STAGE: OptimizationPassStage = 0
NAME = 'Rewrite switch-case entry nodes with multiple predecessors into goto statements.'
DESCRIPTION = 'For each switch-case construct (identified by jump tables), rewrite the entry into a goto block when we detect\n    situations where an entry node is reused by edges in switch-case constructs that are not the current one. This code\n    reuse is usually caused by compiler code deduplication.\n\n    The `max_entry_reuse_count` parameter controls the maximum number of times an entry can be reused in different jump\n    tables in the same function; exceeding this threshold probably indicates that the jump table recovery is incorrect\n    and thus creating jump tables with too many duplicate entries.\n\n    The `max_reused_entries` parameter controls the maximum number of reused entries that can be found in a function\n    before aborting this optimization.'
__init__(*args, max_entry_reuse_count=10, max_reused_entries=20, **kwargs)
Parameters:
  • max_entry_reuse_count (int)

  • max_reused_entries (int)