mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-01 15:33:33 +00:00
21befa7761
A pass that adds random noops to X86 binaries to introduce diversity with the goal of increasing security against most return-oriented programming attacks. Command line options: -noop-insertion // Enable noop insertion. -noop-insertion-percentage=X // X% of assembly instructions will have a noop prepended (default: 50%, requires -noop-insertion) -max-noops-per-instruction=X // Randomly generate X noops per instruction. ie. roll the dice X times with probability set above (default: 1). This doesn't guarantee X noop instructions. In addition, the following 'quick switch' in clang enables basic diversity using default settings (currently: noop insertion and schedule randomization; it is intended to be extended in the future). -fdiversify This is the llvm part of the patch. clang part: D3393 http://reviews.llvm.org/D3392 Patch by Stephen Crane (@rinon) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225908 91177308-0d34-0410-b5e6-96231b3b80d8
32 lines
838 B
LLVM
32 lines
838 B
LLVM
; RUN: llc < %s -march=ppc32 -noop-insertion | FileCheck %s
|
|
; RUN: llc < %s -march=ppc32 -noop-insertion -rng-seed=1 | FileCheck %s --check-prefix=SEED1
|
|
; RUN: llc < %s -march=ppc32 -noop-insertion -noop-insertion-percentage=100 | FileCheck %s --check-prefix=100PERCENT
|
|
|
|
; This test case checks that NOOPs are inserted correctly for PowerPC.
|
|
|
|
; It just happens that with a default percentage of 25% and seed=0,
|
|
; no NOOPs are inserted.
|
|
; CHECK: mullw
|
|
; CHECK-NEXT: add
|
|
; CHECK-NEXT: blr
|
|
|
|
; SEED1: nop
|
|
; SEED1-NEXT: mullw
|
|
; SEED1-NEXT: add
|
|
; SEED1-NEXT: nop
|
|
; SEED1-NEXT: blr
|
|
|
|
; 100PERCENT: nop
|
|
; 100PERCENT-NEXT: mullw
|
|
; 100PERCENT-NEXT: nop
|
|
; 100PERCENT-NEXT: add
|
|
; 100PERCENT-NEXT: nop
|
|
; 100PERCENT-NEXT: blr
|
|
|
|
define i32 @test1(i32 %x, i32 %y, i32 %z) {
|
|
entry:
|
|
%tmp = mul i32 %x, %y
|
|
%tmp2 = add i32 %tmp, %z
|
|
ret i32 %tmp2
|
|
}
|