From: guenther Date: Sun, 25 Oct 2015 18:01:24 +0000 (+0000) Subject: Hide __atexit and __atexit_register_cleanup() X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=57b9636d99ee5ff4ead201ad6808313f1fea86c8;p=openbsd 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@ --- diff --git a/lib/libc/Symbols.list b/lib/libc/Symbols.list index 09da8af364b..c1b9e261579 100644 --- a/lib/libc/Symbols.list +++ b/lib/libc/Symbols.list @@ -1428,8 +1428,6 @@ random /* stdlib */ _Exit -__atexit -__atexit_register_cleanup __cxa_atexit __cxa_finalize __isthreaded diff --git a/lib/libc/hidden/stdlib.h b/lib/libc/hidden/stdlib.h index 9d0e771f4bb..36e46072c50 100644 --- a/lib/libc/hidden/stdlib.h +++ b/lib/libc/hidden/stdlib.h @@ -1,4 +1,4 @@ -/* $OpenBSD: stdlib.h,v 1.4 2015/09/19 04:02:21 guenther Exp $ */ +/* $OpenBSD: stdlib.h,v 1.5 2015/10/25 18:01:24 guenther Exp $ */ /* $NetBSD: stdlib.h,v 1.25 1995/12/27 21:19:08 jtc Exp $ */ /*- @@ -39,6 +39,7 @@ __BEGIN_HIDDEN_DECLS char *__findenv(const char *, int, int *); +void __atexit_register_cleanup(void (*)(void)); __END_HIDDEN_DECLS #if 0 diff --git a/lib/libc/stdio/local.h b/lib/libc/stdio/local.h index 79f23654524..94b2804ff18 100644 --- a/lib/libc/stdio/local.h +++ b/lib/libc/stdio/local.h @@ -1,4 +1,4 @@ -/* $OpenBSD: local.h,v 1.22 2015/10/04 07:33:46 guenther Exp $ */ +/* $OpenBSD: local.h,v 1.23 2015/10/25 18:01:24 guenther Exp $ */ /*- * Copyright (c) 1990, 1993 @@ -45,8 +45,6 @@ void _cleanup(void); int _fwalk(int (*)(FILE *)); PROTO_NORMAL(_fwalk); -extern void __atexit_register_cleanup(void (*)(void)); - __BEGIN_HIDDEN_DECLS int __sflush(FILE *); int __sflush_locked(FILE *); diff --git a/lib/libc/stdlib/atexit.c b/lib/libc/stdlib/atexit.c index a33080571fe..4ccf84562c9 100644 --- a/lib/libc/stdlib/atexit.c +++ b/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/lib/libc/stdlib/atexit.h b/lib/libc/stdlib/atexit.h index 3de2aa3bf60..e2e821de04b 100644 --- a/lib/libc/stdlib/atexit.h +++ b/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); diff --git a/regress/lib/libc/atexit/Makefile b/regress/lib/libc/atexit/Makefile index c14b3c7ac47..057844d767f 100644 --- a/regress/lib/libc/atexit/Makefile +++ b/regress/lib/libc/atexit/Makefile @@ -1,9 +1,10 @@ -# $OpenBSD: Makefile,v 1.5 2003/07/31 22:46:59 david Exp $ +# $OpenBSD: Makefile,v 1.6 2015/10/25 18:01:24 guenther Exp $ NOMAN= PROG=atexit_test -CPPFLAGS+=-I${.CURDIR}/../../../../lib/libc +CPPFLAGS+=-I${.CURDIR}/../../../../lib/libc -D'PROTO_NORMAL(x)=__asm("")' CLEANFILES+= invalid.out valid.out +LDADD=-static run-regress-atexit_test: ${PROG} ./${PROG} -valid 2>${.OBJDIR}/valid.out