freebsd-skq/libexec/rtld-elf
Konstantin Belousov 83aa9cc00c Add support for preinit, init and fini arrays. Some ABIs, in
particular on ARM, do require working init arrays.

Traditional FreeBSD crt1 calls _init and _fini of the binary, instead
of allowing runtime linker to arrange the calls.  This was probably
done to have the same crt code serve both statically and dynamically
linked binaries.  Since ABI mandates that first is called preinit
array functions, then init, and then init array functions, the init
have to be called from rtld now.

To provide binary compatibility to old FreeBSD crt1, which calls _init
itself, rtld only calls intializers and finalizers for main binary if
binary has a note indicating that new crt was used for linking.  Add
parsing of ELF notes to rtld, and cache p_osrel value since we parsed
it anyway.

The patch is inspired by init_array support for DragonflyBSD, written
by John Marino.

Reviewed by:	kan
Tested by:	andrew (arm, previous version), flo (sparc64, previous version)
MFC after:	3 weeks
2012-03-11 20:03:09 +00:00
..
amd64 Add support for preinit, init and fini arrays. Some ABIs, in 2012-03-11 20:03:09 +00:00
arm Add support for preinit, init and fini arrays. Some ABIs, in 2012-03-11 20:03:09 +00:00
i386 Add support for preinit, init and fini arrays. Some ABIs, in 2012-03-11 20:03:09 +00:00
ia64 Add support for preinit, init and fini arrays. Some ABIs, in 2012-03-11 20:03:09 +00:00
mips Add support for preinit, init and fini arrays. Some ABIs, in 2012-03-11 20:03:09 +00:00
powerpc Add support for preinit, init and fini arrays. Some ABIs, in 2012-03-11 20:03:09 +00:00
powerpc64 Add support for preinit, init and fini arrays. Some ABIs, in 2012-03-11 20:03:09 +00:00
sparc64 Add support for preinit, init and fini arrays. Some ABIs, in 2012-03-11 20:03:09 +00:00
debug.c Rtld links with the specially built pic static libc library to get some 2011-08-24 20:05:13 +00:00
debug.h
libmap.c Cosmetic nit: 2012-03-06 09:34:30 +00:00
libmap.h
Makefile Add support for preinit, init and fini arrays. Some ABIs, in 2012-03-11 20:03:09 +00:00
malloc.c Rtld links with the specially built pic static libc library to get some 2011-08-24 20:05:13 +00:00
map_object.c Add support for preinit, init and fini arrays. Some ABIs, in 2012-03-11 20:03:09 +00:00
rtld_lock.c Rtld links with the specially built pic static libc library to get some 2011-08-24 20:05:13 +00:00
rtld_lock.h Implement support for ELF filters in rtld. Both normal and auxillary 2010-12-25 08:51:20 +00:00
rtld_printf.c Remove the use of toupper() from rtld_printf.c. Use of the libc function 2012-03-09 16:21:40 +00:00
rtld_printf.h Rtld links with the specially built pic static libc library to get some 2011-08-24 20:05:13 +00:00
rtld_tls.h
rtld.1 Implement support for ELF filters in rtld. Both normal and auxillary 2010-12-25 08:51:20 +00:00
rtld.c Add support for preinit, init and fini arrays. Some ABIs, in 2012-03-11 20:03:09 +00:00
rtld.h Add support for preinit, init and fini arrays. Some ABIs, in 2012-03-11 20:03:09 +00:00
Symbol.map Implement fdlopen(3), an rtld interface to load shared object by file 2012-01-07 10:33:01 +00:00
xmalloc.c Rtld links with the specially built pic static libc library to get some 2011-08-24 20:05:13 +00:00