摘要 |
Control Flow Graph flattening of a function of software code comprising a plurality of basic blocks having an address and at least one instruction. A processor (710) creates (508) a dispatcher basic block comprising instructions to look up an address in a jump table and to jump to the address, creates (510) the jump table associating a label (X i ) of each basic block with the address of the basic block, creates (512) a coefficient array comprising diffusion function coefficients, replaces (514) a Jump terminal instruction by a jump to the dispatcher basic block in each of the plurality of basic blocks, creates and inserts (518) a first branch function (B1 i ()) and a second branch function (B2 i ()), the first branch function (B1 i ()) calculating the label (X i+1 ) of a subsequent basic block based on a diffusion function (D Pi ) for the present basic block, the second branch function (B2 i ()) calculating the diffusion function index (P i+1 ) of the subsequent basic block based on the present diffusion function index (P i ), creates and inserts (524) a transition function (F()) into the dispatcher basic block, the transition function obtaining the address in the jump table based on at least the label (X i+1 ) of a subsequent basic block, and creates and inserts (522) diffusion functions (D Pi ) in the plurality of basic blocks, each diffusion function calculating a value based on at least one diffusion coefficient in the coefficient array and the label (X i ) of the present basic block. |