A method and a system for constructing a control flow graph (CFG, 106)
from an executable computer program (104). The solution detects data
intermixed with instructions and instruction set changes. The method
includes the steps of defining block leader types specifying basic block
boundaries in the program (104), building a CFG structure (106) according
to the basic blocks found in the program, and adding control flow and
addressing information to the CFG (106) by propagating through the basic
blocks and internals thereof. The CFG (106) may be then optimised (108)
and a compacted executable (112) created as a result.