Browse Source

libc.so can't be unloaded, so move the hidden atexit() and pthread_atfork()

stubs for the executable from crtbegin.o into libc, which lets them be
excluded from static links that don't use them.
For this, drop the normal crt{begin,end}S.o from libc.so: the .init and .fini
sections for libc aren't called at the right times anyway, so it's good that
they're unused.  libc.so just needs __guard_local and the .note.openbsd.ident
section, so add them to stack_protector.c for now (this will be improved)
"good time" deraadt@
OPENBSD_5_9
guenther 9 years ago
parent
commit
be385217fe
1 changed files with 13 additions and 1 deletions
  1. +13
    -1
      src/lib/libc/stdlib/atexit.c

+ 13
- 1
src/lib/libc/stdlib/atexit.c View File

@ -1,4 +1,4 @@
/* $OpenBSD: atexit.c,v 1.23 2015/10/25 18:03:17 guenther Exp $ */
/* $OpenBSD: atexit.c,v 1.24 2015/11/10 04:14:03 guenther Exp $ */
/*
* Copyright (c) 2002 Daniel Hartmeier
* All rights reserved.
@ -109,6 +109,18 @@ unlock:
}
DEF_STRONG(__cxa_atexit);
/*
* Copy of atexit() used by libc and anything staticly linked into the
* executable. This passes NULL for the dso, so the callbacks are only
* invoked by exit() and not dlclose()
*/
int
atexit(void (*fn)(void))
{
return (__cxa_atexit((void (*)(void *))fn, NULL, NULL));
}
DEF_STRONG(atexit);
/*
* Call all handlers registered with __cxa_atexit() for the shared
* object owning 'dso'.


Loading…
Cancel
Save