Discussion:
Running Multifile Applications using Klee
Saikat Dutta
2013-09-17 18:25:13 UTC
Permalink
Hi,
I am working on a research project where i need to run multiple file
programs using klee. I am actually testing the gzip utility which contains
a number of .c and .h files. Can you help me in this regard?

Thanks.
-Saikat
Lei Zhang
2013-09-18 18:21:26 UTC
Permalink
Hi Saikat,
From my understanding, every .c file is compiled and then linked to the
final binary. By running KLEE on that binary, you are touching code in all
these source files. And you can verify that by checking the 'gcov' output.

Or maybe I didn't fully understand your concern? Could you specify your
tasks more clearly?
Hi,
I am working on a research project where i need to run multiple file
programs using klee. I am actually testing the gzip utility which contains
a number of .c and .h files. Can you help me in this regard?
Thanks.
-Saikat
_______________________________________________
klee-dev mailing list
https://mailman.ic.ac.uk/mailman/listinfo/klee-dev
--
Best regards,
Lei Zhang
Lei Zhang
2013-09-18 18:57:40 UTC
Permalink
gzip is also maintained by GNU, like Coreutils. So they have the same build
system. The method for Coreutils works for gzip.

just have a try of the following:

$ wget http://ftp.gnu.org/gnu/gzip/gzip-1.6.tar.xz
$ unxz ./gzip-1.6.tar.xz
$ tar xf ./gzip-1.6.tar
$ cd gzip-1.6
$ mkdir obj-llvm
$ ../configure CFLAGS="-g"
$ make CC=`which klee-gcc`

This will generate the gzip.bc without problems.
Hi,
I was talking about multiple file programs containing multiple .c and .h
files. For klee to run it is required to compile the code with llvm-gcc. I
have used klee for single file programs. But I am not sure on how to use
klee over such multiple file applications. Will putting CC variable in the
makefile as llvm-gcc do the job? It will be best if you can send me an
example over how to do that. Please do help. I am in urgent need.
Thanks.
-Saikat
Post by Lei Zhang
Hi Saikat,
From my understanding, every .c file is compiled and then linked to the
final binary. By running KLEE on that binary, you are touching code in all
these source files. And you can verify that by checking the 'gcov' output.
Or maybe I didn't fully understand your concern? Could you specify your
tasks more clearly?
On Tue, Sep 17, 2013 at 2:25 PM, Saikat Dutta <
Post by Saikat Dutta
Hi,
I am working on a research project where i need to run multiple file
programs using klee. I am actually testing the gzip utility which contains
a number of .c and .h files. Can you help me in this regard?
Thanks.
-Saikat
_______________________________________________
klee-dev mailing list
https://mailman.ic.ac.uk/mailman/listinfo/klee-dev
--
Best regards,
Lei Zhang
--
Best regards,
Lei Zhang
Daniel Liew
2013-09-19 14:22:51 UTC
Permalink
If it helps there is a very nice tool called wllvm which acts as a
wrapper to clang which you can use to build whole programs in native
form and LLVM bitcode form.

The original author's code is at https://github.com/travitch/whole-program-llvm

I have a fork of this which adds a bunch of features that you may find useful

https://github.com/delcypher/whole-program-llvm

Thanks,
Dan.
Post by Lei Zhang
gzip is also maintained by GNU, like Coreutils. So they have the same build
system. The method for Coreutils works for gzip.
$ wget http://ftp.gnu.org/gnu/gzip/gzip-1.6.tar.xz
$ unxz ./gzip-1.6.tar.xz
$ tar xf ./gzip-1.6.tar
$ cd gzip-1.6
$ mkdir obj-llvm
$ ../configure CFLAGS="-g"
$ make CC=`which klee-gcc`
This will generate the gzip.bc without problems.
On Wed, Sep 18, 2013 at 2:35 PM, Saikat Dutta
Hi,
I was talking about multiple file programs containing multiple .c and .h
files. For klee to run it is required to compile the code with llvm-gcc. I
have used klee for single file programs. But I am not sure on how to use
klee over such multiple file applications. Will putting CC variable in the
makefile as llvm-gcc do the job? It will be best if you can send me an
example over how to do that. Please do help. I am in urgent need.
Thanks.
-Saikat
Post by Lei Zhang
Hi Saikat,
From my understanding, every .c file is compiled and then linked to the
final binary. By running KLEE on that binary, you are touching code in all
these source files. And you can verify that by checking the 'gcov' output.
Or maybe I didn't fully understand your concern? Could you specify your
tasks more clearly?
On Tue, Sep 17, 2013 at 2:25 PM, Saikat Dutta
Post by Saikat Dutta
Hi,
I am working on a research project where i need to run multiple file
programs using klee. I am actually testing the gzip utility which contains a
number of .c and .h files. Can you help me in this regard?
Thanks.
-Saikat
_______________________________________________
klee-dev mailing list
https://mailman.ic.ac.uk/mailman/listinfo/klee-dev
--
Best regards,
Lei Zhang
--
Best regards,
Lei Zhang
Lei Zhang
2013-09-20 00:34:51 UTC
Permalink
Wow, this is a nice tool. Thanks, Daniel!
Post by Daniel Liew
If it helps there is a very nice tool called wllvm which acts as a
wrapper to clang which you can use to build whole programs in native
form and LLVM bitcode form.
The original author's code is at
https://github.com/travitch/whole-program-llvm
I have a fork of this which adds a bunch of features that you may find useful
https://github.com/delcypher/whole-program-llvm
Thanks,
Dan.
Post by Lei Zhang
gzip is also maintained by GNU, like Coreutils. So they have the same
build
Post by Lei Zhang
system. The method for Coreutils works for gzip.
$ wget http://ftp.gnu.org/gnu/gzip/gzip-1.6.tar.xz
$ unxz ./gzip-1.6.tar.xz
$ tar xf ./gzip-1.6.tar
$ cd gzip-1.6
$ mkdir obj-llvm
$ ../configure CFLAGS="-g"
$ make CC=`which klee-gcc`
This will generate the gzip.bc without problems.
On Wed, Sep 18, 2013 at 2:35 PM, Saikat Dutta
Hi,
I was talking about multiple file programs containing multiple .c and .h
files. For klee to run it is required to compile the code with
llvm-gcc. I
Post by Lei Zhang
have used klee for single file programs. But I am not sure on how to use
klee over such multiple file applications. Will putting CC variable in
the
Post by Lei Zhang
makefile as llvm-gcc do the job? It will be best if you can send me an
example over how to do that. Please do help. I am in urgent need.
Thanks.
-Saikat
Post by Lei Zhang
Hi Saikat,
From my understanding, every .c file is compiled and then linked to the
final binary. By running KLEE on that binary, you are touching code in
all
Post by Lei Zhang
Post by Lei Zhang
these source files. And you can verify that by checking the 'gcov'
output.
Post by Lei Zhang
Post by Lei Zhang
Or maybe I didn't fully understand your concern? Could you specify your
tasks more clearly?
On Tue, Sep 17, 2013 at 2:25 PM, Saikat Dutta
Post by Saikat Dutta
Hi,
I am working on a research project where i need to run multiple file
programs using klee. I am actually testing the gzip utility which
contains a
Post by Lei Zhang
Post by Lei Zhang
Post by Saikat Dutta
number of .c and .h files. Can you help me in this regard?
Thanks.
-Saikat
_______________________________________________
klee-dev mailing list
https://mailman.ic.ac.uk/mailman/listinfo/klee-dev
--
Best regards,
Lei Zhang
--
Best regards,
Lei Zhang
--
Best regards,
Lei Zhang
Saikat Dutta
2013-09-20 03:25:08 UTC
Permalink
Hi,
I am using llvm-2.9 and path has been set for llvm-gcc as well as klee. I
am using Linux 10.04 32 bit. I have installed everything just as mentioned
in klee's website. Also please help me set up wllvm. I tried following the
instructions given with it, but its not working.How can I use it? Need all
steps.
Thanks.
-Saikat
Post by Lei Zhang
Wow, this is a nice tool. Thanks, Daniel!
Post by Daniel Liew
If it helps there is a very nice tool called wllvm which acts as a
wrapper to clang which you can use to build whole programs in native
form and LLVM bitcode form.
The original author's code is at
https://github.com/travitch/whole-program-llvm
I have a fork of this which adds a bunch of features that you may find useful
https://github.com/delcypher/whole-program-llvm
Thanks,
Dan.
Post by Lei Zhang
gzip is also maintained by GNU, like Coreutils. So they have the same
build
Post by Lei Zhang
system. The method for Coreutils works for gzip.
$ wget http://ftp.gnu.org/gnu/gzip/gzip-1.6.tar.xz
$ unxz ./gzip-1.6.tar.xz
$ tar xf ./gzip-1.6.tar
$ cd gzip-1.6
$ mkdir obj-llvm
$ ../configure CFLAGS="-g"
$ make CC=`which klee-gcc`
This will generate the gzip.bc without problems.
On Wed, Sep 18, 2013 at 2:35 PM, Saikat Dutta
Hi,
I was talking about multiple file programs containing multiple .c and
.h
Post by Lei Zhang
files. For klee to run it is required to compile the code with
llvm-gcc. I
Post by Lei Zhang
have used klee for single file programs. But I am not sure on how to
use
Post by Lei Zhang
klee over such multiple file applications. Will putting CC variable in
the
Post by Lei Zhang
makefile as llvm-gcc do the job? It will be best if you can send me an
example over how to do that. Please do help. I am in urgent need.
Thanks.
-Saikat
Post by Lei Zhang
Hi Saikat,
From my understanding, every .c file is compiled and then linked to
the
Post by Lei Zhang
Post by Lei Zhang
final binary. By running KLEE on that binary, you are touching code
in all
Post by Lei Zhang
Post by Lei Zhang
these source files. And you can verify that by checking the 'gcov'
output.
Post by Lei Zhang
Post by Lei Zhang
Or maybe I didn't fully understand your concern? Could you specify
your
Post by Lei Zhang
Post by Lei Zhang
tasks more clearly?
On Tue, Sep 17, 2013 at 2:25 PM, Saikat Dutta
Post by Saikat Dutta
Hi,
I am working on a research project where i need to run multiple file
programs using klee. I am actually testing the gzip utility which
contains a
Post by Lei Zhang
Post by Lei Zhang
Post by Saikat Dutta
number of .c and .h files. Can you help me in this regard?
Thanks.
-Saikat
_______________________________________________
klee-dev mailing list
https://mailman.ic.ac.uk/mailman/listinfo/klee-dev
--
Best regards,
Lei Zhang
--
Best regards,
Lei Zhang
--
Best regards,
Lei Zhang
Daniel Liew
2013-09-20 12:41:02 UTC
Permalink
Please CC the mailing list in future as this discussion may be useful to others.
Hi Daniel,
I was able to run wllvm. make step was successful. But no .bc file was
created. When I used klee over gzip.o then it returned : "KLEE: ERROR: error
loading program './gzip': Invalid bitcode signature"
You have not read the WLLVM instructions correctly.

1. wllvm builds both LLVM bitcode and native binaries at the same
time. The linked LLVM bitcode is not produced, you must extract this
manually after compiling with wllvm like so...

# Where gzip is the native binary, will produce gzip.bc
extract-bc gzip

2. wllvm doesn't actually support llvm-gcc because it is a deprecated
compiler. However I have a branch of wllvm that does support llvm-gcc
(in a hacky way) called 'llvm-gcc'. You can find it at
https://github.com/delcypher/whole-program-llvm/tree/llvm-gcc Then set
your environment as follows

# llvm-gcc must be in your path already!
export LLVM_COMPILER=llvm-gcc

# path should contain things like llvm-nm and llvm-dis
export LLVM_COMPILER_PATH=/your/path/to/the/llvm2.9/build/Release+Asserts/bin

# Optional but useful for seeing what commands are being executed
export WLLVM_OUTPUT=DEBUG

Note it is crucial that llvm-gcc be able to perform linking but you
may find that it is unable to do so you'll see error messages like...

/usr/bin/ld: cannot find crt1.o: No such file or directory

To fix this add symbolic links to these object files in to the
llvm-gcc lib folder .e.g

$ cd /path/to/llvm-gcc/bin/lib/gcc/x86_64-unknown-linux-gnu/4.2.1
$ ln -s /usr/lib/x86_64-linux-gnu/crt1.o
$ ln -s /usr/lib/x86_64-linux-gnu/crto.o
$ ln -s /usr/lib/x86_64-linux-gnu/crti.o


Hope that helps.

Dan.
On Fri, Sep 20, 2013 at 8:55 AM, Saikat Dutta
Post by Saikat Dutta
Hi,
I am using llvm-2.9 and path has been set for llvm-gcc as well as klee. I
am using Linux 10.04 32 bit. I have installed everything just as mentioned
in klee's website. Also please help me set up wllvm. I tried following the
instructions given with it, but its not working.How can I use it? Need all
steps.
Thanks.
-Saikat
Post by Lei Zhang
Wow, this is a nice tool. Thanks, Daniel!
On Thu, Sep 19, 2013 at 10:22 AM, Daniel Liew
Post by Daniel Liew
If it helps there is a very nice tool called wllvm which acts as a
wrapper to clang which you can use to build whole programs in native
form and LLVM bitcode form.
The original author's code is at
https://github.com/travitch/whole-program-llvm
I have a fork of this which adds a bunch of features that you may find useful
https://github.com/delcypher/whole-program-llvm
Thanks,
Dan.
Post by Lei Zhang
gzip is also maintained by GNU, like Coreutils. So they have the same build
system. The method for Coreutils works for gzip.
$ wget http://ftp.gnu.org/gnu/gzip/gzip-1.6.tar.xz
$ unxz ./gzip-1.6.tar.xz
$ tar xf ./gzip-1.6.tar
$ cd gzip-1.6
$ mkdir obj-llvm
$ ../configure CFLAGS="-g"
$ make CC=`which klee-gcc`
This will generate the gzip.bc without problems.
On Wed, Sep 18, 2013 at 2:35 PM, Saikat Dutta
Hi,
I was talking about multiple file programs containing multiple .c and .h
files. For klee to run it is required to compile the code with llvm-gcc. I
have used klee for single file programs. But I am not sure on how to use
klee over such multiple file applications. Will putting CC variable in the
makefile as llvm-gcc do the job? It will be best if you can send me an
example over how to do that. Please do help. I am in urgent need.
Thanks.
-Saikat
Post by Lei Zhang
Hi Saikat,
From my understanding, every .c file is compiled and then linked to the
final binary. By running KLEE on that binary, you are touching code in all
these source files. And you can verify that by checking the 'gcov' output.
Or maybe I didn't fully understand your concern? Could you specify your
tasks more clearly?
On Tue, Sep 17, 2013 at 2:25 PM, Saikat Dutta
Post by Saikat Dutta
Hi,
I am working on a research project where i need to run multiple file
programs using klee. I am actually testing the gzip utility which
contains a
number of .c and .h files. Can you help me in this regard?
Thanks.
-Saikat
_______________________________________________
klee-dev mailing list
https://mailman.ic.ac.uk/mailman/listinfo/klee-dev
--
Best regards,
Lei Zhang
--
Best regards,
Lei Zhang
--
Best regards,
Lei Zhang
Saikat Dutta
2013-09-20 16:15:52 UTC
Permalink
Hi,
Everything goes fine with wllvm according to the way you described in the
previous mail. No errors till make step. But instead of "gzip.bc" or
"gzip.o.bc" , ".gzip.o.bc" is being formed. When I use extract bc on it,
error is generated. Please help.
-Saikat
Post by Daniel Liew
Please CC the mailing list in future as this discussion may be useful to others.
Hi Daniel,
I was able to run wllvm. make step was successful. But no .bc file was
error
loading program './gzip': Invalid bitcode signature"
You have not read the WLLVM instructions correctly.
1. wllvm builds both LLVM bitcode and native binaries at the same
time. The linked LLVM bitcode is not produced, you must extract this
manually after compiling with wllvm like so...
# Where gzip is the native binary, will produce gzip.bc
extract-bc gzip
2. wllvm doesn't actually support llvm-gcc because it is a deprecated
compiler. However I have a branch of wllvm that does support llvm-gcc
(in a hacky way) called 'llvm-gcc'. You can find it at
https://github.com/delcypher/whole-program-llvm/tree/llvm-gcc Then set
your environment as follows
# llvm-gcc must be in your path already!
export LLVM_COMPILER=llvm-gcc
# path should contain things like llvm-nm and llvm-dis
export
LLVM_COMPILER_PATH=/your/path/to/the/llvm2.9/build/Release+Asserts/bin
# Optional but useful for seeing what commands are being executed
export WLLVM_OUTPUT=DEBUG
Note it is crucial that llvm-gcc be able to perform linking but you
may find that it is unable to do so you'll see error messages like...
/usr/bin/ld: cannot find crt1.o: No such file or directory
To fix this add symbolic links to these object files in to the
llvm-gcc lib folder .e.g
$ cd /path/to/llvm-gcc/bin/lib/gcc/x86_64-unknown-linux-gnu/4.2.1
$ ln -s /usr/lib/x86_64-linux-gnu/crt1.o
$ ln -s /usr/lib/x86_64-linux-gnu/crto.o
$ ln -s /usr/lib/x86_64-linux-gnu/crti.o
Hope that helps.
Dan.
On Fri, Sep 20, 2013 at 8:55 AM, Saikat Dutta
Post by Saikat Dutta
Hi,
I am using llvm-2.9 and path has been set for llvm-gcc as well as klee.
I
Post by Saikat Dutta
am using Linux 10.04 32 bit. I have installed everything just as
mentioned
Post by Saikat Dutta
in klee's website. Also please help me set up wllvm. I tried following
the
Post by Saikat Dutta
instructions given with it, but its not working.How can I use it? Need
all
Post by Saikat Dutta
steps.
Thanks.
-Saikat
Post by Lei Zhang
Wow, this is a nice tool. Thanks, Daniel!
On Thu, Sep 19, 2013 at 10:22 AM, Daniel Liew
Post by Daniel Liew
If it helps there is a very nice tool called wllvm which acts as a
wrapper to clang which you can use to build whole programs in native
form and LLVM bitcode form.
The original author's code is at
https://github.com/travitch/whole-program-llvm
I have a fork of this which adds a bunch of features that you may find useful
https://github.com/delcypher/whole-program-llvm
Thanks,
Dan.
Post by Lei Zhang
gzip is also maintained by GNU, like Coreutils. So they have the
same
Post by Saikat Dutta
Post by Lei Zhang
Post by Daniel Liew
Post by Lei Zhang
build
system. The method for Coreutils works for gzip.
$ wget http://ftp.gnu.org/gnu/gzip/gzip-1.6.tar.xz
$ unxz ./gzip-1.6.tar.xz
$ tar xf ./gzip-1.6.tar
$ cd gzip-1.6
$ mkdir obj-llvm
$ ../configure CFLAGS="-g"
$ make CC=`which klee-gcc`
This will generate the gzip.bc without problems.
On Wed, Sep 18, 2013 at 2:35 PM, Saikat Dutta
Hi,
I was talking about multiple file programs containing multiple .c
and
Post by Saikat Dutta
Post by Lei Zhang
Post by Daniel Liew
Post by Lei Zhang
.h
files. For klee to run it is required to compile the code with llvm-gcc. I
have used klee for single file programs. But I am not sure on how
to
Post by Saikat Dutta
Post by Lei Zhang
Post by Daniel Liew
Post by Lei Zhang
use
klee over such multiple file applications. Will putting CC variable in the
makefile as llvm-gcc do the job? It will be best if you can send me an
example over how to do that. Please do help. I am in urgent need.
Thanks.
-Saikat
Post by Lei Zhang
Hi Saikat,
From my understanding, every .c file is compiled and then linked
to
Post by Saikat Dutta
Post by Lei Zhang
Post by Daniel Liew
Post by Lei Zhang
Post by Lei Zhang
the
final binary. By running KLEE on that binary, you are touching
code
Post by Saikat Dutta
Post by Lei Zhang
Post by Daniel Liew
Post by Lei Zhang
Post by Lei Zhang
in all
these source files. And you can verify that by checking the 'gcov'
output.
Or maybe I didn't fully understand your concern? Could you specify your
tasks more clearly?
On Tue, Sep 17, 2013 at 2:25 PM, Saikat Dutta
Post by Saikat Dutta
Hi,
I am working on a research project where i need to run multiple file
programs using klee. I am actually testing the gzip utility which
contains a
number of .c and .h files. Can you help me in this regard?
Thanks.
-Saikat
_______________________________________________
klee-dev mailing list
https://mailman.ic.ac.uk/mailman/listinfo/klee-dev
--
Best regards,
Lei Zhang
--
Best regards,
Lei Zhang
--
Best regards,
Lei Zhang
Daniel Liew
2013-09-20 16:39:31 UTC
Permalink
Post by Saikat Dutta
Hi,
Everything goes fine with wllvm according to the way you described in the
previous mail. No errors till make step.
If you don't tell us what the errors are we will **not** be able to
help you. If you see an error tell us what it is.
Post by Saikat Dutta
But instead of "gzip.bc" or
"gzip.o.bc" , ".gzip.o.bc" is being formed.
.gzip.o.bc is a LLVM bitcode file that corresponds to the gzip.o
object file (this mostly likely corresponds with gzip.c) . It is
**not** the finally linked executable. You are only supposed to run
extract-bc on the the finally linked executable (or on static
libraries) **not** on object files.

I just tried this and it works fine. You should run extract-bc on the
"gzip" executable.

# I assume you have llvm-gcc in your path and it was the pre-built
binary llvm-gcc 4.2

$ export LLVM_COMPILER=llvm-gcc
$ export WLLVM_OUTPUT=WARNING
$ export LLVM_COMPILER_PATH=/your/path/to/the/llvm2.9/build/Release+Asserts/bin
$ wget http://ftp.gnu.org/gnu/gzip/gzip-1.6.tar.xz
$ tar -xvf gzip-1.6.tar.xz
$ cd gzip-1.6
$ CC=wllvm ./configure
$ make -j4
$ extract-bc gzip

# gzip.bc will now be in the current directory
Post by Saikat Dutta
When I use extract bc on it,
error is generated. Please help.
-Saikat
Again... If there is an error message tell us what it is.

Hope that helps.

Dan.
Saikat Dutta
2013-09-20 16:50:38 UTC
Permalink
Hi,
At the "extract-bc gzip" stage following error is produced:

Traceback (most recent call last):
File
"/home/saikat/Downloads/llvm_new/whole-program-llvm-llvm-gcc/extract-bc",
line 269, in <module>
sys.exit(main(sys.argv))
File
"/home/saikat/Downloads/llvm_new/whole-program-llvm-llvm-gcc/extract-bc",
line 212, in main
import argparse
ImportError: No module named argparse
Post by Daniel Liew
Post by Saikat Dutta
Hi,
Everything goes fine with wllvm according to the way you described in the
previous mail. No errors till make step.
If you don't tell us what the errors are we will **not** be able to
help you. If you see an error tell us what it is.
Post by Saikat Dutta
But instead of "gzip.bc" or
"gzip.o.bc" , ".gzip.o.bc" is being formed.
.gzip.o.bc is a LLVM bitcode file that corresponds to the gzip.o
object file (this mostly likely corresponds with gzip.c) . It is
**not** the finally linked executable. You are only supposed to run
extract-bc on the the finally linked executable (or on static
libraries) **not** on object files.
I just tried this and it works fine. You should run extract-bc on the
"gzip" executable.
# I assume you have llvm-gcc in your path and it was the pre-built
binary llvm-gcc 4.2
$ export LLVM_COMPILER=llvm-gcc
$ export WLLVM_OUTPUT=WARNING
$ export
LLVM_COMPILER_PATH=/your/path/to/the/llvm2.9/build/Release+Asserts/bin
$ wget http://ftp.gnu.org/gnu/gzip/gzip-1.6.tar.xz
$ tar -xvf gzip-1.6.tar.xz
$ cd gzip-1.6
$ CC=wllvm ./configure
$ make -j4
$ extract-bc gzip
# gzip.bc will now be in the current directory
Post by Saikat Dutta
When I use extract bc on it,
error is generated. Please help.
-Saikat
Again... If there is an error message tell us what it is.
Hope that helps.
Dan.
Daniel Liew
2013-09-20 16:58:51 UTC
Permalink
Your python install is too old (the argparse module was introduced in
python2.7) you need python 2.7 or later. You can find your current
python version by running

$ python --version

I think you said you were using Ubuntu 10.04 in which case the python
version is probably 2.6.5 . Unless you have a good reason to be
running such an old version of python (or Ubuntu for that matter) you
should upgrade.
Post by Saikat Dutta
Hi,
File
"/home/saikat/Downloads/llvm_new/whole-program-llvm-llvm-gcc/extract-bc",
line 269, in <module>
sys.exit(main(sys.argv))
File
"/home/saikat/Downloads/llvm_new/whole-program-llvm-llvm-gcc/extract-bc",
line 212, in main
import argparse
ImportError: No module named argparse
Post by Daniel Liew
Post by Saikat Dutta
Hi,
Everything goes fine with wllvm according to the way you described in the
previous mail. No errors till make step.
If you don't tell us what the errors are we will **not** be able to
help you. If you see an error tell us what it is.
Post by Saikat Dutta
But instead of "gzip.bc" or
"gzip.o.bc" , ".gzip.o.bc" is being formed.
.gzip.o.bc is a LLVM bitcode file that corresponds to the gzip.o
object file (this mostly likely corresponds with gzip.c) . It is
**not** the finally linked executable. You are only supposed to run
extract-bc on the the finally linked executable (or on static
libraries) **not** on object files.
I just tried this and it works fine. You should run extract-bc on the
"gzip" executable.
# I assume you have llvm-gcc in your path and it was the pre-built
binary llvm-gcc 4.2
$ export LLVM_COMPILER=llvm-gcc
$ export WLLVM_OUTPUT=WARNING
$ export
LLVM_COMPILER_PATH=/your/path/to/the/llvm2.9/build/Release+Asserts/bin
$ wget http://ftp.gnu.org/gnu/gzip/gzip-1.6.tar.xz
$ tar -xvf gzip-1.6.tar.xz
$ cd gzip-1.6
$ CC=wllvm ./configure
$ make -j4
$ extract-bc gzip
# gzip.bc will now be in the current directory
Post by Saikat Dutta
When I use extract bc on it,
error is generated. Please help.
-Saikat
Again... If there is an error message tell us what it is.
Hope that helps.
Dan.
Daniel Liew
2013-09-21 08:50:24 UTC
Permalink
Oh I forgot to mention that if you really don't feel like upgrading
you could just modify the extract-bc python script by removing the use
of argparse from the main() function and setting

inputFile = sys.argv[1]
Post by Daniel Liew
Your python install is too old (the argparse module was introduced in
python2.7) you need python 2.7 or later. You can find your current
python version by running
$ python --version
I think you said you were using Ubuntu 10.04 in which case the python
version is probably 2.6.5 . Unless you have a good reason to be
running such an old version of python (or Ubuntu for that matter) you
should upgrade.
Post by Saikat Dutta
Hi,
File
"/home/saikat/Downloads/llvm_new/whole-program-llvm-llvm-gcc/extract-bc",
line 269, in <module>
sys.exit(main(sys.argv))
File
"/home/saikat/Downloads/llvm_new/whole-program-llvm-llvm-gcc/extract-bc",
line 212, in main
import argparse
ImportError: No module named argparse
Post by Daniel Liew
Post by Saikat Dutta
Hi,
Everything goes fine with wllvm according to the way you described in the
previous mail. No errors till make step.
If you don't tell us what the errors are we will **not** be able to
help you. If you see an error tell us what it is.
Post by Saikat Dutta
But instead of "gzip.bc" or
"gzip.o.bc" , ".gzip.o.bc" is being formed.
.gzip.o.bc is a LLVM bitcode file that corresponds to the gzip.o
object file (this mostly likely corresponds with gzip.c) . It is
**not** the finally linked executable. You are only supposed to run
extract-bc on the the finally linked executable (or on static
libraries) **not** on object files.
I just tried this and it works fine. You should run extract-bc on the
"gzip" executable.
# I assume you have llvm-gcc in your path and it was the pre-built
binary llvm-gcc 4.2
$ export LLVM_COMPILER=llvm-gcc
$ export WLLVM_OUTPUT=WARNING
$ export
LLVM_COMPILER_PATH=/your/path/to/the/llvm2.9/build/Release+Asserts/bin
$ wget http://ftp.gnu.org/gnu/gzip/gzip-1.6.tar.xz
$ tar -xvf gzip-1.6.tar.xz
$ cd gzip-1.6
$ CC=wllvm ./configure
$ make -j4
$ extract-bc gzip
# gzip.bc will now be in the current directory
Post by Saikat Dutta
When I use extract bc on it,
error is generated. Please help.
-Saikat
Again... If there is an error message tell us what it is.
Hope that helps.
Dan.
Saikat Dutta
2013-09-21 09:36:31 UTC
Permalink
I upgraded to python 2.7
"extract-bc gzip" produced gzip.bc
what to do next?
Post by Daniel Liew
Oh I forgot to mention that if you really don't feel like upgrading
you could just modify the extract-bc python script by removing the use
of argparse from the main() function and setting
inputFile = sys.argv[1]
Post by Daniel Liew
Your python install is too old (the argparse module was introduced in
python2.7) you need python 2.7 or later. You can find your current
python version by running
$ python --version
I think you said you were using Ubuntu 10.04 in which case the python
version is probably 2.6.5 . Unless you have a good reason to be
running such an old version of python (or Ubuntu for that matter) you
should upgrade.
Post by Saikat Dutta
Hi,
File
"/home/saikat/Downloads/llvm_new/whole-program-llvm-llvm-gcc/extract-bc",
Post by Daniel Liew
Post by Saikat Dutta
line 269, in <module>
sys.exit(main(sys.argv))
File
"/home/saikat/Downloads/llvm_new/whole-program-llvm-llvm-gcc/extract-bc",
Post by Daniel Liew
Post by Saikat Dutta
line 212, in main
import argparse
ImportError: No module named argparse
On Fri, Sep 20, 2013 at 10:09 PM, Daniel Liew <
On 20 September 2013 17:15, Saikat Dutta <
Post by Saikat Dutta
Hi,
Everything goes fine with wllvm according to the way you described in the
previous mail. No errors till make step.
If you don't tell us what the errors are we will **not** be able to
help you. If you see an error tell us what it is.
Post by Saikat Dutta
But instead of "gzip.bc" or
"gzip.o.bc" , ".gzip.o.bc" is being formed.
.gzip.o.bc is a LLVM bitcode file that corresponds to the gzip.o
object file (this mostly likely corresponds with gzip.c) . It is
**not** the finally linked executable. You are only supposed to run
extract-bc on the the finally linked executable (or on static
libraries) **not** on object files.
I just tried this and it works fine. You should run extract-bc on the
"gzip" executable.
# I assume you have llvm-gcc in your path and it was the pre-built
binary llvm-gcc 4.2
$ export LLVM_COMPILER=llvm-gcc
$ export WLLVM_OUTPUT=WARNING
$ export
LLVM_COMPILER_PATH=/your/path/to/the/llvm2.9/build/Release+Asserts/bin
$ wget http://ftp.gnu.org/gnu/gzip/gzip-1.6.tar.xz
$ tar -xvf gzip-1.6.tar.xz
$ cd gzip-1.6
$ CC=wllvm ./configure
$ make -j4
$ extract-bc gzip
# gzip.bc will now be in the current directory
Post by Saikat Dutta
When I use extract bc on it,
error is generated. Please help.
-Saikat
Again... If there is an error message tell us what it is.
Hope that helps.
Dan.
Daniel Liew
2013-09-21 10:10:02 UTC
Permalink
You're done. gzip.bc is a single LLVM module that is equivalent to the
gzip binary. Now you just need to run KLEE on it.

e.g.

$ klee --libc=uclibc --posix-runtime gzip.bc --help
KLEE: NOTE: Using model:
/data/dev/KLEE/klee/bin-dbg/Release+Asserts/lib/libkleeRuntimePOSIX.bca
KLEE: output directory = "klee-out-1"
LLVM ERROR: Code generator does not support intrinsic function
'llvm.objectsize.i64'!

I should note that this does not work on my machine because of missing
support for a particular LLVM intrinsic function. You'll need to add
support for it:
http://llvm.org/docs/LangRef.html#llvm-objectsize-intrinsic

A developer recently added support for another intrinsic so you could
use this as an example ( https://github.com/ccadar/klee/pull/27 )

If you get it working please consider contributing your code back to
the project so others can benefit.

Thanks,
Dan Liew.
Post by Saikat Dutta
I upgraded to python 2.7
"extract-bc gzip" produced gzip.bc
what to do next?
Post by Daniel Liew
Oh I forgot to mention that if you really don't feel like upgrading
you could just modify the extract-bc python script by removing the use
of argparse from the main() function and setting
inputFile = sys.argv[1]
Post by Daniel Liew
Your python install is too old (the argparse module was introduced in
python2.7) you need python 2.7 or later. You can find your current
python version by running
$ python --version
I think you said you were using Ubuntu 10.04 in which case the python
version is probably 2.6.5 . Unless you have a good reason to be
running such an old version of python (or Ubuntu for that matter) you
should upgrade.
Post by Saikat Dutta
Hi,
File
"/home/saikat/Downloads/llvm_new/whole-program-llvm-llvm-gcc/extract-bc",
line 269, in <module>
sys.exit(main(sys.argv))
File
"/home/saikat/Downloads/llvm_new/whole-program-llvm-llvm-gcc/extract-bc",
line 212, in main
import argparse
ImportError: No module named argparse
On Fri, Sep 20, 2013 at 10:09 PM, Daniel Liew
On 20 September 2013 17:15, Saikat Dutta
Post by Saikat Dutta
Hi,
Everything goes fine with wllvm according to the way you described
in
the
previous mail. No errors till make step.
If you don't tell us what the errors are we will **not** be able to
help you. If you see an error tell us what it is.
Post by Saikat Dutta
But instead of "gzip.bc" or
"gzip.o.bc" , ".gzip.o.bc" is being formed.
.gzip.o.bc is a LLVM bitcode file that corresponds to the gzip.o
object file (this mostly likely corresponds with gzip.c) . It is
**not** the finally linked executable. You are only supposed to run
extract-bc on the the finally linked executable (or on static
libraries) **not** on object files.
I just tried this and it works fine. You should run extract-bc on the
"gzip" executable.
# I assume you have llvm-gcc in your path and it was the pre-built
binary llvm-gcc 4.2
$ export LLVM_COMPILER=llvm-gcc
$ export WLLVM_OUTPUT=WARNING
$ export
LLVM_COMPILER_PATH=/your/path/to/the/llvm2.9/build/Release+Asserts/bin
$ wget http://ftp.gnu.org/gnu/gzip/gzip-1.6.tar.xz
$ tar -xvf gzip-1.6.tar.xz
$ cd gzip-1.6
$ CC=wllvm ./configure
$ make -j4
$ extract-bc gzip
# gzip.bc will now be in the current directory
Post by Saikat Dutta
When I use extract bc on it,
error is generated. Please help.
-Saikat
Again... If there is an error message tell us what it is.
Hope that helps.
Dan.
Saikat Dutta
2013-09-21 10:42:56 UTC
Permalink
I got the same message:
LLVM ERROR: Code generator does not support intrinsic function
'llvm.objectsize.i32'!
So theres no existing solution to this?
Post by Daniel Liew
You're done. gzip.bc is a single LLVM module that is equivalent to the
gzip binary. Now you just need to run KLEE on it.
e.g.
$ klee --libc=uclibc --posix-runtime gzip.bc --help
/data/dev/KLEE/klee/bin-dbg/Release+Asserts/lib/libkleeRuntimePOSIX.bca
KLEE: output directory = "klee-out-1"
LLVM ERROR: Code generator does not support intrinsic function
'llvm.objectsize.i64'!
I should note that this does not work on my machine because of missing
support for a particular LLVM intrinsic function. You'll need to add
http://llvm.org/docs/LangRef.html#llvm-objectsize-intrinsic
A developer recently added support for another intrinsic so you could
use this as an example ( https://github.com/ccadar/klee/pull/27 )
If you get it working please consider contributing your code back to
the project so others can benefit.
Thanks,
Dan Liew.
Post by Saikat Dutta
I upgraded to python 2.7
"extract-bc gzip" produced gzip.bc
what to do next?
Post by Daniel Liew
Oh I forgot to mention that if you really don't feel like upgrading
you could just modify the extract-bc python script by removing the use
of argparse from the main() function and setting
inputFile = sys.argv[1]
Post by Daniel Liew
Your python install is too old (the argparse module was introduced in
python2.7) you need python 2.7 or later. You can find your current
python version by running
$ python --version
I think you said you were using Ubuntu 10.04 in which case the python
version is probably 2.6.5 . Unless you have a good reason to be
running such an old version of python (or Ubuntu for that matter) you
should upgrade.
On 20 September 2013 17:50, Saikat Dutta <
Post by Saikat Dutta
Hi,
File
"/home/saikat/Downloads/llvm_new/whole-program-llvm-llvm-gcc/extract-bc",
Post by Saikat Dutta
Post by Daniel Liew
Post by Daniel Liew
Post by Saikat Dutta
line 269, in <module>
sys.exit(main(sys.argv))
File
"/home/saikat/Downloads/llvm_new/whole-program-llvm-llvm-gcc/extract-bc",
Post by Saikat Dutta
Post by Daniel Liew
Post by Daniel Liew
Post by Saikat Dutta
line 212, in main
import argparse
ImportError: No module named argparse
On Fri, Sep 20, 2013 at 10:09 PM, Daniel Liew
On 20 September 2013 17:15, Saikat Dutta
Post by Saikat Dutta
Hi,
Everything goes fine with wllvm according to the way you described
in
the
previous mail. No errors till make step.
If you don't tell us what the errors are we will **not** be able to
help you. If you see an error tell us what it is.
Post by Saikat Dutta
But instead of "gzip.bc" or
"gzip.o.bc" , ".gzip.o.bc" is being formed.
.gzip.o.bc is a LLVM bitcode file that corresponds to the gzip.o
object file (this mostly likely corresponds with gzip.c) . It is
**not** the finally linked executable. You are only supposed to run
extract-bc on the the finally linked executable (or on static
libraries) **not** on object files.
I just tried this and it works fine. You should run extract-bc on
the
Post by Saikat Dutta
Post by Daniel Liew
Post by Daniel Liew
Post by Saikat Dutta
"gzip" executable.
# I assume you have llvm-gcc in your path and it was the pre-built
binary llvm-gcc 4.2
$ export LLVM_COMPILER=llvm-gcc
$ export WLLVM_OUTPUT=WARNING
$ export
LLVM_COMPILER_PATH=/your/path/to/the/llvm2.9/build/Release+Asserts/bin
Post by Saikat Dutta
Post by Daniel Liew
Post by Daniel Liew
Post by Saikat Dutta
$ wget http://ftp.gnu.org/gnu/gzip/gzip-1.6.tar.xz
$ tar -xvf gzip-1.6.tar.xz
$ cd gzip-1.6
$ CC=wllvm ./configure
$ make -j4
$ extract-bc gzip
# gzip.bc will now be in the current directory
Post by Saikat Dutta
When I use extract bc on it,
error is generated. Please help.
-Saikat
Again... If there is an error message tell us what it is.
Hope that helps.
Dan.
Daniel Liew
2013-09-21 10:55:46 UTC
Permalink
One possible workaround is to use an older version of LLVM and
llvm-gcc (I think you would need to use llvm-2.6) that doesn't
generate that intrinsic. I give no guarantees that this would work as
I have not tried using KLEE with this older version.

I've added an issue to the KLEE issue tracker on your behalf (
https://github.com/ccadar/klee/issues/33 ). There are no guarantees
that this will be fixed.

If you need this to work **now** you need to implement support for
this intrinsic yourself.
Post by Daniel Liew
LLVM ERROR: Code generator does not support intrinsic function
'llvm.objectsize.i32'!
So theres no existing solution to this?
Post by Daniel Liew
You're done. gzip.bc is a single LLVM module that is equivalent to the
gzip binary. Now you just need to run KLEE on it.
e.g.
$ klee --libc=uclibc --posix-runtime gzip.bc --help
/data/dev/KLEE/klee/bin-dbg/Release+Asserts/lib/libkleeRuntimePOSIX.bca
KLEE: output directory = "klee-out-1"
LLVM ERROR: Code generator does not support intrinsic function
'llvm.objectsize.i64'!
I should note that this does not work on my machine because of missing
support for a particular LLVM intrinsic function. You'll need to add
http://llvm.org/docs/LangRef.html#llvm-objectsize-intrinsic
A developer recently added support for another intrinsic so you could
use this as an example ( https://github.com/ccadar/klee/pull/27 )
If you get it working please consider contributing your code back to
the project so others can benefit.
Thanks,
Dan Liew.
Post by Saikat Dutta
I upgraded to python 2.7
"extract-bc gzip" produced gzip.bc
what to do next?
On Sat, Sep 21, 2013 at 2:20 PM, Daniel Liew
Post by Daniel Liew
Oh I forgot to mention that if you really don't feel like upgrading
you could just modify the extract-bc python script by removing the use
of argparse from the main() function and setting
inputFile = sys.argv[1]
Post by Daniel Liew
Your python install is too old (the argparse module was introduced in
python2.7) you need python 2.7 or later. You can find your current
python version by running
$ python --version
I think you said you were using Ubuntu 10.04 in which case the python
version is probably 2.6.5 . Unless you have a good reason to be
running such an old version of python (or Ubuntu for that matter) you
should upgrade.
On 20 September 2013 17:50, Saikat Dutta
Post by Saikat Dutta
Hi,
File
"/home/saikat/Downloads/llvm_new/whole-program-llvm-llvm-gcc/extract-bc",
line 269, in <module>
sys.exit(main(sys.argv))
File
"/home/saikat/Downloads/llvm_new/whole-program-llvm-llvm-gcc/extract-bc",
line 212, in main
import argparse
ImportError: No module named argparse
On Fri, Sep 20, 2013 at 10:09 PM, Daniel Liew
On 20 September 2013 17:15, Saikat Dutta
Post by Saikat Dutta
Hi,
Everything goes fine with wllvm according to the way you described
in
the
previous mail. No errors till make step.
If you don't tell us what the errors are we will **not** be able to
help you. If you see an error tell us what it is.
Post by Saikat Dutta
But instead of "gzip.bc" or
"gzip.o.bc" , ".gzip.o.bc" is being formed.
.gzip.o.bc is a LLVM bitcode file that corresponds to the gzip.o
object file (this mostly likely corresponds with gzip.c) . It is
**not** the finally linked executable. You are only supposed to run
extract-bc on the the finally linked executable (or on static
libraries) **not** on object files.
I just tried this and it works fine. You should run extract-bc on the
"gzip" executable.
# I assume you have llvm-gcc in your path and it was the pre-built
binary llvm-gcc 4.2
$ export LLVM_COMPILER=llvm-gcc
$ export WLLVM_OUTPUT=WARNING
$ export
LLVM_COMPILER_PATH=/your/path/to/the/llvm2.9/build/Release+Asserts/bin
$ wget http://ftp.gnu.org/gnu/gzip/gzip-1.6.tar.xz
$ tar -xvf gzip-1.6.tar.xz
$ cd gzip-1.6
$ CC=wllvm ./configure
$ make -j4
$ extract-bc gzip
# gzip.bc will now be in the current directory
Post by Saikat Dutta
When I use extract bc on it,
error is generated. Please help.
-Saikat
Again... If there is an error message tell us what it is.
Hope that helps.
Dan.
Saikat Dutta
2013-09-21 11:01:55 UTC
Permalink
Ok....Dead End then....Thanks for your help a lot. You were very patient
throughout. Let me know if theres any development in this !
Thanks.
-Saikat
Post by Daniel Liew
One possible workaround is to use an older version of LLVM and
llvm-gcc (I think you would need to use llvm-2.6) that doesn't
generate that intrinsic. I give no guarantees that this would work as
I have not tried using KLEE with this older version.
I've added an issue to the KLEE issue tracker on your behalf (
https://github.com/ccadar/klee/issues/33 ). There are no guarantees
that this will be fixed.
If you need this to work **now** you need to implement support for
this intrinsic yourself.
Post by Daniel Liew
LLVM ERROR: Code generator does not support intrinsic function
'llvm.objectsize.i32'!
So theres no existing solution to this?
Post by Daniel Liew
You're done. gzip.bc is a single LLVM module that is equivalent to the
gzip binary. Now you just need to run KLEE on it.
e.g.
$ klee --libc=uclibc --posix-runtime gzip.bc --help
/data/dev/KLEE/klee/bin-dbg/Release+Asserts/lib/libkleeRuntimePOSIX.bca
KLEE: output directory = "klee-out-1"
LLVM ERROR: Code generator does not support intrinsic function
'llvm.objectsize.i64'!
I should note that this does not work on my machine because of missing
support for a particular LLVM intrinsic function. You'll need to add
http://llvm.org/docs/LangRef.html#llvm-objectsize-intrinsic
A developer recently added support for another intrinsic so you could
use this as an example ( https://github.com/ccadar/klee/pull/27 )
If you get it working please consider contributing your code back to
the project so others can benefit.
Thanks,
Dan Liew.
Post by Saikat Dutta
I upgraded to python 2.7
"extract-bc gzip" produced gzip.bc
what to do next?
On Sat, Sep 21, 2013 at 2:20 PM, Daniel Liew
Post by Daniel Liew
Oh I forgot to mention that if you really don't feel like upgrading
you could just modify the extract-bc python script by removing the
use
Post by Daniel Liew
Post by Daniel Liew
Post by Saikat Dutta
Post by Daniel Liew
of argparse from the main() function and setting
inputFile = sys.argv[1]
Post by Daniel Liew
Your python install is too old (the argparse module was introduced
in
Post by Daniel Liew
Post by Daniel Liew
Post by Saikat Dutta
Post by Daniel Liew
Post by Daniel Liew
python2.7) you need python 2.7 or later. You can find your current
python version by running
$ python --version
I think you said you were using Ubuntu 10.04 in which case the
python
Post by Daniel Liew
Post by Daniel Liew
Post by Saikat Dutta
Post by Daniel Liew
Post by Daniel Liew
version is probably 2.6.5 . Unless you have a good reason to be
running such an old version of python (or Ubuntu for that matter)
you
Post by Daniel Liew
Post by Daniel Liew
Post by Saikat Dutta
Post by Daniel Liew
Post by Daniel Liew
should upgrade.
On 20 September 2013 17:50, Saikat Dutta
Post by Saikat Dutta
Hi,
File
"/home/saikat/Downloads/llvm_new/whole-program-llvm-llvm-gcc/extract-bc",
Post by Daniel Liew
Post by Daniel Liew
Post by Saikat Dutta
Post by Daniel Liew
Post by Daniel Liew
Post by Saikat Dutta
line 269, in <module>
sys.exit(main(sys.argv))
File
"/home/saikat/Downloads/llvm_new/whole-program-llvm-llvm-gcc/extract-bc",
Post by Daniel Liew
Post by Daniel Liew
Post by Saikat Dutta
Post by Daniel Liew
Post by Daniel Liew
Post by Saikat Dutta
line 212, in main
import argparse
ImportError: No module named argparse
On Fri, Sep 20, 2013 at 10:09 PM, Daniel Liew
On 20 September 2013 17:15, Saikat Dutta
Post by Saikat Dutta
Hi,
Everything goes fine with wllvm according to the way you described
in
the
previous mail. No errors till make step.
If you don't tell us what the errors are we will **not** be able
to
Post by Daniel Liew
Post by Daniel Liew
Post by Saikat Dutta
Post by Daniel Liew
Post by Daniel Liew
Post by Saikat Dutta
help you. If you see an error tell us what it is.
Post by Saikat Dutta
But instead of "gzip.bc" or
"gzip.o.bc" , ".gzip.o.bc" is being formed.
.gzip.o.bc is a LLVM bitcode file that corresponds to the gzip.o
object file (this mostly likely corresponds with gzip.c) . It is
**not** the finally linked executable. You are only supposed to
run
Post by Daniel Liew
Post by Daniel Liew
Post by Saikat Dutta
Post by Daniel Liew
Post by Daniel Liew
Post by Saikat Dutta
extract-bc on the the finally linked executable (or on static
libraries) **not** on object files.
I just tried this and it works fine. You should run extract-bc on the
"gzip" executable.
# I assume you have llvm-gcc in your path and it was the
pre-built
Post by Daniel Liew
Post by Daniel Liew
Post by Saikat Dutta
Post by Daniel Liew
Post by Daniel Liew
Post by Saikat Dutta
binary llvm-gcc 4.2
$ export LLVM_COMPILER=llvm-gcc
$ export WLLVM_OUTPUT=WARNING
$ export
LLVM_COMPILER_PATH=/your/path/to/the/llvm2.9/build/Release+Asserts/bin
Post by Daniel Liew
Post by Daniel Liew
Post by Saikat Dutta
Post by Daniel Liew
Post by Daniel Liew
Post by Saikat Dutta
$ wget http://ftp.gnu.org/gnu/gzip/gzip-1.6.tar.xz
$ tar -xvf gzip-1.6.tar.xz
$ cd gzip-1.6
$ CC=wllvm ./configure
$ make -j4
$ extract-bc gzip
# gzip.bc will now be in the current directory
Post by Saikat Dutta
When I use extract bc on it,
error is generated. Please help.
-Saikat
Again... If there is an error message tell us what it is.
Hope that helps.
Dan.
Daniel Liew
2013-09-21 11:58:33 UTC
Permalink
Oops. I appear to have mislead you. KLEE can execute gzip.bc . The
problem is by default the gzip build system tells llvm-gcc to optimise
the code (-O2). You need to tell llvm-gcc to not optimise the code
(this seems to prevent the llvm.objectsize.*) intrinsic from being
used. You can do this by forcing the value of CFLAGS at configure time
like so...

$ cd gzip-1.6
$ make clean
$ CC=wllvm CFLAGS="-O0 -g" ./configure
$ make
$ extract-bc gzip

Now
$ klee --libc=uclibc --posix-runtime gzip.bc --help

Works.

Hope that helps.

Dan.
Post by Saikat Dutta
Ok....Dead End then....Thanks for your help a lot. You were very patient
throughout. Let me know if theres any development in this !
Thanks.
-Saikat
Post by Daniel Liew
One possible workaround is to use an older version of LLVM and
llvm-gcc (I think you would need to use llvm-2.6) that doesn't
generate that intrinsic. I give no guarantees that this would work as
I have not tried using KLEE with this older version.
I've added an issue to the KLEE issue tracker on your behalf (
https://github.com/ccadar/klee/issues/33 ). There are no guarantees
that this will be fixed.
If you need this to work **now** you need to implement support for
this intrinsic yourself.
Post by Daniel Liew
LLVM ERROR: Code generator does not support intrinsic function
'llvm.objectsize.i32'!
So theres no existing solution to this?
On Sat, Sep 21, 2013 at 3:40 PM, Daniel Liew
Post by Daniel Liew
You're done. gzip.bc is a single LLVM module that is equivalent to the
gzip binary. Now you just need to run KLEE on it.
e.g.
$ klee --libc=uclibc --posix-runtime gzip.bc --help
/data/dev/KLEE/klee/bin-dbg/Release+Asserts/lib/libkleeRuntimePOSIX.bca
KLEE: output directory = "klee-out-1"
LLVM ERROR: Code generator does not support intrinsic function
'llvm.objectsize.i64'!
I should note that this does not work on my machine because of missing
support for a particular LLVM intrinsic function. You'll need to add
http://llvm.org/docs/LangRef.html#llvm-objectsize-intrinsic
A developer recently added support for another intrinsic so you could
use this as an example ( https://github.com/ccadar/klee/pull/27 )
If you get it working please consider contributing your code back to
the project so others can benefit.
Thanks,
Dan Liew.
On 21 September 2013 10:36, Saikat Dutta
Post by Saikat Dutta
I upgraded to python 2.7
"extract-bc gzip" produced gzip.bc
what to do next?
On Sat, Sep 21, 2013 at 2:20 PM, Daniel Liew
Post by Daniel Liew
Oh I forgot to mention that if you really don't feel like upgrading
you could just modify the extract-bc python script by removing the use
of argparse from the main() function and setting
inputFile = sys.argv[1]
Post by Daniel Liew
Your python install is too old (the argparse module was introduced in
python2.7) you need python 2.7 or later. You can find your current
python version by running
$ python --version
I think you said you were using Ubuntu 10.04 in which case the python
version is probably 2.6.5 . Unless you have a good reason to be
running such an old version of python (or Ubuntu for that matter) you
should upgrade.
On 20 September 2013 17:50, Saikat Dutta
Post by Saikat Dutta
Hi,
File
"/home/saikat/Downloads/llvm_new/whole-program-llvm-llvm-gcc/extract-bc",
line 269, in <module>
sys.exit(main(sys.argv))
File
"/home/saikat/Downloads/llvm_new/whole-program-llvm-llvm-gcc/extract-bc",
line 212, in main
import argparse
ImportError: No module named argparse
On Fri, Sep 20, 2013 at 10:09 PM, Daniel Liew
On 20 September 2013 17:15, Saikat Dutta
Post by Saikat Dutta
Hi,
Everything goes fine with wllvm according to the way you
described
in
the
previous mail. No errors till make step.
If you don't tell us what the errors are we will **not** be able to
help you. If you see an error tell us what it is.
Post by Saikat Dutta
But instead of "gzip.bc" or
"gzip.o.bc" , ".gzip.o.bc" is being formed.
.gzip.o.bc is a LLVM bitcode file that corresponds to the gzip.o
object file (this mostly likely corresponds with gzip.c) . It is
**not** the finally linked executable. You are only supposed to run
extract-bc on the the finally linked executable (or on static
libraries) **not** on object files.
I just tried this and it works fine. You should run extract-bc
on
the
"gzip" executable.
# I assume you have llvm-gcc in your path and it was the pre-built
binary llvm-gcc 4.2
$ export LLVM_COMPILER=llvm-gcc
$ export WLLVM_OUTPUT=WARNING
$ export
LLVM_COMPILER_PATH=/your/path/to/the/llvm2.9/build/Release+Asserts/bin
$ wget http://ftp.gnu.org/gnu/gzip/gzip-1.6.tar.xz
$ tar -xvf gzip-1.6.tar.xz
$ cd gzip-1.6
$ CC=wllvm ./configure
$ make -j4
$ extract-bc gzip
# gzip.bc will now be in the current directory
Post by Saikat Dutta
When I use extract bc on it,
error is generated. Please help.
-Saikat
Again... If there is an error message tell us what it is.
Hope that helps.
Dan.
Saikat Dutta
2013-09-21 14:36:26 UTC
Permalink
Thanks .. its working :) ....can the same procedure be followed for
non-GNU applications?
Post by Daniel Liew
Oops. I appear to have mislead you. KLEE can execute gzip.bc . The
problem is by default the gzip build system tells llvm-gcc to optimise
the code (-O2). You need to tell llvm-gcc to not optimise the code
(this seems to prevent the llvm.objectsize.*) intrinsic from being
used. You can do this by forcing the value of CFLAGS at configure time
like so...
$ cd gzip-1.6
$ make clean
$ CC=wllvm CFLAGS="-O0 -g" ./configure
$ make
$ extract-bc gzip
Now
$ klee --libc=uclibc --posix-runtime gzip.bc --help
Works.
Hope that helps.
Dan.
Post by Saikat Dutta
Ok....Dead End then....Thanks for your help a lot. You were very patient
throughout. Let me know if theres any development in this !
Thanks.
-Saikat
Post by Daniel Liew
One possible workaround is to use an older version of LLVM and
llvm-gcc (I think you would need to use llvm-2.6) that doesn't
generate that intrinsic. I give no guarantees that this would work as
I have not tried using KLEE with this older version.
I've added an issue to the KLEE issue tracker on your behalf (
https://github.com/ccadar/klee/issues/33 ). There are no guarantees
that this will be fixed.
If you need this to work **now** you need to implement support for
this intrinsic yourself.
Post by Daniel Liew
LLVM ERROR: Code generator does not support intrinsic function
'llvm.objectsize.i32'!
So theres no existing solution to this?
On Sat, Sep 21, 2013 at 3:40 PM, Daniel Liew
Post by Daniel Liew
You're done. gzip.bc is a single LLVM module that is equivalent to
the
Post by Saikat Dutta
Post by Daniel Liew
Post by Daniel Liew
Post by Daniel Liew
gzip binary. Now you just need to run KLEE on it.
e.g.
$ klee --libc=uclibc --posix-runtime gzip.bc --help
/data/dev/KLEE/klee/bin-dbg/Release+Asserts/lib/libkleeRuntimePOSIX.bca
Post by Saikat Dutta
Post by Daniel Liew
Post by Daniel Liew
Post by Daniel Liew
KLEE: output directory = "klee-out-1"
LLVM ERROR: Code generator does not support intrinsic function
'llvm.objectsize.i64'!
I should note that this does not work on my machine because of
missing
Post by Saikat Dutta
Post by Daniel Liew
Post by Daniel Liew
Post by Daniel Liew
support for a particular LLVM intrinsic function. You'll need to add
http://llvm.org/docs/LangRef.html#llvm-objectsize-intrinsic
A developer recently added support for another intrinsic so you could
use this as an example ( https://github.com/ccadar/klee/pull/27 )
If you get it working please consider contributing your code back to
the project so others can benefit.
Thanks,
Dan Liew.
On 21 September 2013 10:36, Saikat Dutta
Post by Saikat Dutta
I upgraded to python 2.7
"extract-bc gzip" produced gzip.bc
what to do next?
On Sat, Sep 21, 2013 at 2:20 PM, Daniel Liew
Post by Daniel Liew
Oh I forgot to mention that if you really don't feel like
upgrading
Post by Saikat Dutta
Post by Daniel Liew
Post by Daniel Liew
Post by Daniel Liew
Post by Saikat Dutta
Post by Daniel Liew
you could just modify the extract-bc python script by removing the use
of argparse from the main() function and setting
inputFile = sys.argv[1]
On 20 September 2013 17:58, Daniel Liew <
Post by Daniel Liew
Your python install is too old (the argparse module was
introduced
Post by Saikat Dutta
Post by Daniel Liew
Post by Daniel Liew
Post by Daniel Liew
Post by Saikat Dutta
Post by Daniel Liew
Post by Daniel Liew
in
python2.7) you need python 2.7 or later. You can find your
current
Post by Saikat Dutta
Post by Daniel Liew
Post by Daniel Liew
Post by Daniel Liew
Post by Saikat Dutta
Post by Daniel Liew
Post by Daniel Liew
python version by running
$ python --version
I think you said you were using Ubuntu 10.04 in which case the python
version is probably 2.6.5 . Unless you have a good reason to be
running such an old version of python (or Ubuntu for that
matter)
Post by Saikat Dutta
Post by Daniel Liew
Post by Daniel Liew
Post by Daniel Liew
Post by Saikat Dutta
Post by Daniel Liew
Post by Daniel Liew
you
should upgrade.
On 20 September 2013 17:50, Saikat Dutta
Post by Saikat Dutta
Hi,
File
"/home/saikat/Downloads/llvm_new/whole-program-llvm-llvm-gcc/extract-bc",
Post by Saikat Dutta
Post by Daniel Liew
Post by Daniel Liew
Post by Daniel Liew
Post by Saikat Dutta
Post by Daniel Liew
Post by Daniel Liew
Post by Saikat Dutta
line 269, in <module>
sys.exit(main(sys.argv))
File
"/home/saikat/Downloads/llvm_new/whole-program-llvm-llvm-gcc/extract-bc",
Post by Saikat Dutta
Post by Daniel Liew
Post by Daniel Liew
Post by Daniel Liew
Post by Saikat Dutta
Post by Daniel Liew
Post by Daniel Liew
Post by Saikat Dutta
line 212, in main
import argparse
ImportError: No module named argparse
On Fri, Sep 20, 2013 at 10:09 PM, Daniel Liew
On 20 September 2013 17:15, Saikat Dutta
Post by Saikat Dutta
Hi,
Everything goes fine with wllvm according to the way you
described
in
the
previous mail. No errors till make step.
If you don't tell us what the errors are we will **not** be
able
Post by Saikat Dutta
Post by Daniel Liew
Post by Daniel Liew
Post by Daniel Liew
Post by Saikat Dutta
Post by Daniel Liew
Post by Daniel Liew
Post by Saikat Dutta
to
help you. If you see an error tell us what it is.
Post by Saikat Dutta
But instead of "gzip.bc" or
"gzip.o.bc" , ".gzip.o.bc" is being formed.
.gzip.o.bc is a LLVM bitcode file that corresponds to the
gzip.o
Post by Saikat Dutta
Post by Daniel Liew
Post by Daniel Liew
Post by Daniel Liew
Post by Saikat Dutta
Post by Daniel Liew
Post by Daniel Liew
Post by Saikat Dutta
object file (this mostly likely corresponds with gzip.c) . It
is
Post by Saikat Dutta
Post by Daniel Liew
Post by Daniel Liew
Post by Daniel Liew
Post by Saikat Dutta
Post by Daniel Liew
Post by Daniel Liew
Post by Saikat Dutta
**not** the finally linked executable. You are only supposed
to
Post by Saikat Dutta
Post by Daniel Liew
Post by Daniel Liew
Post by Daniel Liew
Post by Saikat Dutta
Post by Daniel Liew
Post by Daniel Liew
Post by Saikat Dutta
run
extract-bc on the the finally linked executable (or on static
libraries) **not** on object files.
I just tried this and it works fine. You should run extract-bc
on
the
"gzip" executable.
# I assume you have llvm-gcc in your path and it was the
pre-built
binary llvm-gcc 4.2
$ export LLVM_COMPILER=llvm-gcc
$ export WLLVM_OUTPUT=WARNING
$ export
LLVM_COMPILER_PATH=/your/path/to/the/llvm2.9/build/Release+Asserts/bin
Post by Saikat Dutta
Post by Daniel Liew
Post by Daniel Liew
Post by Daniel Liew
Post by Saikat Dutta
Post by Daniel Liew
Post by Daniel Liew
Post by Saikat Dutta
$ wget http://ftp.gnu.org/gnu/gzip/gzip-1.6.tar.xz
$ tar -xvf gzip-1.6.tar.xz
$ cd gzip-1.6
$ CC=wllvm ./configure
$ make -j4
$ extract-bc gzip
# gzip.bc will now be in the current directory
Post by Saikat Dutta
When I use extract bc on it,
error is generated. Please help.
-Saikat
Again... If there is an error message tell us what it is.
Hope that helps.
Dan.
Daniel Liew
2013-09-21 16:37:11 UTC
Permalink
Many non GNU projects use autotools so this approach will probably work
with them. Please remember that KLEE does not have a runtime C++ library so
it is unlikely you will be able to run many C++ programs.

CMake is another common build system. You should be able to do something
similar when setting the CC flag. I'm not sure CFLAGS will work though (
instead you might need to change the CMAKE_BUILD_TYPE variable). You will
have to experiment (cmake-gui is your friend )

Remember if you set WLLVM_OUTPUT=DEBUG then the command line passed to the
compiler will be shown on stderr which you can use to check that the "-g"
(debug symbols) "-O0" ( almost no optimisation ) are being passed to the
compiler

Have fun with KLEE!

Thanks,
Dan.
Post by Saikat Dutta
Thanks .. its working :) ....can the same procedure be followed for
non-GNU applications?
Post by Daniel Liew
Oops. I appear to have mislead you. KLEE can execute gzip.bc . The
problem is by default the gzip build system tells llvm-gcc to optimise
the code (-O2). You need to tell llvm-gcc to not optimise the code
(this seems to prevent the llvm.objectsize.*) intrinsic from being
used. You can do this by forcing the value of CFLAGS at configure time
like so...
$ cd gzip-1.6
$ make clean
$ CC=wllvm CFLAGS="-O0 -g" ./configure
$ make
$ extract-bc gzip
Now
$ klee --libc=uclibc --posix-runtime gzip.bc --help
Works.
Hope that helps.
Dan.
Post by Saikat Dutta
Ok....Dead End then....Thanks for your help a lot. You were very patient
throughout. Let me know if theres any development in this !
Thanks.
-Saikat
On Sat, Sep 21, 2013 at 4:25 PM, Daniel Liew <
Post by Daniel Liew
One possible workaround is to use an older version of LLVM and
llvm-gcc (I think you would need to use llvm-2.6) that doesn't
generate that intrinsic. I give no guarantees that this would work as
I have not tried using KLEE with this older version.
I've added an issue to the KLEE issue tracker on your behalf (
https://github.com/ccadar/klee/issues/33 ). There are no guarantees
that this will be fixed.
If you need this to work **now** you need to implement support for
this intrinsic yourself.
On 21 September 2013 11:42, Saikat Dutta <
Post by Daniel Liew
LLVM ERROR: Code generator does not support intrinsic function
'llvm.objectsize.i32'!
So theres no existing solution to this?
On Sat, Sep 21, 2013 at 3:40 PM, Daniel Liew
Post by Daniel Liew
You're done. gzip.bc is a single LLVM module that is equivalent to
the
Post by Saikat Dutta
Post by Daniel Liew
Post by Daniel Liew
Post by Daniel Liew
gzip binary. Now you just need to run KLEE on it.
e.g.
$ klee --libc=uclibc --posix-runtime gzip.bc --help
/data/dev/KLEE/klee/bin-dbg/Release+Asserts/lib/libkleeRuntimePOSIX.bca
Post by Saikat Dutta
Post by Daniel Liew
Post by Daniel Liew
Post by Daniel Liew
KLEE: output directory = "klee-out-1"
LLVM ERROR: Code generator does not support intrinsic function
'llvm.objectsize.i64'!
I should note that this does not work on my machine because of
missing
Post by Saikat Dutta
Post by Daniel Liew
Post by Daniel Liew
Post by Daniel Liew
support for a particular LLVM intrinsic function. You'll need to add
http://llvm.org/docs/LangRef.html#llvm-objectsize-intrinsic
A developer recently added support for another intrinsic so you
could
Post by Saikat Dutta
Post by Daniel Liew
Post by Daniel Liew
Post by Daniel Liew
use this as an example ( https://github.com/ccadar/klee/pull/27 )
If you get it working please consider contributing your code back to
the project so others can benefit.
Thanks,
Dan Liew.
On 21 September 2013 10:36, Saikat Dutta
Post by Saikat Dutta
I upgraded to python 2.7
"extract-bc gzip" produced gzip.bc
what to do next?
On Sat, Sep 21, 2013 at 2:20 PM, Daniel Liew
Post by Daniel Liew
Oh I forgot to mention that if you really don't feel like
upgrading
Post by Saikat Dutta
Post by Daniel Liew
Post by Daniel Liew
Post by Daniel Liew
Post by Saikat Dutta
Post by Daniel Liew
you could just modify the extract-bc python script by removing
the
Post by Saikat Dutta
Post by Daniel Liew
Post by Daniel Liew
Post by Daniel Liew
Post by Saikat Dutta
Post by Daniel Liew
use
of argparse from the main() function and setting
inputFile = sys.argv[1]
On 20 September 2013 17:58, Daniel Liew <
Post by Daniel Liew
Your python install is too old (the argparse module was
introduced
Post by Saikat Dutta
Post by Daniel Liew
Post by Daniel Liew
Post by Daniel Liew
Post by Saikat Dutta
Post by Daniel Liew
Post by Daniel Liew
in
python2.7) you need python 2.7 or later. You can find your
current
Post by Saikat Dutta
Post by Daniel Liew
Post by Daniel Liew
Post by Daniel Liew
Post by Saikat Dutta
Post by Daniel Liew
Post by Daniel Liew
python version by running
$ python --version
I think you said you were using Ubuntu 10.04 in which case the
python
version is probably 2.6.5 . Unless you have a good reason to be
running such an old version of python (or Ubuntu for that
matter)
Post by Saikat Dutta
Post by Daniel Liew
Post by Daniel Liew
Post by Daniel Liew
Post by Saikat Dutta
Post by Daniel Liew
Post by Daniel Liew
you
should upgrade.
On 20 September 2013 17:50, Saikat Dutta
Post by Saikat Dutta
Hi,
File
"/home/saikat/Downloads/llvm_new/whole-program-llvm-llvm-gcc/extract-bc",
Post by Saikat Dutta
Post by Daniel Liew
Post by Daniel Liew
Post by Daniel Liew
Post by Saikat Dutta
Post by Daniel Liew
Post by Daniel Liew
Post by Saikat Dutta
line 269, in <module>
sys.exit(main(sys.argv))
File
"/home/saikat/Downloads/llvm_new/whole-program-llvm-llvm-gcc/extract-bc",
Post by Saikat Dutta
Post by Daniel Liew
Post by Daniel Liew
Post by Daniel Liew
Post by Saikat Dutta
Post by Daniel Liew
Post by Daniel Liew
Post by Saikat Dutta
line 212, in main
import argparse
ImportError: No module named argparse
On Fri, Sep 20, 2013 at 10:09 PM, Daniel Liew
On 20 September 2013 17:15, Saikat Dutta
Post by Saikat Dutta
Hi,
Everything goes fine with wllvm according to the way you
described
in
the
previous mail. No errors till make step.
If you don't tell us what the errors are we will **not** be
able
Post by Saikat Dutta
Post by Daniel Liew
Post by Daniel Liew
Post by Daniel Liew
Post by Saikat Dutta
Post by Daniel Liew
Post by Daniel Liew
Post by Saikat Dutta
to
help you. If you see an error tell us what it is.
Post by Saikat Dutta
But instead of "gzip.bc" or
"gzip.o.bc" , ".gzip.o.bc" is being formed.
.gzip.o.bc is a LLVM bitcode file that corresponds to the
gzip.o
Post by Saikat Dutta
Post by Daniel Liew
Post by Daniel Liew
Post by Daniel Liew
Post by Saikat Dutta
Post by Daniel Liew
Post by Daniel Liew
Post by Saikat Dutta
object file (this mostly likely corresponds with gzip.c) .
It is
Post by Saikat Dutta
Post by Daniel Liew
Post by Daniel Liew
Post by Daniel Liew
Post by Saikat Dutta
Post by Daniel Liew
Post by Daniel Liew
Post by Saikat Dutta
**not** the finally linked executable. You are only supposed
to
Post by Saikat Dutta
Post by Daniel Liew
Post by Daniel Liew
Post by Daniel Liew
Post by Saikat Dutta
Post by Daniel Liew
Post by Daniel Liew
Post by Saikat Dutta
run
extract-bc on the the finally linked executable (or on static
libraries) **not** on object files.
I just tried this and it works fine. You should run
extract-bc
Post by Saikat Dutta
Post by Daniel Liew
Post by Daniel Liew
Post by Daniel Liew
Post by Saikat Dutta
Post by Daniel Liew
Post by Daniel Liew
Post by Saikat Dutta
on
the
"gzip" executable.
# I assume you have llvm-gcc in your path and it was the
pre-built
binary llvm-gcc 4.2
$ export LLVM_COMPILER=llvm-gcc
$ export WLLVM_OUTPUT=WARNING
$ export
LLVM_COMPILER_PATH=/your/path/to/the/llvm2.9/build/Release+Asserts/bin
Post by Saikat Dutta
Post by Daniel Liew
Post by Daniel Liew
Post by Daniel Liew
Post by Saikat Dutta
Post by Daniel Liew
Post by Daniel Liew
Post by Saikat Dutta
$ wget http://ftp.gnu.org/gnu/gzip/gzip-1.6.tar.xz
$ tar -xvf gzip-1.6.tar.xz
$ cd gzip-1.6
$ CC=wllvm ./configure
$ make -j4
$ extract-bc gzip
# gzip.bc will now be in the current directory
Post by Saikat Dutta
When I use extract bc on it,
error is generated. Please help.
-Saikat
Again... If there is an error message tell us what it is.
Hope that helps.
Dan.
Saikat Dutta
2013-09-21 16:40:16 UTC
Permalink
Thanks. What is the latest ubuntu version that can run klee?
Post by Daniel Liew
Many non GNU projects use autotools so this approach will probably work
with them. Please remember that KLEE does not have a runtime C++ library so
it is unlikely you will be able to run many C++ programs.
CMake is another common build system. You should be able to do something
similar when setting the CC flag. I'm not sure CFLAGS will work though (
instead you might need to change the CMAKE_BUILD_TYPE variable). You will
have to experiment (cmake-gui is your friend )
Remember if you set WLLVM_OUTPUT=DEBUG then the command line passed to the
compiler will be shown on stderr which you can use to check that the "-g"
(debug symbols) "-O0" ( almost no optimisation ) are being passed to the
compiler
Have fun with KLEE!
Thanks,
Dan.
Post by Saikat Dutta
Thanks .. its working :) ....can the same procedure be followed for
non-GNU applications?
Post by Daniel Liew
Oops. I appear to have mislead you. KLEE can execute gzip.bc . The
problem is by default the gzip build system tells llvm-gcc to optimise
the code (-O2). You need to tell llvm-gcc to not optimise the code
(this seems to prevent the llvm.objectsize.*) intrinsic from being
used. You can do this by forcing the value of CFLAGS at configure time
like so...
$ cd gzip-1.6
$ make clean
$ CC=wllvm CFLAGS="-O0 -g" ./configure
$ make
$ extract-bc gzip
Now
$ klee --libc=uclibc --posix-runtime gzip.bc --help
Works.
Hope that helps.
Dan.
Post by Saikat Dutta
Ok....Dead End then....Thanks for your help a lot. You were very
patient
Post by Saikat Dutta
throughout. Let me know if theres any development in this !
Thanks.
-Saikat
On Sat, Sep 21, 2013 at 4:25 PM, Daniel Liew <
Post by Daniel Liew
One possible workaround is to use an older version of LLVM and
llvm-gcc (I think you would need to use llvm-2.6) that doesn't
generate that intrinsic. I give no guarantees that this would work as
I have not tried using KLEE with this older version.
I've added an issue to the KLEE issue tracker on your behalf (
https://github.com/ccadar/klee/issues/33 ). There are no guarantees
that this will be fixed.
If you need this to work **now** you need to implement support for
this intrinsic yourself.
On 21 September 2013 11:42, Saikat Dutta <
Post by Daniel Liew
LLVM ERROR: Code generator does not support intrinsic function
'llvm.objectsize.i32'!
So theres no existing solution to this?
On Sat, Sep 21, 2013 at 3:40 PM, Daniel Liew
Post by Daniel Liew
You're done. gzip.bc is a single LLVM module that is equivalent to
the
Post by Saikat Dutta
Post by Daniel Liew
Post by Daniel Liew
Post by Daniel Liew
gzip binary. Now you just need to run KLEE on it.
e.g.
$ klee --libc=uclibc --posix-runtime gzip.bc --help
/data/dev/KLEE/klee/bin-dbg/Release+Asserts/lib/libkleeRuntimePOSIX.bca
Post by Saikat Dutta
Post by Daniel Liew
Post by Daniel Liew
Post by Daniel Liew
KLEE: output directory = "klee-out-1"
LLVM ERROR: Code generator does not support intrinsic function
'llvm.objectsize.i64'!
I should note that this does not work on my machine because of
missing
Post by Saikat Dutta
Post by Daniel Liew
Post by Daniel Liew
Post by Daniel Liew
support for a particular LLVM intrinsic function. You'll need to
add
Post by Saikat Dutta
Post by Daniel Liew
Post by Daniel Liew
Post by Daniel Liew
http://llvm.org/docs/LangRef.html#llvm-objectsize-intrinsic
A developer recently added support for another intrinsic so you
could
Post by Saikat Dutta
Post by Daniel Liew
Post by Daniel Liew
Post by Daniel Liew
use this as an example ( https://github.com/ccadar/klee/pull/27 )
If you get it working please consider contributing your code back
to
Post by Saikat Dutta
Post by Daniel Liew
Post by Daniel Liew
Post by Daniel Liew
the project so others can benefit.
Thanks,
Dan Liew.
On 21 September 2013 10:36, Saikat Dutta
Post by Saikat Dutta
I upgraded to python 2.7
"extract-bc gzip" produced gzip.bc
what to do next?
On Sat, Sep 21, 2013 at 2:20 PM, Daniel Liew
Post by Daniel Liew
Oh I forgot to mention that if you really don't feel like
upgrading
Post by Saikat Dutta
Post by Daniel Liew
Post by Daniel Liew
Post by Daniel Liew
Post by Saikat Dutta
Post by Daniel Liew
you could just modify the extract-bc python script by removing
the
Post by Saikat Dutta
Post by Daniel Liew
Post by Daniel Liew
Post by Daniel Liew
Post by Saikat Dutta
Post by Daniel Liew
use
of argparse from the main() function and setting
inputFile = sys.argv[1]
On 20 September 2013 17:58, Daniel Liew <
Post by Daniel Liew
Your python install is too old (the argparse module was
introduced
Post by Saikat Dutta
Post by Daniel Liew
Post by Daniel Liew
Post by Daniel Liew
Post by Saikat Dutta
Post by Daniel Liew
Post by Daniel Liew
in
python2.7) you need python 2.7 or later. You can find your
current
Post by Saikat Dutta
Post by Daniel Liew
Post by Daniel Liew
Post by Daniel Liew
Post by Saikat Dutta
Post by Daniel Liew
Post by Daniel Liew
python version by running
$ python --version
I think you said you were using Ubuntu 10.04 in which case the
python
version is probably 2.6.5 . Unless you have a good reason to
be
Post by Saikat Dutta
Post by Daniel Liew
Post by Daniel Liew
Post by Daniel Liew
Post by Saikat Dutta
Post by Daniel Liew
Post by Daniel Liew
running such an old version of python (or Ubuntu for that
matter)
Post by Saikat Dutta
Post by Daniel Liew
Post by Daniel Liew
Post by Daniel Liew
Post by Saikat Dutta
Post by Daniel Liew
Post by Daniel Liew
you
should upgrade.
On 20 September 2013 17:50, Saikat Dutta
Post by Saikat Dutta
Hi,
File
"/home/saikat/Downloads/llvm_new/whole-program-llvm-llvm-gcc/extract-bc",
Post by Saikat Dutta
Post by Daniel Liew
Post by Daniel Liew
Post by Daniel Liew
Post by Saikat Dutta
Post by Daniel Liew
Post by Daniel Liew
Post by Saikat Dutta
line 269, in <module>
sys.exit(main(sys.argv))
File
"/home/saikat/Downloads/llvm_new/whole-program-llvm-llvm-gcc/extract-bc",
Post by Saikat Dutta
Post by Daniel Liew
Post by Daniel Liew
Post by Daniel Liew
Post by Saikat Dutta
Post by Daniel Liew
Post by Daniel Liew
Post by Saikat Dutta
line 212, in main
import argparse
ImportError: No module named argparse
On Fri, Sep 20, 2013 at 10:09 PM, Daniel Liew
On 20 September 2013 17:15, Saikat Dutta
Post by Saikat Dutta
Hi,
Everything goes fine with wllvm according to the way you
described
in
the
previous mail. No errors till make step.
If you don't tell us what the errors are we will **not** be
able
Post by Saikat Dutta
Post by Daniel Liew
Post by Daniel Liew
Post by Daniel Liew
Post by Saikat Dutta
Post by Daniel Liew
Post by Daniel Liew
Post by Saikat Dutta
to
help you. If you see an error tell us what it is.
Post by Saikat Dutta
But instead of "gzip.bc" or
"gzip.o.bc" , ".gzip.o.bc" is being formed.
.gzip.o.bc is a LLVM bitcode file that corresponds to the
gzip.o
Post by Saikat Dutta
Post by Daniel Liew
Post by Daniel Liew
Post by Daniel Liew
Post by Saikat Dutta
Post by Daniel Liew
Post by Daniel Liew
Post by Saikat Dutta
object file (this mostly likely corresponds with gzip.c) .
It is
Post by Saikat Dutta
Post by Daniel Liew
Post by Daniel Liew
Post by Daniel Liew
Post by Saikat Dutta
Post by Daniel Liew
Post by Daniel Liew
Post by Saikat Dutta
**not** the finally linked executable. You are only
supposed to
Post by Saikat Dutta
Post by Daniel Liew
Post by Daniel Liew
Post by Daniel Liew
Post by Saikat Dutta
Post by Daniel Liew
Post by Daniel Liew
Post by Saikat Dutta
run
extract-bc on the the finally linked executable (or on
static
Post by Saikat Dutta
Post by Daniel Liew
Post by Daniel Liew
Post by Daniel Liew
Post by Saikat Dutta
Post by Daniel Liew
Post by Daniel Liew
Post by Saikat Dutta
libraries) **not** on object files.
I just tried this and it works fine. You should run
extract-bc
Post by Saikat Dutta
Post by Daniel Liew
Post by Daniel Liew
Post by Daniel Liew
Post by Saikat Dutta
Post by Daniel Liew
Post by Daniel Liew
Post by Saikat Dutta
on
the
"gzip" executable.
# I assume you have llvm-gcc in your path and it was the
pre-built
binary llvm-gcc 4.2
$ export LLVM_COMPILER=llvm-gcc
$ export WLLVM_OUTPUT=WARNING
$ export
LLVM_COMPILER_PATH=/your/path/to/the/llvm2.9/build/Release+Asserts/bin
Post by Saikat Dutta
Post by Daniel Liew
Post by Daniel Liew
Post by Daniel Liew
Post by Saikat Dutta
Post by Daniel Liew
Post by Daniel Liew
Post by Saikat Dutta
$ wget http://ftp.gnu.org/gnu/gzip/gzip-1.6.tar.xz
$ tar -xvf gzip-1.6.tar.xz
$ cd gzip-1.6
$ CC=wllvm ./configure
$ make -j4
$ extract-bc gzip
# gzip.bc will now be in the current directory
Post by Saikat Dutta
When I use extract bc on it,
error is generated. Please help.
-Saikat
Again... If there is an error message tell us what it is.
Hope that helps.
Dan.
Daniel Liew
2013-09-22 16:31:35 UTC
Permalink
I do not know the answer to that question.

I know for a fact that KLEE and klee-uclibc will compile on Ubuntu
12.04 LTS because I have used it. However KLEE does compile on very
new distributions (I use Arch Linux which is very new) but currently
klee-uclibc won't compile on very new kernels. We hope to fix that in
the near future though.
Post by Saikat Dutta
Thanks. What is the latest ubuntu version that can run klee?
Post by Daniel Liew
Many non GNU projects use autotools so this approach will probably work
with them. Please remember that KLEE does not have a runtime C++ library so
it is unlikely you will be able to run many C++ programs.
CMake is another common build system. You should be able to do something
similar when setting the CC flag. I'm not sure CFLAGS will work though (
instead you might need to change the CMAKE_BUILD_TYPE variable). You will
have to experiment (cmake-gui is your friend )
Remember if you set WLLVM_OUTPUT=DEBUG then the command line passed to the
compiler will be shown on stderr which you can use to check that the "-g"
(debug symbols) "-O0" ( almost no optimisation ) are being passed to the
compiler
Have fun with KLEE!
Thanks,
Dan.
Post by Saikat Dutta
Thanks .. its working :) ....can the same procedure be followed for
non-GNU applications?
Post by Daniel Liew
Oops. I appear to have mislead you. KLEE can execute gzip.bc . The
problem is by default the gzip build system tells llvm-gcc to optimise
the code (-O2). You need to tell llvm-gcc to not optimise the code
(this seems to prevent the llvm.objectsize.*) intrinsic from being
used. You can do this by forcing the value of CFLAGS at configure time
like so...
$ cd gzip-1.6
$ make clean
$ CC=wllvm CFLAGS="-O0 -g" ./configure
$ make
$ extract-bc gzip
Now
$ klee --libc=uclibc --posix-runtime gzip.bc --help
Works.
Hope that helps.
Dan.
Post by Saikat Dutta
Ok....Dead End then....Thanks for your help a lot. You were very patient
throughout. Let me know if theres any development in this !
Thanks.
-Saikat
On Sat, Sep 21, 2013 at 4:25 PM, Daniel Liew
Post by Daniel Liew
One possible workaround is to use an older version of LLVM and
llvm-gcc (I think you would need to use llvm-2.6) that doesn't
generate that intrinsic. I give no guarantees that this would work as
I have not tried using KLEE with this older version.
I've added an issue to the KLEE issue tracker on your behalf (
https://github.com/ccadar/klee/issues/33 ). There are no guarantees
that this will be fixed.
If you need this to work **now** you need to implement support for
this intrinsic yourself.
On 21 September 2013 11:42, Saikat Dutta
Post by Daniel Liew
LLVM ERROR: Code generator does not support intrinsic function
'llvm.objectsize.i32'!
So theres no existing solution to this?
On Sat, Sep 21, 2013 at 3:40 PM, Daniel Liew
Post by Daniel Liew
You're done. gzip.bc is a single LLVM module that is equivalent to the
gzip binary. Now you just need to run KLEE on it.
e.g.
$ klee --libc=uclibc --posix-runtime gzip.bc --help
/data/dev/KLEE/klee/bin-dbg/Release+Asserts/lib/libkleeRuntimePOSIX.bca
KLEE: output directory = "klee-out-1"
LLVM ERROR: Code generator does not support intrinsic function
'llvm.objectsize.i64'!
I should note that this does not work on my machine because of missing
support for a particular LLVM intrinsic function. You'll need to add
http://llvm.org/docs/LangRef.html#llvm-objectsize-intrinsic
A developer recently added support for another intrinsic so you could
use this as an example ( https://github.com/ccadar/klee/pull/27 )
If you get it working please consider contributing your code back to
the project so others can benefit.
Thanks,
Dan Liew.
On 21 September 2013 10:36, Saikat Dutta
Post by Saikat Dutta
I upgraded to python 2.7
"extract-bc gzip" produced gzip.bc
what to do next?
On Sat, Sep 21, 2013 at 2:20 PM, Daniel Liew
Post by Daniel Liew
Oh I forgot to mention that if you really don't feel like upgrading
you could just modify the extract-bc python script by removing
the
use
of argparse from the main() function and setting
inputFile = sys.argv[1]
On 20 September 2013 17:58, Daniel Liew
Post by Daniel Liew
Your python install is too old (the argparse module was
introduced
in
python2.7) you need python 2.7 or later. You can find your
current
python version by running
$ python --version
I think you said you were using Ubuntu 10.04 in which case the
python
version is probably 2.6.5 . Unless you have a good reason to be
running such an old version of python (or Ubuntu for that
matter)
you
should upgrade.
On 20 September 2013 17:50, Saikat Dutta
Post by Saikat Dutta
Hi,
File
"/home/saikat/Downloads/llvm_new/whole-program-llvm-llvm-gcc/extract-bc",
line 269, in <module>
sys.exit(main(sys.argv))
File
"/home/saikat/Downloads/llvm_new/whole-program-llvm-llvm-gcc/extract-bc",
line 212, in main
import argparse
ImportError: No module named argparse
On Fri, Sep 20, 2013 at 10:09 PM, Daniel Liew
On 20 September 2013 17:15, Saikat Dutta
Post by Saikat Dutta
Hi,
Everything goes fine with wllvm according to the way you
described
in
the
previous mail. No errors till make step.
If you don't tell us what the errors are we will **not** be
able
to
help you. If you see an error tell us what it is.
Post by Saikat Dutta
But instead of "gzip.bc" or
"gzip.o.bc" , ".gzip.o.bc" is being formed.
.gzip.o.bc is a LLVM bitcode file that corresponds to the
gzip.o
object file (this mostly likely corresponds with gzip.c) .
It is
**not** the finally linked executable. You are only
supposed to
run
extract-bc on the the finally linked executable (or on
static
libraries) **not** on object files.
I just tried this and it works fine. You should run
extract-bc
on
the
"gzip" executable.
# I assume you have llvm-gcc in your path and it was the
pre-built
binary llvm-gcc 4.2
$ export LLVM_COMPILER=llvm-gcc
$ export WLLVM_OUTPUT=WARNING
$ export
LLVM_COMPILER_PATH=/your/path/to/the/llvm2.9/build/Release+Asserts/bin
$ wget http://ftp.gnu.org/gnu/gzip/gzip-1.6.tar.xz
$ tar -xvf gzip-1.6.tar.xz
$ cd gzip-1.6
$ CC=wllvm ./configure
$ make -j4
$ extract-bc gzip
# gzip.bc will now be in the current directory
Post by Saikat Dutta
When I use extract bc on it,
error is generated. Please help.
-Saikat
Again... If there is an error message tell us what it is.
Hope that helps.
Dan.
Loading...