Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(215)

Side by Side Diff: test/Transforms/NaCl/sandbox-indirect-calls.ll

Issue 29743003: Add passes for applying SFI sandboxing at the LLVM IR level Base URL: http://git.chromium.org/native_client/pnacl-llvm.git@master
Patch Set: Retry upload Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 ; RUN: opt < %s -sandbox-indirect-calls -S | FileCheck %s
2
3 @addr_taker_var1 = global i32 ptrtoint (void ()* @target_func1 to i32)
4 @addr_taker_var2 = global i32 ptrtoint (i32 (i32)* @target_func2 to i32)
5
6 ; CHECK: @addr_taker_var1 = global i32 1
7 ; CHECK: @addr_taker_var2 = global i32 2
8
9 ; CHECK: @__sfi_function_table = internal constant [3 x i8*] [i8* null, i8* bitc ast (void ()* @target_func1 to i8*), i8* bitcast (i32 (i32)* @target_func2 to i8 *)]
10
11
12 define void @target_func1() {
13 ret void
14 }
15
16 define i32 @target_func2(i32 %arg) {
17 ret i32 %arg
18 }
19
20 ; Direct calls should be left alone.
21 define void @direct_call() {
22 call void @target_func1()
23 call i32 @target_func2(i32 123)
24 ret void
25 }
26 ; CHECK: define void @direct_call() {
27 ; CHECK: call void @target_func1()
28 ; CHECK: call i32 @target_func2(i32 123)
29
30 define i32 @addr_taker_func() {
31 %func = ptrtoint void ()* @target_func1 to i32
32 ret i32 %func
33 }
34 ; CHECK: define i32 @addr_taker_func()
35 ; CHECK-NEXT: ret i32 1
36
37 define void @caller(i32 %func) {
38 %func2 = inttoptr i32 %func to void ()*
39 call void %func2()
40 ret void
41 }
42 ; CHECK: define void @caller(i32 %func) {
43 ; CHECK-NEXT: %func_gep = getelementptr {{.*}} @__sfi_function_table, i32 0, i32 %func
44 ; CHECK-NEXT: %func1 = load i8** %func_gep
45 ; CHECK-NEXT: %func_bc = bitcast i8* %func1 to void ()*
46 ; CHECK-NEXT: call void %func_bc()
47
48
49 ; Example of a function which doesn't follow the normal form, and
50 ; which isn't handled.
51 ;
52 ; declare void @f(...)
53 ;
54 ; define void @use_as_arg() {
55 ; call void (...)* @f(void ()* @target_func)
56 ; ret void
57 ; }
OLDNEW
« no previous file with comments | « test/Transforms/NaCl/flatten-globals.ll ('k') | test/Transforms/NaCl/sandbox-memory-accesses.ll » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698