Patent ID: 9442704
Filing Date: 2016-09-13
CPC Classification: G06F

Claim Text:
1. A method for control flow graph flattening of a function of software code, the function comprising a plurality of basic blocks each having an address and at least one instruction, the method, performed by a processor of a device, comprising: assigning a value to at least one diffusion function coefficient of a diffusion function of each of the plurality of basic blocks; calculating changes for labels and diffusion functions indices upon transitions between the plurality of basic blocks, the changes corresponding to modifications made by a linear first branch function and a linear second branch function; creating a dispatcher basic block comprising instructions to look up an address in a jump table and to jump to the address; creating the jump table associating the label of each basic block with the address of the basic block; creating a coefficient array comprising diffusion function coefficients; replacing a jump terminal instruction by a jump to the dispatcher basic block in each of the plurality of basic blocks; creating and inserting into each of the plurality of basic blocks the first branch function and the second branch function, the first branch function taking as input a result of a diffusion function in the present basic block and outputting the label of the subsequent basic block to execute, the second branch function taking as input a diffusion function index of the present basic block and outputting a diffusion function index of the subsequent basic block based; creating and inserting a transition function into the dispatcher basic block, the transition function obtaining the address in the jump table based on at least the label of the subsequent basic block; and creating and inserting diffusion functions in the plurality of basic blocks, a diffusion function inserted in the present basic block calculating a value based on at least one diffusion function coefficient dependant on the diffusion function index and the label of the present basic block.