[Bug 115631] [libc] [patch] [request] make dlclose(3) atexit-aware

bugzilla-noreply at freebsd.org bugzilla-noreply at freebsd.org
Wed Nov 21 00:52:07 UTC 2018


https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=115631

--- Comment #8 from Bryan Drewery <bdrewery at FreeBSD.org> ---
*Very naive and untested*.
It seems like we need something like this:

diff --git lib/libc/stdlib/atexit.c lib/libc/stdlib/atexit.c
index bc9ad3ebd7bf..8df6cd4e31b0 100644
--- lib/libc/stdlib/atexit.c
+++ lib/libc/stdlib/atexit.c
@@ -125,6 +125,8 @@ atexit_register(struct atexit_fn *fptr)
        return 0;
 }

+extern void *__dso_handle __hidden;
+
 /*
  * Register a function to be performed at exit.
  */
@@ -137,7 +139,7 @@ atexit(void (*func)(void))
        fn.fn_type = ATEXIT_FN_STD;
        fn.fn_ptr.std_func = func;
        fn.fn_arg = NULL;
-       fn.fn_dso = NULL;
+       fn.fn_dso = __dso_handle;

        error = atexit_register(&fn);
        return (error);

-- 
You are receiving this mail because:
You are the assignee for the bug.


More information about the freebsd-bugs mailing list