Home | History | Annotate | Download | only in common
History log of /src/lib/csu/common/crt0-common.c
RevisionDateAuthorComments
 1.30  02-May-2025  riastradh lib/csu: Add support for RELR relocations in static PIEs.

Same logic as in ld.elf_so, but baked into the executable itself for
static PIEs.

Addendum to proposal on tech-userlevel:
https://mail-index.NetBSD.org/tech-userlevel/2025/04/27/msg014727.html

PR bin/59360: ld.elf_so(8): missing RELR support
 1.29  22-Mar-2025  christos PR/59189: RVP: move atexit(cleanup) after _preinit() to allow sanitizer
initialization during preinit as well as atexit interception.
 1.28  19-Jan-2024  christos declare _libc_init() in header.
 1.27  21-Jun-2022  skrll Support ifunc on aarch64. The tests pass at least.
 1.26  21-Jun-2022  skrll Wrap long #if defined(...) || ... and sort. NFCI.
 1.25  21-Jun-2022  skrll Trailing whitespace
 1.24  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.23  28-Dec-2018  christos Re-do previous (always make available preinit/initarray/finiarray), with
less disruption.
 1.22  28-Dec-2018  christos Undo previous; breaks macppc/m68k (at least)
 1.21  27-Dec-2018  christos Allow both array and non-array constructors for transition.
 1.20  26-Nov-2018  joerg Do not pass the main object handle from the assembler startup stub to
the common ___start routine. It's only used for a pointless magic
version check. Thanks to martin@ for testing various architectures.
 1.19  13-Jul-2018  kre i386/amd64 build fix. Fix "possibly used uninitialized" from gcc.
These changes should make no practical effect - but because external
data is being examined, it would be possible to contrive a situation
(perhaps) where uninit'd vars could actually be used (unless the format
has been checked elsewhere earlier - I did not look ... we have to
appease gcc anyway).

Joerg: Please review (& fix)
 1.18  12-Jul-2018  joerg Add static PIE support for i386 and AMD64.

The basic glue works with mininal changes for other architectures as
well, but those require linker changes first to avoid leaking dynamic
relocations into the binary.
 1.17  12-Jul-2018  joerg _DYNAMIC is present for static PIE as well, so loosen rtld check.
 1.16  29-Mar-2018  joerg branches: 1.16.2;
Move the complex logic for dynamically writing branches from ld.elf_so
into a header for reuse in crt0.o for static ifunc support. Change the
existing logic for sparc64 to use the Bicc variant of ba,a as it allows
+-8MB displacement compared to the BPcc variant's +-1MB. Teach the sparc
variant the same trick for using ba,a and not sethi+jmp when possible.
 1.15  09-Mar-2018  joerg Add ifunc support for statically linked applications on x86, ppc, sparc
and ARM.
 1.14  07-Jun-2016  joerg branches: 1.14.14;
Fun fact of the weak: a weak reference doesn't have visibility attached.
As such, reorganize the start/end references to use a weak reference
only, if we use it to remove size knowledge. Otherwise use weak
external declarations.
 1.13  31-Jan-2013  matt Add support for PREINIT_ARRAY
 1.12  28-Jan-2013  matt Use __weakref_visible (from joerg@)
 1.11  28-Jan-2013  matt Make with work with gcc 4.5 or clang.
 1.10  22-Jan-2013  matt Fix static weak (to extern weak)
 1.9  13-Aug-2012  matt branches: 1.9.2;
Add support for init_array/fini_array (conditionalized on HAVE_INITFINI_ARRAY).
[This is needed for ARM EABI.]
 1.8  22-Mar-2012  joerg Add some more __dead as exposed by the recent WARN bumps.
 1.7  30-Jun-2011  matt branches: 1.7.2; 1.7.6;
Mark ___start as .hidden (for MKPIE=yes executables).
 1.6  30-Jun-2011  joerg Assert that ps_strings is valid. Use it to drop the first three
arguments to ___start to make the assembler callers simpler.
 1.5  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.4  22-Feb-2011  joerg Introduce __weakref_visible to handle the different required visibility
for weak references. GCC 4.2+ and Clang require static, older GCC wants
extern. Change __weak_reference to include sym. This requires changes
the existing users to not reuse the name of the symbol, but avoids
further differences between GCC 4.1 and GCC 4.2+/clang.
 1.3  18-Feb-2011  joerg Allow building with the changed weakref semantic in GCC 4.2 and clang.
 1.2  08-Feb-2011  matt Distinguish between a corrupt obj pointer and a null obj pointer.
 1.1  07-Aug-2010  joerg branches: 1.1.2;
Switch i386 and x86_64 to the new CRT layout. The crt0.c body is shared
between all platforms and a small assembler stub in crt0.S is used for
setting up the proper stack and whatever else MD needs.

Extract crti.S and crtn. from the old dot_init.h files. Prepare other
platforms that use the 6-argument form of __(_)start for this.

Rewrite the crtbegin and crtend modules in assembler to make them
compiler independent. Document the interface in README.
 1.1.2.2  05-Mar-2011  bouyer Sync with HEAD
 1.1.2.1  08-Feb-2011  bouyer Sync with HEAD
 1.7.6.2  28-Jan-2013  matt Use __weakref_visible
 1.7.6.1  22-Jan-2013  matt Pullup from HEAD:
Add support for init_array/fini_array (conditionalized on HAVE_INITFINI_ARRAY).
[This is needed for ARM EABI.]
 1.7.2.3  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.7.2.2  30-Oct-2012  yamt sync with head
 1.7.2.1  17-Apr-2012  yamt sync with head
 1.9.2.1  25-Feb-2013  tls resync with head
 1.14.14.5  18-Jan-2019  pgoyette Synch with HEAD
 1.14.14.4  26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.14.14.3  28-Jul-2018  pgoyette Sync with HEAD
 1.14.14.2  30-Mar-2018  pgoyette Resolve conflicts between branch and HEAD
 1.14.14.1  15-Mar-2018  pgoyette Synch with HEAD
 1.16.2.1  10-Jun-2019  christos Sync with HEAD

RSS XML Feed