From 545241c6f9fcd48ec878b8479df50cabf0af2d24 Mon Sep 17 00:00:00 2001 From: guenther <> Date: Sun, 25 Oct 2015 18:01:24 +0000 Subject: [PATCH] Hide __atexit and __atexit_register_cleanup() Wrap __cxa_{atexit,finalize}() so the call from exit() goes direct Switch regress/lib/libc/atexit/ to be built with -static so that it can still access __atexit* ok millert@ jca@ --- src/lib/libc/stdlib/atexit.c | 4 +++- src/lib/libc/stdlib/atexit.h | 7 ++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/lib/libc/stdlib/atexit.c b/src/lib/libc/stdlib/atexit.c index a3308057..4ccf8456 100644 --- a/src/lib/libc/stdlib/atexit.c +++ b/src/lib/libc/stdlib/atexit.c @@ -1,4 +1,4 @@ -/* $OpenBSD: atexit.c,v 1.21 2015/04/07 01:27:07 guenther Exp $ */ +/* $OpenBSD: atexit.c,v 1.22 2015/10/25 18:01:24 guenther Exp $ */ /* * Copyright (c) 2002 Daniel Hartmeier * All rights reserved. @@ -103,6 +103,7 @@ unlock: _ATEXIT_UNLOCK(); return (ret); } +DEF_STRONG(__cxa_atexit); /* * Call all handlers registered with __cxa_atexit() for the shared @@ -180,6 +181,7 @@ restart: } } +DEF_STRONG(__cxa_finalize); /* * Register the cleanup function diff --git a/src/lib/libc/stdlib/atexit.h b/src/lib/libc/stdlib/atexit.h index 3de2aa3b..e2e821de 100644 --- a/src/lib/libc/stdlib/atexit.h +++ b/src/lib/libc/stdlib/atexit.h @@ -1,4 +1,4 @@ -/* $OpenBSD: atexit.h,v 1.9 2014/06/18 19:01:10 kettenis Exp $ */ +/* $OpenBSD: atexit.h,v 1.10 2015/10/25 18:01:24 guenther Exp $ */ /* * Copyright (c) 2002 Daniel Hartmeier @@ -41,7 +41,12 @@ struct atexit { } fns[1]; /* the table itself */ }; +__BEGIN_HIDDEN_DECLS extern struct atexit *__atexit; /* points to head of LIFO stack */ +__END_HIDDEN_DECLS int __cxa_atexit(void (*)(void *), void *, void *); void __cxa_finalize(void *); + +PROTO_NORMAL(__cxa_atexit); +PROTO_NORMAL(__cxa_finalize);