Home | History | Annotate | only in /src/lib/csu/common
History log of /src/lib/csu/common
RevisionDateAuthorComments
 1.35 28-Dec-2018  christos Undo previous; breaks macppc/m68k (at least)
 1.34 27-Dec-2018  christos Enable initfini array support for everyone.
 1.33 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.32 01-Jun-2016  joerg branches: 1.32.14; 1.32.16;
Revert -O1 hack for GCC 5.3, replaced by workaround in the code.
 1.31 10-May-2016  martin We need the -O1 hack (for gcc 5.3) for crtbegin.c as well.
Works around PR toolchain/51121.
 1.30 01-May-2016  martin Revert previous (fallout is more subtle but there).
Rework the conditionon so it depends on .S existence instead of an arch
list.
 1.29 30-Apr-2016  martin Gcc 5.3 seems to do fine compiling this for sparc64, so exclude it
from the -O1 hack
 1.28 04-Apr-2016  martin For the benefit of compilers not using our native C runtime environment,
install a "sysident.o" file providing the note identifying NetBSD
executables (and marking the currently installed version).
 1.27 29-Mar-2016  skrll crt0-common.c is miscompiled by gcc 5.3 on evbarm with -O2 so use -O1. Do
this for all non-x86 arches.
 1.26 27-Mar-2016  mrg add a hack for GCC 5 and non-x86 platforms:

build crtbeginS.o with -O1 as GCC tries to be very smart with the
__DTOR_LIST__ as it believes it knows the size of the array at
compile time (which is not true until link time). on SPARC and
MIPS, the result was emitting a call to 0.

technically, i believe that GCC isn't "wrong" to make this choice,
as the array is declared with a well-known initialiser size in the
crtbegin.c compilation unit, and we have noticed that the libgcc
version of this code has some hacks added, most likely to avoid
being bitten by this optimisation.


this makes sshd work for me on earm and sparc with GCC 5.
 1.25 04-Mar-2014  joerg Add GENASSYM_CPPFLAGS in two more places.
 1.24 11-Jan-2014  matt Using ${LD} -x screws up BE arm. Use ${OBJCOPY} ${OBJCOPYLIBFLAGS} instead
so the $a/$t/$d symbols are preserved.
 1.23 17-Nov-2013  martin Simplify previous by using CSU_MACHINE_ARCH. Hint from Takeshi Nakayama.
 1.22 16-Nov-2013  martin We do not want to build the code model markes when creating the 32bit
compat libs for sparc64
 1.21 14-Nov-2013  martin On sparc64: create additional "marker" object files, that can be used by the
compiler to encode the used code model in binaries.
 1.20 11-Nov-2013  joerg Explicitly depend on sys/param.h to pick up __NetBSD_Version changes.
 1.19 18-Sep-2013  uwe Fix previous: use PICFLAGS for crtbeginS.o
Should unbreak sh3 builds.

XXX: PICFLAGS is defined in bsd.lib.mk which lib/csu does not use.
For now supply a local definition. joerg@, please fix appropriately.
 1.18 12-Sep-2013  joerg Pass PICFLAGS down to cc-as-as and use __PIC__ to decide if it is small
vs big PIC mode. Retire -DPIC and -DBIGPIC.
 1.17 10-Sep-2013  matt Add support for a NetBSD MARCH elf note to record the MACHINE_ARCH for
which a program was compiled.
 1.16 05-Aug-2013  matt Alpha needs crtfm.o for USE_COMPILERCRTSTUFF=no
 1.15 18-Jul-2013  matt Only supplie -fPIE to crtbegin.c if MKPIC is yes.
 1.14 17-Jul-2013  martin branches: 1.14.2;
Use -fPIE for crtbegin.o (instead of -fpie).
Fixes linking the firefox js shell. Ok: joerg@
 1.13 05-Jul-2013  joerg Only install crtbeginS.o, crtbeginT.o and crtendS.o when MKPIC=yes.
 1.12 27-Jun-2013  matt Switch arm, earm, powerpc to use crtbegin.c
Use -fpie for crtbegin.
 1.11 27-Jun-2013  matt Add -fPIC to compile of crtbeginS.o
 1.10 25-Jun-2013  matt Reorder to avoid !exists
Add a crtbegin.h dependency
 1.9 22-Jun-2013  matt Add a common crtbegin.c file and use a machine dependent crtbegin.h to
fill in .init/.fini.
Add mips support for USE_COMPILERCRTSTUFF=no (compiled only)
 1.8 22-Jun-2013  matt Allow crtbegin to be a C file.
 1.7 25-Mar-2012  joerg branches: 1.7.2;
Don't pass assembler flags to genassym, it doesn't compile.
 1.6 31-Jan-2012  uwe Move crt0.S in front of crt0-common.c when building crt0.o and gcrt0.o.
Reading disassembly is easier when the asm crt0.S trampoline is at the
start, not hidden behind the C code in crt0-common.c.
 1.5 31-Jan-2012  uwe Hmm, funny. I wonder why and how did emacs VC managed to add

Warning: Permanently added the RSA host key for IP address '...' to the list of known hosts.

to the committed file. (hi, new cvs!)
 1.4 31-Jan-2012  uwe Use -DPIC to compile crtbeginS.o since that's what <machine/asm.h>
headers check.
 1.3 31-Jan-2011  drochner branches: 1.3.4;
use of .PARSEDIR just doesn't work with .OBJDIR, replace with .CURDIR
 1.2 07-Dec-2010  joerg branches: 1.2.2;
Build assembler sources with assembler compile rules.
 1.1 07-Aug-2010  joerg 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.2.2.1 08-Feb-2011  bouyer Sync with HEAD
 1.3.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.3.4.1 17-Apr-2012  yamt sync with head
 1.7.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.14.2.1 23-Jul-2013  riastradh sync with HEAD
 1.32.16.1 10-Jun-2019  christos Sync with HEAD
 1.32.14.1 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.4 01-May-2016  martin Change section flags to "MG" and put it into comdat.
Makes new binutils happy.
 1.3 14-May-2014  joerg branches: 1.3.2; 1.3.6;
Ensure notes are properly padded to 32bit length.
 1.2 26-Feb-2014  martin branches: 1.2.2;
Make the .note section mergable and set proper "item" length.
XXX seems to be impossible to do that with gas w/o causing a (bogus)
warning - but the resulting object file is fine.
 1.1 14-Nov-2013  martin On sparc64: create additional "marker" object files, that can be used by the
compiler to encode the used code model in binaries.
 1.2.2.1 10-Aug-2014  tls Rebase.
 1.3.6.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.3.6.1 14-May-2014  tls file compident.S was added on branch tls-maxphys on 2014-08-20 00:02:07 +0000
 1.3.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.3.2.1 14-May-2014  yamt file compident.S was added on branch yamt-pagecache on 2014-05-22 11:36:44 +0000
 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 branches: 1.28.2;
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
 1.28.2.1 02-Aug-2025  perseant Sync with HEAD
 1.17 28-Dec-2018  christos Undo previous; breaks macppc/m68k (at least)
 1.16 28-Dec-2018  christos Avoid duplicate definitions on arm (reported by kre@)
 1.15 27-Dec-2018  christos Allow both array and non-array constructors for transition.
 1.14 18-Jul-2017  joerg branches: 1.14.4;
.eh_frame should be read-only on MIPS too.
 1.13 29-Jun-2016  joerg branches: 1.13.8;
For some mind-boogling reasons, GCC 5.4 believes that a weak reference
cannot alias with an extern. While this is clearly bogus, avoid yet
another alias handling bug and use strong aliases. It's actually
slightly simpler, too.
 1.12 07-Jun-2016  joerg 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.11 05-Jun-2016  joerg Make older GCC and Clang happy and use weak references to the elements,
not declared as arrays.
 1.10 01-Jun-2016  joerg PR toolchain/51121:
__CTOR_LIST__ and __CTOR_LIST_END__ are logically the same object, but
due to the start marker, the former has to be declared as array of fixed
size. Newer GCC versions take the liberty of exploiting the UB of
accessing global objects past the end to unconditionally load zero
values in that case. Two fixes are possible:
(1) Pruning via inline assembler as done by GCC's own CRT copy.
(2) Pruning via weak references as done for linker sets.
Since the second part is known and required to work anyway, prefer this
approach. In theory, the labels could be replaced completely, except
that GNU as doesn't provide start/end symbols for sections containing
dots.
 1.9 06-May-2014  joerg branches: 1.9.2; 1.9.6;
Make EHABI optional.
 1.8 29-Jan-2014  bouyer branches: 1.8.2;
Also make sure the __CTOR_LIST__ is just aligned to a pointer boundary.
By default, mips N32 will aligned to a 64-bit boundary not 32-bit
which causes an extra NULL entry to be added.
Fix "segfault on exit" several people have noticed on mips N32,
caused by a jr to a NULL address.
 1.7 11-Dec-2013  matt Make sure the __CTOR_LIST__ is just aligned to a pointer boundary.
By default, mips N32 will aligned to a 64-bit boundary not 32-bit
which causes an extra NULL entry to be added.
 1.6 29-Nov-2013  joerg Include crtbegin.h first to make it possible to build with the stricter
attribute consistency checks in clang.
 1.5 26-Aug-2013  matt MIPS wants a read/write eh_frame.
 1.4 19-Aug-2013  matt Put the ctors code in .text.startup and dtors code in .text.exit
 1.3 27-Jun-2013  matt Switch arm, earm, powerpc to use crtbegin.c
Use -fpie for crtbegin.
 1.2 24-Jun-2013  matt Make dwarf_eh_object is 8 words long
 1.1 22-Jun-2013  matt Add a common crtbegin.c file and use a machine dependent crtbegin.h to
fill in .init/.fini.
Add mips support for USE_COMPILERCRTSTUFF=no (compiled only)
 1.8.2.1 10-Aug-2014  tls Rebase.
 1.9.6.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.9.6.1 06-May-2014  tls file crtbegin.c was added on branch tls-maxphys on 2014-08-20 00:02:07 +0000
 1.9.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.9.2.1 06-May-2014  yamt file crtbegin.c was added on branch yamt-pagecache on 2014-05-22 11:36:44 +0000
 1.13.8.1 29-Aug-2017  bouyer Pull up following revision(s) (requested by joerg in ticket #240):
external/gpl3/binutils/dist/gas/config/tc-mips.h: revision 1.7
external/gpl3/gcc/dist/gcc/configure: revision 1.16
external/gpl3/gcc/dist/gcc/varasm.c: revision 1.2
external/gpl3/gcc/dist/gcc/varasm.c: revision 1.3
external/gpl3/gcc/dist/gcc/config/mips/netbsd.h: revision 1.10
lib/csu/arch/mips/crtend.S: revision 1.4
share/mk/bsd.own.mk: revision 1.1011
lib/csu/common/crtbegin.c: revision 1.14
external/gpl3/binutils/dist/bfd/elfxx-mips.c: revision 1.11
external/gpl3/gcc/dist/gcc/configure.ac: revision 1.14
external/gpl3/binutils/dist/bfd/elfxx-sparc.c: revision 1.12
external/gpl3/gcc/dist/gcc/config/arm/arm.h: revision 1.14
Create references as absolute pointers internally for .cfi*.
Do not warn for anonymous relocations in read-only .eh_frame,
they will be turned into relative entries afterwards.
A const declaration with explicit section attribute should create a
read-only section, whether it is initialized or not.
Use read-only .eh_frame.
Detect advance_loc support with readelf, not objdump. The latter is
broken in some situations before binutils 2.28.
.eh_frame should be read-only on MIPS too.
Build PIC libs on MIPS and PPC64. While the normal calling convention is
position-independent, real PIC defaults to Global Dynamic as TLS model,
while non-PIC and PIE code can use more restrictive models like Initial
Exec. This is most visible with the thread_local destructor code now
using TLS in libc as it would be clobbered by any other shared library
with TLS due to static offset assignment by ld.
Fix encoding of LSDA entries. .eh_frame references in non-PIC mode can
use plain pointers. For PIC, any references to global objects must be
indirect, but the .eh_frame entries themselve should be pcrel.
One more missing check for DECL_INITIAL being non-NULL.
TLS relocations for PIE and non-PIE main executable work the same, so
apply the same relaxation rules and the same static binding rules.
 1.14.4.1 10-Jun-2019  christos Sync with HEAD
 1.2 19-Jan-2024  christos declare _libc_init() in header.
 1.1 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.3 14-May-2014  joerg Ensure notes are properly padded to 32bit length.
 1.2 10-Sep-2013  matt branches: 1.2.2;
Add support for a NetBSD MARCH elf note to record the MACHINE_ARCH for
which a program was compiled.
 1.1 07-Aug-2010  joerg branches: 1.1.6; 1.1.12;
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.12.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.1.6.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.2.2.1 10-Aug-2014  tls Rebase.
 1.4 14-Nov-2013  martin On sparc64: create additional "marker" object files, that can be used by the
compiler to encode the used code model in binaries.
 1.3 10-Sep-2013  matt MARCH note is conditional
 1.2 10-Sep-2013  matt Add support for a NetBSD MARCH elf note to record the MACHINE_ARCH for
which a program was compiled.
 1.1 07-Aug-2010  joerg branches: 1.1.6; 1.1.12;
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.12.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.1.6.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")

RSS XML Feed