From a04538aa72092bab9d255fe0c2e3b08dfad1e4e2 Mon Sep 17 00:00:00 2001 From: Alastair Reid Date: Sat, 1 Aug 2020 14:13:47 +0000 Subject: Definition of __cxa_thread_atexit_impl for the KLEE libc. This is a thread-local version of __cxa_atexit (but, in the absence of threads, it is sufficient to just call __cxa_atexit). The test is based on the existing test for atexit in test/Runtime/Uclibc/2008-03-04-libc-atexit-uses-dso-handle.c The motivation for adding this function is to support the Rust standard library that calls __cxa_thread_atexit_impl. This function is usually a weak symbol but, in KLEE, this behaves like a call to an unknown function and chaos ensues. Worse, it happens just as the program is cleanly shutting itself down, so programs that are cleanly exiting crash with the wrong message. --- runtime/klee-libc/__cxa_atexit.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'runtime') diff --git a/runtime/klee-libc/__cxa_atexit.c b/runtime/klee-libc/__cxa_atexit.c index 990b645d..eb0c3e41 100644 --- a/runtime/klee-libc/__cxa_atexit.c +++ b/runtime/klee-libc/__cxa_atexit.c @@ -47,3 +47,8 @@ int __cxa_atexit(void (*fn)(void*), return 0; } +// This variant is part of more recent glibc versions and +// is required by the Rust standard library +int __cxa_thread_atexit_impl(void (*fn)(void*), void *arg, void *dso_handle) { + return __cxa_atexit(fn, arg, dso_handle); +} -- cgit 1.4.1