mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-08-02 23:26:31 +00:00
Add Forward Control-Flow Integrity.
This commit adds a new pass that can inject checks before indirect calls to make sure that these calls target known locations. It supports three types of checks and, at compile time, it can take the name of a custom function to call when an indirect call check fails. The default failure function ignores the error and continues. This pass incidentally moves the function JumpInstrTables::transformType from private to public and makes it static (with a new argument that specifies the table type to use); this is so that the CFI code can transform function types at call sites to determine which jump-instruction table to use for the check at that site. Also, this removes support for jumptables in ARM, pending further performance analysis and discussion. Review: http://reviews.llvm.org/D4167 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@221708 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -37,7 +37,9 @@ class JumpInstrTableInfo : public ImmutablePass {
|
||||
public:
|
||||
static char ID;
|
||||
|
||||
JumpInstrTableInfo();
|
||||
/// The default byte alignment for jump tables is 16, which is large but
|
||||
/// usually safe.
|
||||
JumpInstrTableInfo(uint64_t ByteAlign = 16);
|
||||
virtual ~JumpInstrTableInfo();
|
||||
const char *getPassName() const override {
|
||||
return "Jump-Instruction Table Info";
|
||||
@@ -52,9 +54,19 @@ public:
|
||||
/// Gets the tables.
|
||||
const JumpTables &getTables() const { return Tables; }
|
||||
|
||||
/// Gets the alignment in bytes of a jumptable entry.
|
||||
uint64_t entryByteAlignment() const { return ByteAlignment; }
|
||||
private:
|
||||
JumpTables Tables;
|
||||
|
||||
/// A power-of-two alignment of a jumptable entry.
|
||||
uint64_t ByteAlignment;
|
||||
};
|
||||
|
||||
/// Creates a JumpInstrTableInfo pass with the given bound on entry size. This
|
||||
/// bound specifies the maximum number of bytes needed to represent an
|
||||
/// unconditional jump or a trap instruction in the back end currently in use.
|
||||
ModulePass *createJumpInstrTableInfoPass(unsigned Bound);
|
||||
}
|
||||
|
||||
#endif /* LLVM_ANALYSIS_JUMPINSTRTABLEINFO_H */
|
||||
|
Reference in New Issue
Block a user