摘要 |
Control Flow Graph flattening of a function comprising a plurality of basic blocks having an address and at least one instruction. A processor (710) creates (510) a jump table associating a label (X i ) of each basic block with its address, creates (512) a coefficient array comprising constant coefficients, creates (514) a dispatcher basic block comprising instructions to look up an address in the jump table and to jump to the address, replaces (516) a jump terminal instruction by a jump to the dispatcher basic block in each basic block, creates and inserts (520) at least one lookup function in each of the plurality of basic blocks, each lookup function returning a derived value based on a constant coefficient depending on at least an index (P i ) of the basic block; creates and inserts (522) a first branch function (B i ()) calculating the label (X i+1 ) of a subsequent basic block based on at least the derived value, and a second branch function (Bparam i ()) calculating the index (P i+1 ) of the subsequent basic block; and creates and inserts (524) into the dispatcher basic block a transition function (F()) obtaining the address in the jump table based on at least the label (X i+1 ) of a subsequent basic block. |