diff options
author | guenther <> | 2015-10-25 18:01:24 +0000 |
---|---|---|
committer | guenther <> | 2015-10-25 18:01:24 +0000 |
commit | f99a409614d6c4522947819dc74a336ee3815b6c (patch) | |
tree | d693093c1d02f4d871efc5d2a1f844d4efa6f765 /src | |
parent | 42fee343ee2dc57b8df51e274a7981adeaa05c85 (diff) | |
download | openbsd-f99a409614d6c4522947819dc74a336ee3815b6c.tar.gz openbsd-f99a409614d6c4522947819dc74a336ee3815b6c.tar.bz2 openbsd-f99a409614d6c4522947819dc74a336ee3815b6c.zip |
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@
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/libc/stdlib/atexit.c | 4 | ||||
-rw-r--r-- | src/lib/libc/stdlib/atexit.h | 7 | ||||
-rw-r--r-- | src/regress/lib/libc/atexit/Makefile | 5 |
3 files changed, 12 insertions, 4 deletions
diff --git a/src/lib/libc/stdlib/atexit.c b/src/lib/libc/stdlib/atexit.c index a33080571f..4ccf84562c 100644 --- a/src/lib/libc/stdlib/atexit.c +++ b/src/lib/libc/stdlib/atexit.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: atexit.c,v 1.21 2015/04/07 01:27:07 guenther Exp $ */ | 1 | /* $OpenBSD: atexit.c,v 1.22 2015/10/25 18:01:24 guenther Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2002 Daniel Hartmeier | 3 | * Copyright (c) 2002 Daniel Hartmeier |
4 | * All rights reserved. | 4 | * All rights reserved. |
@@ -103,6 +103,7 @@ unlock: | |||
103 | _ATEXIT_UNLOCK(); | 103 | _ATEXIT_UNLOCK(); |
104 | return (ret); | 104 | return (ret); |
105 | } | 105 | } |
106 | DEF_STRONG(__cxa_atexit); | ||
106 | 107 | ||
107 | /* | 108 | /* |
108 | * Call all handlers registered with __cxa_atexit() for the shared | 109 | * Call all handlers registered with __cxa_atexit() for the shared |
@@ -180,6 +181,7 @@ restart: | |||
180 | 181 | ||
181 | } | 182 | } |
182 | } | 183 | } |
184 | DEF_STRONG(__cxa_finalize); | ||
183 | 185 | ||
184 | /* | 186 | /* |
185 | * Register the cleanup function | 187 | * Register the cleanup function |
diff --git a/src/lib/libc/stdlib/atexit.h b/src/lib/libc/stdlib/atexit.h index 3de2aa3bf6..e2e821de04 100644 --- a/src/lib/libc/stdlib/atexit.h +++ b/src/lib/libc/stdlib/atexit.h | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: atexit.h,v 1.9 2014/06/18 19:01:10 kettenis Exp $ */ | 1 | /* $OpenBSD: atexit.h,v 1.10 2015/10/25 18:01:24 guenther Exp $ */ |
2 | 2 | ||
3 | /* | 3 | /* |
4 | * Copyright (c) 2002 Daniel Hartmeier | 4 | * Copyright (c) 2002 Daniel Hartmeier |
@@ -41,7 +41,12 @@ struct atexit { | |||
41 | } fns[1]; /* the table itself */ | 41 | } fns[1]; /* the table itself */ |
42 | }; | 42 | }; |
43 | 43 | ||
44 | __BEGIN_HIDDEN_DECLS | ||
44 | extern struct atexit *__atexit; /* points to head of LIFO stack */ | 45 | extern struct atexit *__atexit; /* points to head of LIFO stack */ |
46 | __END_HIDDEN_DECLS | ||
45 | 47 | ||
46 | int __cxa_atexit(void (*)(void *), void *, void *); | 48 | int __cxa_atexit(void (*)(void *), void *, void *); |
47 | void __cxa_finalize(void *); | 49 | void __cxa_finalize(void *); |
50 | |||
51 | PROTO_NORMAL(__cxa_atexit); | ||
52 | PROTO_NORMAL(__cxa_finalize); | ||
diff --git a/src/regress/lib/libc/atexit/Makefile b/src/regress/lib/libc/atexit/Makefile index c14b3c7ac4..057844d767 100644 --- a/src/regress/lib/libc/atexit/Makefile +++ b/src/regress/lib/libc/atexit/Makefile | |||
@@ -1,9 +1,10 @@ | |||
1 | # $OpenBSD: Makefile,v 1.5 2003/07/31 22:46:59 david Exp $ | 1 | # $OpenBSD: Makefile,v 1.6 2015/10/25 18:01:24 guenther Exp $ |
2 | 2 | ||
3 | NOMAN= | 3 | NOMAN= |
4 | PROG=atexit_test | 4 | PROG=atexit_test |
5 | CPPFLAGS+=-I${.CURDIR}/../../../../lib/libc | 5 | CPPFLAGS+=-I${.CURDIR}/../../../../lib/libc -D'PROTO_NORMAL(x)=__asm("")' |
6 | CLEANFILES+= invalid.out valid.out | 6 | CLEANFILES+= invalid.out valid.out |
7 | LDADD=-static | ||
7 | 8 | ||
8 | run-regress-atexit_test: ${PROG} | 9 | run-regress-atexit_test: ${PROG} |
9 | ./${PROG} -valid 2>${.OBJDIR}/valid.out | 10 | ./${PROG} -valid 2>${.OBJDIR}/valid.out |