A method for control-flow integrity protection, comprising: performing static analysis on a program to be protected to obtain a control flow of the program to be protected; rearranging preset bits of all legal target addresses of a current indirect branch instruction in the control flow of the program to be protected to change to be same, wherein the preset bits of the legal target addresses are low bytes of the legal target addresses; rewriting preset bits of a current target address of the current indirect branch instruction to be same as the preset bits of the legal target addresses, so that the program to be protected terminates when the current target address is tampered with, wherein the preset bits of the current target address are low bytes of the current target address; wherein the rearranging preset bits of all legal target addresses of the current indirect branch instruction in the control flow of the program to be protected to change to be same, comprising: performing a null instruction filling operation on the all legal target addresses respectively, so that preset low bits of all the legal target addresses increase until equal to a label of a current indirect branch instruction, wherein the label of the current indirect branch instruction is preset at random, and the label of the current indirect branch instruction is different from labels of other indirect branch instructions in the program to be protected; and wherein the rewriting preset bits of the current target address of the current indirect branch instruction to be same as the preset bits of the legal target addresses, so that the program to be protected terminates when the current target address is tampered with, comprising: rewriting the preset low bits of the current target address to be same as the label of the current indirect branch instruction, so that the current indirect branch is not able to jump to the legal target addresses when the current target address is tampered with, and the program to be protected terminates, wherein the label is preset low bits of a legal target address of the current indirect branch instruction. performing static analysis on a program to be protected to obtain a control flow of the program to be protected; rearranging preset bits of all legal target addresses of a current indirect branch instruction in the control flow of the program to be protected to change to be same, wherein the preset bits of the legal target addresses are low bytes of the legal target addresses; rewriting preset bits of a current target address of the current indirect branch instruction to be same as the preset bits of the legal target addresses, so that the program to be protected terminates when the current target address is tampered with, wherein the preset bits of the current target address are low bytes of the current target address; wherein the rearranging preset bits of all legal target addresses of the current indirect branch instruction in the control flow of the program to be protected to change to be same, comprising: performing a null instruction filling operation on the all legal target addresses respectively, so that preset low bits of all the legal target addresses increase until equal to a label of a current indirect branch instruction, wherein the label of the current indirect branch instruction is preset at random, and the label of the current indirect branch instruction is different from labels of other indirect branch instructions in the program to be protected; and wherein the rewriting preset bits of the current target address of the current indirect branch instruction to be same as the preset bits of the legal target addresses, so that the program to be protected terminates when the current target address is tampered with, comprising: rewriting the preset low bits of the current target address to be same as the label of the current indirect branch instruction, so that the current indirect branch is not able to jump to the legal target addresses when the current target address is tampered with, and the program to be protected terminates, wherein the label is preset low bits of a legal target address of the current indirect branch instruction. performing a null instruction filling operation on the all legal target addresses respectively, so that preset low bits of all the legal target addresses increase until equal to a label of a current indirect branch instruction, wherein the label of the current indirect branch instruction is preset at random, and the label of the current indirect branch instruction is different from labels of other indirect branch instructions in the program to be protected; and wherein the rewriting preset bits of the current target address of the current indirect branch instruction to be same as the preset bits of the legal target addresses, so that the program to be protected terminates when the current target address is tampered with, comprising: rewriting the preset low bits of the current target address to be same as the label of the current indirect branch instruction, so that the current indirect branch is not able to jump to the legal target addresses when the current target address is tampered with, and the program to be protected terminates, wherein the label is preset low bits of a legal target address of the current indirect branch instruction.