diff options
author | Martin Nowack <m.nowack@imperial.ac.uk> | 2020-06-04 12:09:47 +0100 |
---|---|---|
committer | Cristian Cadar <c.cadar@imperial.ac.uk> | 2020-10-09 21:34:43 +0100 |
commit | 838b0b1930da796f157cd6f4b11145de4d7c4e4e (patch) | |
tree | e9df758b8d24f73a855d6df009bcf4875b9228c4 /test/Feature | |
parent | 3aa92e3d997b5bbb626957bed52658677e9a3ef8 (diff) | |
download | klee-838b0b1930da796f157cd6f4b11145de4d7c4e4e.tar.gz |
Add testcase for weakly linked globals
Diffstat (limited to 'test/Feature')
-rw-r--r-- | test/Feature/GlobalVariable.ll | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/test/Feature/GlobalVariable.ll b/test/Feature/GlobalVariable.ll new file mode 100644 index 00000000..7b567bcb --- /dev/null +++ b/test/Feature/GlobalVariable.ll @@ -0,0 +1,28 @@ +; RUN: llvm-as %s -f -o %t1.bc +; RUN: rm -rf %t.klee-out +; Run KLEE and expect it to error out but not crash +; RUN: not %klee --output-dir=%t.klee-out --optimize=false %t1.bc 2> %t2 +; Check that it could not find an initializer for the external_function global +; RUN: FileCheck %s --input-file %t2 +; CHECK: ERROR: Unable to load symbol(external_function) while initializing globals + +@external_function = extern_weak global i8 +@bar = internal thread_local global <{ [56 x i8] }> zeroinitializer, align 32 +@handle = global i8* null, align 8 + +define internal void @foo(i8* nocapture) { +entry: + ret void +} + +define i32 @main(i32 %argc, i8** nocapture %argv) nounwind readnone { +entry: + br i1 icmp ne (i8* @external_function, i8* null), label %bbtrue, label %bbfalse + +bbtrue: + %0 = tail call i32 bitcast (i8* @external_function to i32 (void (i8*)*, i8*, i8*)*)(void (i8*)* nonnull @foo, i8* getelementptr inbounds (<{ [56 x i8] }>, <{ [56 x i8] }>* @bar, i64 0, i32 0, i64 0), i8* bitcast (i8** @handle to i8*)) + ret i32 0 + +bbfalse: + ret i32 1 +} |