Home | History | Annotate | only in /src/lib/libc/misc
History log of /src/lib/libc/misc
RevisionDateAuthorComments
 1.5 20-Apr-2021  christos Instead of compiling files with -fcommon, create an include file and declare
the 3 symbols that need to be common using an attribute. Put all the 3 symbol
definitions in libc in one place (initfini.c). Reviewed by joerg@
 1.4 22-Apr-2020  joerg Explicitly use -fcommon for globals shared between libc and CSU.
 1.3 03-Aug-2018  kamil Add a support to build ubsan.c in libc

Under the condition of MKLIBCSANITIZER==yes link ubsan.c into libc.

This is a clean-room reimplementation from scratch of the Undefined
Behavior runtime called micro-UBSan (or uBSan - user-UBSan).
 1.2 29-Jan-2013  matt branches: 1.2.28; 1.2.30;
Add ${ARCHDIR}/misc to path
 1.1 13-Nov-2007  ad branches: 1.1.4; 1.1.32; 1.1.38;
- stack_protector.c doesn't really belong under sys/. Add a new directory
for misc support routines and put it there.
- Add a libc constructor. Use this to initialize threading and the
stack protector stuff. libpthread cannot be initialized safely using
its own constructor because libc and libpthread are deeply intertwined.
PR bin/37347
 1.1.38.1 25-Feb-2013  tls resync with head
 1.1.32.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.1.4.2 09-Jan-2008  matt sync with HEAD
 1.1.4.1 13-Nov-2007  matt file Makefile.inc was added on branch matt-armv6 on 2008-01-09 01:34:10 +0000
 1.2.30.1 10-Jun-2019  christos Sync with HEAD
 1.2.28.1 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.17 20-Jan-2024  christos Catch up with all the lint warnings since exit on warning was disabled.
Disable 'missing header declaration' and 'nested extern' warnings for now.
 1.16 18-Jul-2023  riastradh libc: Use RB_TREE_INITIALIZER to nix initfini.c/_env.c coupling.

Doesn't actually help to remove _env.c from programs that don't use
it, though, because various internal things like __diagassert13 still
call getenv.
 1.15 20-Apr-2021  christos Instead of compiling files with -fcommon, create an include file and declare
the 3 symbols that need to be common using an attribute. Put all the 3 symbol
definitions in libc in one place (initfini.c). Reviewed by joerg@
 1.14 17-Jun-2017  joerg PR 51654: Don't initialize _dlauxinfo for static binaries.

Emacs likes save all memory of the main binary and the first run of
_libc_init via .init will get the wrong (old) value of __ps_strings.
By avoiding the initialization of _dlauxinfo for shared applications,
it will be touched only by the _libc_init call from crt0.o itself,
at which point __ps_strings is correct.
 1.13 26-Nov-2016  dholland branches: 1.13.6;
More of previous.
 1.12 26-Nov-2016  dholland fix comment about initialization-time calls; ok joerg
 1.11 19-Aug-2013  matt branches: 1.11.8;
Put the startup code in .text.startup
 1.10 16-Feb-2012  joerg branches: 1.10.2;
Add _dlauxinfo helper function to provide access to the ELF auxilary
vector. This can normally be found via __ps_strings, but libc is
initialised too early when linked dynamically and doesn't have access to
it yet, so provide an alternative mechanism via ld.elf_so.
Bump libc minor.
 1.9 09-Mar-2011  joerg branches: 1.9.4;
Add TLS support infrastructure. For dynamic binaries, ld.elf_so exports
_rtld_tls_allocate and _rtld_tls_free. libpthread uses this functions to
setup the thread private area of all new threads. ld.elf_so is
responsible for setting up the private area for the initial thread.
Similar functions are called from _libc_init for static binaries, using
dl_iterate_phdr to access the ELF Program Header.

Add test cases to exercise the different TLS storage models. Test cases
are compiled and installed on all platforms, but are skipped on
platforms not marked for TLS support.

This material is based upon work partially supported by
The NetBSD Foundation under a contract with Joerg Sonnenberger.

It is inspired by the TLS support in FreeBSD by Doug Rabson and the
clean ups of the DragonFly port of the original FreeBSD modifications.
 1.8 07-Mar-2011  joerg Pass down ELF Auxillary Vectors for static NetBSD binaries too.
Rename __libc_init to _libc_init and call it explicitly from CSU code.
This enforces the constructor run order for newly linked programs.
Keep it as constructor with run-once semantic for binary compatibility.
Implement dl_iterate_phdr for statically linked programs.

This material is based upon work partially supported by
The NetBSD Foundation under a contract with Joerg Sonnenberger.
 1.7 14-Nov-2010  tron Improve and simplify implementation of *env(3) functions:
- Use RB tree to keep track of memory allocated via setenv(3) as
suggested by Enami Tsugutomo in private e-mail.
This simplifies the code a lot as we no longer need to keep the size
of "environ" in sync with an array of allocated environment variables.
It also makes it possible to free environment variables in unsetenv(3)
if something has changed the order of the "environ" array.
- Fix a bug in getenv(3) and getenv_r(3) which would return bogus
results e.g. for " getenv("A=B") " if an environment variable "A"
with value "B=C" exists.
- Clean up the internal functions:
- Don't expose the read/write lock for the environment to other parts
of "libc". Provide locking functions instead.
- Use "bool" to report success or failure.
- Use "ssize_t" or "size_t" instead of "int" for indexes.
- Provide internal functions with simpler interfaces e.g. don't
combine return values and reference arguments.
- Don't copy "environ" into an allocated block unless we really need
to grow it.

Code reviewed by Joerg Sonnenberger and Christos Zoulas, tested by
Joerg Sonnenberger and me. These changes also fix problems in
zsh 4.3.* and pam_ssh according to Joerg.
 1.6 28-Jun-2010  joerg Ensure that initfini.c is referenced by exit.c. The start up code has to
reference the latter as a return of main() results in a call to exit(3),
so this ensures that the libc constructors are run for statically linked
programs. Fixes PR 37454.
 1.5 28-Apr-2008  martin branches: 1.5.6; 1.5.8; 1.5.14;
Remove clause 3 and 4 from TNF licenses
 1.4 25-Feb-2008  xtraeme branches: 1.4.2;
Make the atexit mutex recursive and initialize it in __libc_init()
as suggested by ad@, based on the patch provided by Sverre Froyen
in lib/37654.

Reviewed by ad@ and jmcneill@.
 1.3 10-Feb-2008  ad branches: 1.3.2;
Enable the atomic ops in userspace.
 1.2 13-Nov-2007  ad branches: 1.2.4;
- Make it pass lint.
- Add RCSID.
 1.1 13-Nov-2007  ad - stack_protector.c doesn't really belong under sys/. Add a new directory
for misc support routines and put it there.
- Add a libc constructor. Use this to initialize threading and the
stack protector stuff. libpthread cannot be initialized safely using
its own constructor because libc and libpthread are deeply intertwined.
PR bin/37347
 1.2.4.3 23-Mar-2008  matt sync with HEAD
 1.2.4.2 09-Jan-2008  matt sync with HEAD
 1.2.4.1 13-Nov-2007  matt file initfini.c was added on branch matt-armv6 on 2008-01-09 01:34:10 +0000
 1.3.2.1 24-Mar-2008  keiichi sync with head.
 1.4.2.1 18-May-2008  yamt sync with head.
 1.5.14.1 20-May-2011  matt bring matt-nb5-mips64 up to date with netbsd-5-1-RELEASE (except compat).
 1.5.8.2 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.5.8.1 28-Apr-2008  martin file initfini.c was added on branch christos-time_t on 2008-04-28 20:23:01 +0000
 1.5.6.1 16-Jul-2010  riz Pull up following revision(s) (requested by joerg in ticket #1423):
lib/libc/stdlib/exit.c: revision 1.12
lib/libc/misc/initfini.c: revision 1.6
Ensure that initfini.c is referenced by exit.c. The start up code has to
reference the latter as a return of main() results in a call to exit(3),
so this ensures that the libc constructors are run for statically linked
programs. Fixes PR 37454.
 1.9.4.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.9.4.1 17-Apr-2012  yamt sync with head
 1.10.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.11.8.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.13.6.1 21-Jun-2017  snj Pull up following revision(s) (requested by joerg in ticket #44):
lib/libc/misc/initfini.c: revision 1.14
PR 51654: Don't initialize _dlauxinfo for static binaries.
Emacs likes save all memory of the main binary and the first run of
_libc_init via .init will get the wrong (old) value of __ps_strings.
By avoiding the initialization of _dlauxinfo for shared applications,
it will be touched only by the _libc_init call from crt0.o itself,
at which point __ps_strings is correct.
 1.10 02-May-2025  riastradh ld.elf_so: Use __sysctl() syscall stub rather than sysctl() wrapper.

This avoids pulling in some unnecessary junk from libc, saving on a
couple kilobytes of space and some relative relocations at runtime.

PR lib/59387: ld.elf_so: needlessly includes libc/gen/sysctl.c user.*
 1.9 19-Aug-2013  matt branches: 1.9.38;
Put the startup code in .text.startup
 1.8 13-Mar-2012  christos branches: 1.8.2;
PR/45989: Martin Husemann: lint invocation does include -w only on i386

- turn lint -w for all the platforms after fixing the lint warnings.
- add _DIAGASSERTS() for casts that would assign values to types that
would not fit.
- change types, add casts
- change into ansii prototypes
- turn on _DIAGNOSTIC for libc (during current, to be eliminated for release
builds)

approved by core@
 1.7 08-Dec-2011  joerg Use a constant array for the MIB. Newer LLVM decided that mib[] warranted
stack protections, with the obvious crash after the setup was done.
As a positive side effect, code size shrinks a bit.
 1.6 16-Sep-2011  joerg branches: 1.6.2;
Use __dead
 1.5 07-Dec-2010  joerg Don't use argument as direct format string.
 1.4 17-Nov-2009  drochner -delete prototypes which are already in <ssp/ssp.h>
-make __fail __noreturn__
 1.3 30-Jan-2009  ad Make threaded programs die correctly:

kill(getpid(), SIGFOO) -> raise(SIGFOO)
 1.2 03-Jun-2008  ad branches: 1.2.4; 1.2.6;
xprintf returns void.
 1.1 13-Nov-2007  ad branches: 1.1.4; 1.1.8; 1.1.10;
- stack_protector.c doesn't really belong under sys/. Add a new directory
for misc support routines and put it there.
- Add a libc constructor. Use this to initialize threading and the
stack protector stuff. libpthread cannot be initialized safely using
its own constructor because libc and libpthread are deeply intertwined.
PR bin/37347
 1.1.10.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.1.8.1 17-Jun-2008  yamt sync with head.
 1.1.4.2 09-Jan-2008  matt sync with HEAD
 1.1.4.1 13-Nov-2007  matt file stack_protector.c was added on branch matt-armv6 on 2008-01-09 01:34:11 +0000
 1.2.6.2 03-Jun-2008  ad xprintf returns void.
 1.2.6.1 03-Jun-2008  ad file stack_protector.c was added on branch christos-time_t on 2008-06-03 19:22:38 +0000
 1.2.4.1 02-Feb-2009  snj Pull up following revision(s) (requested by ad in ticket #399):
lib/libc/misc/stack_protector.c: revision 1.3
lib/libc/stdlib/abort.c: revision 1.13
lib/libc/thread-stub/thread-stub.c: revision 1.21
Make threaded programs die correctly:
kill(getpid(), SIGFOO) -> raise(SIGFOO)
 1.6.2.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.6.2.1 17-Apr-2012  yamt sync with head
 1.8.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.9.38.1 02-Aug-2025  perseant Sync with HEAD

RSS XML Feed