freebsd-skq/libexec
Konstantin Belousov 760e34772c Fix order of destructors between main binary and libraries.
Since inits for the main binary are run from rtld (for some time), the
rtld_exit atexit(3) handler, which is passed from rtld to the program
entry and installed by csu, is installed after any atexit(3) handlers
installed by main binary constructors.  This means that rtld_exit() is
fired before main binary handlers.

Typical C++ static constructors are executed from init (either binary
or libs) but use atexit(3) to ensure that destructors are called in
the right order, independent of the linking order.  Also, C++
libraries finalizers call __cxa_finalize(3) to flush library'
atexit(3) entries.  Since atexit(3) entry is cleared after being run,
this would be mostly innocent, except that, atexit(rtld_exit) done
after main binary constructors, makes destructors from libraries
executed before destructors for main.

Fix by reordering atexit(rtld_exit) before inits for main binary, same
as it happened when inits were called by csu.  Do it using new private
libc symbol with pre-defined ABI.

Reported. tested, and reviewed by:	kan
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2019-04-15 13:03:09 +00:00
..
atf
atrun
blacklistd-helper
bootpd bootpd: validate hardware type 2018-12-19 18:16:29 +00:00
comsat
dma Replace send-mail with the more standarized sendmail, we do not create 2017-12-27 06:23:50 +00:00
fingerd
ftpd Move ftpusers to libexec/ftpd/ 2018-08-21 17:07:52 +00:00
getty Fix potential buffer overflow and undefined behavior. 2019-01-26 20:43:28 +00:00
hyperv
mail.local
makewhatis.local makewhatis: do not try to operate on read-only mounted directories 2018-10-27 17:15:58 +00:00
mknetid
pppoed
rbootd
rc Revert r346017 pending compiled-in zfs fix 2019-04-10 07:51:13 +00:00
revnetgroup
rpc.rquotad This exposes ZFS user and group quotas via the normal 2018-07-05 22:56:13 +00:00
rpc.rstatd
rpc.rusersd
rpc.rwalld
rpc.sprayd rpc.sprayd: raise WARNS to 6 2018-03-05 16:11:07 +00:00
rtld-aout
rtld-elf Fix order of destructors between main binary and libraries. 2019-04-15 13:03:09 +00:00
save-entropy random(4): Attempt to persist entropy promptly 2019-03-31 04:57:50 +00:00
smrsh
talkd Remove All Rights Reserved 2019-02-05 21:37:34 +00:00
tcpd
telnetd
tests
tftp-proxy
tftpd Drop "All rights reserved" from the files I own 2019-03-11 22:23:56 +00:00
ulog-helper
ypxfr
Makefile Move the rc framework out of sbin/init into libexec/rc. 2018-10-17 16:49:11 +00:00
Makefile.amd64
Makefile.i386
Makefile.inc