History log of /openbsd-current/lib/csu/crtbegin.c
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 1.26 09-Jan-2019 visa

Use static consistently with definitions of functions that have been
declared static.

OK guenther@


# 1.25 21-Dec-2018 guenther

Add support for {preinit,init,fini}_array sections in static binaries

ok kettenis@


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE
# 1.24 19-Feb-2017 guenther

Move static variables from .data to .bss by not initializing them to zero

ok kettenis@


# 1.23 21-Jan-2017 guenther

Make crtbegin.c and crtbeginS.c consistent on stylistic points

ok kettenis@


# 1.22 21-Jan-2017 guenther

Declare the symbols that label the .ctors, .dtors, .eh_frame, and .jcr
sections as extern hidden arrays of indefinite size, so that the compiler
(well, clang) doesn't believe it knows the exact contents and thus optimize
things into infinite loops. Actually set the symbols to be in the sections
and insert the leading and trailing values via __asm().

Problem pointed out by patrick@
testing and ok kettenis@


# 1.21 22-Dec-2016 kettenis

Don't make __CTOR_LIST__ and __DTOR_LIST__ const. This makes the .ctors and
.dtors sections writable just like they are in crtend.o and code generated
by compilers. This is necessary to make sure that linkers that respect the
ELF spec a bit better (such as lld) correctly concatenate the secttions.

ok deraadt@


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE
# 1.20 10-Nov-2015 guenther

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@


Revision tags: OPENBSD_5_8_BASE
# 1.19 07-Apr-2015 guenther

Make pthread_atfork() track the DSO that called it like atexit() does,
unregistering callbacks if the DSO is unloaded. Move the callback
handling from libpthread to libc, though libpthread still overrides the
inner call to handle locking and thread-library reinitialization.
Major version bump for both libc and libpthread.

verification that this fixes various ports ajacoutot@
asm assistance miod@; ok millert@ deraadt@


# 1.18 04-Apr-2015 guenther

gcc 2.x is dead

ok millert@


Revision tags: OPENBSD_5_7_BASE
# 1.17 28-Dec-2013 kettenis

Move atexit(3) into crtbegin.c and certbeginS.c such that we can pass the
right __dso_handle and have dlopen'ed shared objects run their atexit handlers
when they get unloaded. This is what Linux does, and several ports depend on
this behaviour (and will crash upon exit without this chang).

Based on an earlier diff from matthew@
Tested by ajacoutot@
ok deraadt@


# 1.16 08-Sep-2012 matthew

Reverse the order that ctors and dtors are run in accordance with
GCC's documentation. Fixes GNU C++'s init_priority attribute.

ok miod


# 1.15 28-Aug-2012 matthew

Add __guard_local as a hidden symbol to ld.so, kernel, and every
executable and DSO (via crtbegin.c/crtbeginS.c). Not used yet, but
needed before GCC can start emitting -fstack-protector code that uses
them instead of __guard.


# 1.14 01-May-2010 kettenis

Sprinkle a few __used markers to prevent gcc4 from throwing away essential
bits of code and data. With this change gcc4 builds usable crt*.o on sparc64,
other architectures probably need some more love.

ok marco@, jsg@


# 1.13 13-Apr-2009 kurt

Add gcj java class registration hooks for gcc3 elf archs. From NetBSD
with minor differences.

okay kettenis@ drahn@


# 1.12 03-Sep-2007 millert

Add __cxa_atexit() support for gcc3. This provides support for shared object destructors called at dlclose() time. Inspired by similar changes in FreeBSD and NetBSD.


# 1.11 26-Oct-2004 kettenis

Change __register_frame_info into a weakly defined symbol.
ok drahn@, pval@, deraadt@


# 1.10 10-Oct-2004 kettenis

Add support for DWARF2 exception handling.
ok drahn@, millert@


# 1.9 26-Jan-2004 espie

add finalized guard to destructor calls, to prevent multiple calls.
stop most kde apps from burping all over the place on exit, which
means that, somehow, our destructors get registered twice... :-(

Okay drahn@


# 1.8 26-Jan-2004 espie

small clean-up: typedef to desambiguate const, prototypes...

ok drahn@, some time ago.


# 1.7 08-Jan-2004 drahn

__init/__fini handling on ELF has not been correct. It is supposed to
be a section which code stubs (branches) can be added to initialize/destructor
This adds MD stubs to allow this to operate as expected. should fix wine
and behave according to ELF specs. ok miod@


# 1.6 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.5 03-Feb-2001 art

oops.


# 1.4 03-Feb-2001 art

Schedule running of __fini in __init, not __start.


# 1.3 03-Feb-2001 art

Add an OS note identifying OpenBSD binaries.
This appears to be the standard way to do it.


# 1.2 03-Feb-2001 art

Decruftification.


# 1.1 03-Feb-2001 art

Create a common_elf directory with crtbegin and crtend that can
be shared between archs.


# 1.25 21-Dec-2018 guenther

Add support for {preinit,init,fini}_array sections in static binaries

ok kettenis@


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE
# 1.24 19-Feb-2017 guenther

Move static variables from .data to .bss by not initializing them to zero

ok kettenis@


# 1.23 21-Jan-2017 guenther

Make crtbegin.c and crtbeginS.c consistent on stylistic points

ok kettenis@


# 1.22 21-Jan-2017 guenther

Declare the symbols that label the .ctors, .dtors, .eh_frame, and .jcr
sections as extern hidden arrays of indefinite size, so that the compiler
(well, clang) doesn't believe it knows the exact contents and thus optimize
things into infinite loops. Actually set the symbols to be in the sections
and insert the leading and trailing values via __asm().

Problem pointed out by patrick@
testing and ok kettenis@


# 1.21 22-Dec-2016 kettenis

Don't make __CTOR_LIST__ and __DTOR_LIST__ const. This makes the .ctors and
.dtors sections writable just like they are in crtend.o and code generated
by compilers. This is necessary to make sure that linkers that respect the
ELF spec a bit better (such as lld) correctly concatenate the secttions.

ok deraadt@


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE
# 1.20 10-Nov-2015 guenther

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@


Revision tags: OPENBSD_5_8_BASE
# 1.19 07-Apr-2015 guenther

Make pthread_atfork() track the DSO that called it like atexit() does,
unregistering callbacks if the DSO is unloaded. Move the callback
handling from libpthread to libc, though libpthread still overrides the
inner call to handle locking and thread-library reinitialization.
Major version bump for both libc and libpthread.

verification that this fixes various ports ajacoutot@
asm assistance miod@; ok millert@ deraadt@


# 1.18 04-Apr-2015 guenther

gcc 2.x is dead

ok millert@


Revision tags: OPENBSD_5_7_BASE
# 1.17 28-Dec-2013 kettenis

Move atexit(3) into crtbegin.c and certbeginS.c such that we can pass the
right __dso_handle and have dlopen'ed shared objects run their atexit handlers
when they get unloaded. This is what Linux does, and several ports depend on
this behaviour (and will crash upon exit without this chang).

Based on an earlier diff from matthew@
Tested by ajacoutot@
ok deraadt@


# 1.16 08-Sep-2012 matthew

Reverse the order that ctors and dtors are run in accordance with
GCC's documentation. Fixes GNU C++'s init_priority attribute.

ok miod


# 1.15 28-Aug-2012 matthew

Add __guard_local as a hidden symbol to ld.so, kernel, and every
executable and DSO (via crtbegin.c/crtbeginS.c). Not used yet, but
needed before GCC can start emitting -fstack-protector code that uses
them instead of __guard.


# 1.14 01-May-2010 kettenis

Sprinkle a few __used markers to prevent gcc4 from throwing away essential
bits of code and data. With this change gcc4 builds usable crt*.o on sparc64,
other architectures probably need some more love.

ok marco@, jsg@


# 1.13 13-Apr-2009 kurt

Add gcj java class registration hooks for gcc3 elf archs. From NetBSD
with minor differences.

okay kettenis@ drahn@


# 1.12 03-Sep-2007 millert

Add __cxa_atexit() support for gcc3. This provides support for shared object destructors called at dlclose() time. Inspired by similar changes in FreeBSD and NetBSD.


# 1.11 26-Oct-2004 kettenis

Change __register_frame_info into a weakly defined symbol.
ok drahn@, pval@, deraadt@


# 1.10 10-Oct-2004 kettenis

Add support for DWARF2 exception handling.
ok drahn@, millert@


# 1.9 26-Jan-2004 espie

add finalized guard to destructor calls, to prevent multiple calls.
stop most kde apps from burping all over the place on exit, which
means that, somehow, our destructors get registered twice... :-(

Okay drahn@


# 1.8 26-Jan-2004 espie

small clean-up: typedef to desambiguate const, prototypes...

ok drahn@, some time ago.


# 1.7 08-Jan-2004 drahn

__init/__fini handling on ELF has not been correct. It is supposed to
be a section which code stubs (branches) can be added to initialize/destructor
This adds MD stubs to allow this to operate as expected. should fix wine
and behave according to ELF specs. ok miod@


# 1.6 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.5 03-Feb-2001 art

oops.


# 1.4 03-Feb-2001 art

Schedule running of __fini in __init, not __start.


# 1.3 03-Feb-2001 art

Add an OS note identifying OpenBSD binaries.
This appears to be the standard way to do it.


# 1.2 03-Feb-2001 art

Decruftification.


# 1.1 03-Feb-2001 art

Create a common_elf directory with crtbegin and crtend that can
be shared between archs.


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE
# 1.24 19-Feb-2017 guenther

Move static variables from .data to .bss by not initializing them to zero

ok kettenis@


# 1.23 21-Jan-2017 guenther

Make crtbegin.c and crtbeginS.c consistent on stylistic points

ok kettenis@


# 1.22 21-Jan-2017 guenther

Declare the symbols that label the .ctors, .dtors, .eh_frame, and .jcr
sections as extern hidden arrays of indefinite size, so that the compiler
(well, clang) doesn't believe it knows the exact contents and thus optimize
things into infinite loops. Actually set the symbols to be in the sections
and insert the leading and trailing values via __asm().

Problem pointed out by patrick@
testing and ok kettenis@


# 1.21 22-Dec-2016 kettenis

Don't make __CTOR_LIST__ and __DTOR_LIST__ const. This makes the .ctors and
.dtors sections writable just like they are in crtend.o and code generated
by compilers. This is necessary to make sure that linkers that respect the
ELF spec a bit better (such as lld) correctly concatenate the secttions.

ok deraadt@


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE
# 1.20 10-Nov-2015 guenther

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@


Revision tags: OPENBSD_5_8_BASE
# 1.19 07-Apr-2015 guenther

Make pthread_atfork() track the DSO that called it like atexit() does,
unregistering callbacks if the DSO is unloaded. Move the callback
handling from libpthread to libc, though libpthread still overrides the
inner call to handle locking and thread-library reinitialization.
Major version bump for both libc and libpthread.

verification that this fixes various ports ajacoutot@
asm assistance miod@; ok millert@ deraadt@


# 1.18 04-Apr-2015 guenther

gcc 2.x is dead

ok millert@


Revision tags: OPENBSD_5_7_BASE
# 1.17 28-Dec-2013 kettenis

Move atexit(3) into crtbegin.c and certbeginS.c such that we can pass the
right __dso_handle and have dlopen'ed shared objects run their atexit handlers
when they get unloaded. This is what Linux does, and several ports depend on
this behaviour (and will crash upon exit without this chang).

Based on an earlier diff from matthew@
Tested by ajacoutot@
ok deraadt@


# 1.16 08-Sep-2012 matthew

Reverse the order that ctors and dtors are run in accordance with
GCC's documentation. Fixes GNU C++'s init_priority attribute.

ok miod


# 1.15 28-Aug-2012 matthew

Add __guard_local as a hidden symbol to ld.so, kernel, and every
executable and DSO (via crtbegin.c/crtbeginS.c). Not used yet, but
needed before GCC can start emitting -fstack-protector code that uses
them instead of __guard.


# 1.14 01-May-2010 kettenis

Sprinkle a few __used markers to prevent gcc4 from throwing away essential
bits of code and data. With this change gcc4 builds usable crt*.o on sparc64,
other architectures probably need some more love.

ok marco@, jsg@


# 1.13 13-Apr-2009 kurt

Add gcj java class registration hooks for gcc3 elf archs. From NetBSD
with minor differences.

okay kettenis@ drahn@


# 1.12 03-Sep-2007 millert

Add __cxa_atexit() support for gcc3. This provides support for shared object destructors called at dlclose() time. Inspired by similar changes in FreeBSD and NetBSD.


# 1.11 26-Oct-2004 kettenis

Change __register_frame_info into a weakly defined symbol.
ok drahn@, pval@, deraadt@


# 1.10 10-Oct-2004 kettenis

Add support for DWARF2 exception handling.
ok drahn@, millert@


# 1.9 26-Jan-2004 espie

add finalized guard to destructor calls, to prevent multiple calls.
stop most kde apps from burping all over the place on exit, which
means that, somehow, our destructors get registered twice... :-(

Okay drahn@


# 1.8 26-Jan-2004 espie

small clean-up: typedef to desambiguate const, prototypes...

ok drahn@, some time ago.


# 1.7 08-Jan-2004 drahn

__init/__fini handling on ELF has not been correct. It is supposed to
be a section which code stubs (branches) can be added to initialize/destructor
This adds MD stubs to allow this to operate as expected. should fix wine
and behave according to ELF specs. ok miod@


# 1.6 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.5 03-Feb-2001 art

oops.


# 1.4 03-Feb-2001 art

Schedule running of __fini in __init, not __start.


# 1.3 03-Feb-2001 art

Add an OS note identifying OpenBSD binaries.
This appears to be the standard way to do it.


# 1.2 03-Feb-2001 art

Decruftification.


# 1.1 03-Feb-2001 art

Create a common_elf directory with crtbegin and crtend that can
be shared between archs.