diff options
Diffstat (limited to 'runtime')
-rw-r--r-- | runtime/CMakeLists.txt | 11 | ||||
-rw-r--r-- | runtime/Makefile.cmake.bitcode.rules | 9 | ||||
-rw-r--r-- | runtime/POSIX/fd.c | 3 | ||||
-rw-r--r-- | runtime/POSIX/stubs.c | 22 |
4 files changed, 34 insertions, 11 deletions
diff --git a/runtime/CMakeLists.txt b/runtime/CMakeLists.txt index 1e680e5d..c90cbda0 100644 --- a/runtime/CMakeLists.txt +++ b/runtime/CMakeLists.txt @@ -111,10 +111,17 @@ ExternalProject_Add_Step(BuildKLEERuntimes RuntimeBuild COMMAND ${ENV_BINARY} MAKEFLAGS="" ${MAKE_BINARY} -f Makefile.cmake.bitcode all ALWAYS ${EXTERNAL_PROJECT_BUILD_ALWAYS_ARG} WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}" + ${EXTERNAL_PROJECT_ADD_STEP_USES_TERMINAL_ARG} ) -# FIXME: Invoke `make clean` in the bitcode build system -# when the `clean` target is invoked. +# Target for cleaning the bitcode build system +# FIXME: Invoke `make clean` does not invoke this target. It's also weird +# that `ExternalProject` provides no way to do a clean. +add_custom_target(clean_runtime + COMMAND ${ENV_BINARY} MAKEFLAGS="" ${MAKE_BINARY} -f Makefile.cmake.bitcode clean + WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}" + ${ADD_CUSTOM_COMMAND_USES_TERMINAL_ARG} +) ############################################################################### # Runtime install diff --git a/runtime/Makefile.cmake.bitcode.rules b/runtime/Makefile.cmake.bitcode.rules index 8261ce99..2737eb80 100644 --- a/runtime/Makefile.cmake.bitcode.rules +++ b/runtime/Makefile.cmake.bitcode.rules @@ -70,8 +70,15 @@ else all:: build_at_level # Compute the directory to find sources -DIR_SUFFIX := $(subst $(RUNTIME_CMAKE_BINARY_DIR),,$(CURRENT_DIR)) +# Note: Use of $(realpath) is to resolve any symlinks +DIR_SUFFIX := $(subst $(realpath $(RUNTIME_CMAKE_BINARY_DIR)),,$(realpath $(CURRENT_DIR))) SRC_DIR := $(abspath $(ROOT_SRC)/$(DIR_SUFFIX)) +# Sanity check +ifeq ($(realpath $(SRC_DIR)),) +$(error SRC_DIR "$(SRC_DIR)" does not exist) +endif + +# Compute the directory to put build files LOCAL_BUILD_DIR := $(abspath $(ROOT_OBJ)/$(DIR_SUFFIX)) C_SRCS := $(shell echo $(SRC_DIR)/*.c) diff --git a/runtime/POSIX/fd.c b/runtime/POSIX/fd.c index 24b248e3..6f78c747 100644 --- a/runtime/POSIX/fd.c +++ b/runtime/POSIX/fd.c @@ -37,6 +37,9 @@ int klee_get_errno(void); /* Returns pointer to the symbolic file structure fs the pathname is symbolic */ static exe_disk_file_t *__get_sym_file(const char *pathname) { + if (!pathname) + return NULL; + char c = pathname[0]; unsigned i; diff --git a/runtime/POSIX/stubs.c b/runtime/POSIX/stubs.c index b4f31bf7..bb528ad4 100644 --- a/runtime/POSIX/stubs.c +++ b/runtime/POSIX/stubs.c @@ -240,21 +240,27 @@ int strverscmp (__const char *__s1, __const char *__s2) { return strcmp(__s1, __s2); /* XXX no doubt this is bad */ } -unsigned int gnu_dev_major(unsigned long long int __dev) __attribute__((weak)); -unsigned int gnu_dev_major(unsigned long long int __dev) { +#if __GLIBC_PREREQ(2, 25) +#define gnu_dev_type dev_t +#else +#define gnu_dev_type unsigned long long int +#endif + +unsigned int gnu_dev_major(gnu_dev_type __dev) __attribute__((weak)); +unsigned int gnu_dev_major(gnu_dev_type __dev) { return ((__dev >> 8) & 0xfff) | ((unsigned int) (__dev >> 32) & ~0xfff); } -unsigned int gnu_dev_minor(unsigned long long int __dev) __attribute__((weak)); -unsigned int gnu_dev_minor(unsigned long long int __dev) { +unsigned int gnu_dev_minor(gnu_dev_type __dev) __attribute__((weak)); +unsigned int gnu_dev_minor(gnu_dev_type __dev) { return (__dev & 0xff) | ((unsigned int) (__dev >> 12) & ~0xff); } -unsigned long long int gnu_dev_makedev(unsigned int __major, unsigned int __minor) __attribute__((weak)); -unsigned long long int gnu_dev_makedev(unsigned int __major, unsigned int __minor) { +gnu_dev_type gnu_dev_makedev(unsigned int __major, unsigned int __minor) __attribute__((weak)); +gnu_dev_type gnu_dev_makedev(unsigned int __major, unsigned int __minor) { return ((__minor & 0xff) | ((__major & 0xfff) << 8) - | (((unsigned long long int) (__minor & ~0xff)) << 12) - | (((unsigned long long int) (__major & ~0xfff)) << 32)); + | (((gnu_dev_type) (__minor & ~0xff)) << 12) + | (((gnu_dev_type) (__major & ~0xfff)) << 32)); } char *canonicalize_file_name (const char *name) __attribute__((weak)); |