diff options
author | Martin Nowack <m.nowack@imperial.ac.uk> | 2018-07-22 23:12:49 +0100 |
---|---|---|
committer | Cristian Cadar <c.cadar@imperial.ac.uk> | 2018-09-10 15:24:17 +0100 |
commit | 3d373d8b5c101e0798ea8a5e8015aa03537d02d8 (patch) | |
tree | dbf0f42bd7707b4c2d2505be803c770c70f6dceb /runtime/POSIX | |
parent | 0f1b68e093dfe0357adf400ea7b4746f09fb4cba (diff) | |
download | klee-3d373d8b5c101e0798ea8a5e8015aa03537d02d8.tar.gz |
POSIX: Add invocation of klee_init_env into wrapper before calling main
To enable the POSIX support, the former implementation instrumented the main function and inserted a call to `klee_init_env` at the beginning. This has multiple disadvantages: * debugging information was not correctly propagated leaving the call to `klee_init_env` without debug information * the main function always required `int arg, char**` as part of the function definition of `main` Based on the new linking infrastructure, we can now add an additional wrapper `__klee_posix_wraper(int, char**)` that gets always called when POSIX support is enabled. It executes `klee_init_env` and after that calls the `main` function. Enabling POSIX support only requires the renaming of the user provided `main` into `__klee_posix_wrapped_main` in addition to linking.
Diffstat (limited to 'runtime/POSIX')
-rw-r--r-- | runtime/POSIX/klee_init_env.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/runtime/POSIX/klee_init_env.c b/runtime/POSIX/klee_init_env.c index 1fa6adea..265c3bfd 100644 --- a/runtime/POSIX/klee_init_env.c +++ b/runtime/POSIX/klee_init_env.c @@ -209,3 +209,12 @@ usage: (klee_init_env) [options] [program arguments]\n\ save_all_writes_flag, fd_fail); } +/* The following function represents the main function of the user application + * and is renamed during POSIX setup */ +int __klee_posix_wrapped_main(int argc, char **argv); + +/* This wrapper gets called instead of main if POSIX setup is used */ +int __klee_posix_wrapper(int argcPtr, char **argvPtr) { + klee_init_env(&argcPtr, &argvPtr); + return __klee_posix_wrapped_main(argcPtr, argvPtr); +} |