rtld: Add support for preinit, init, and fini arrays
As far as I can tell, all BSDs limit their ELF executable file
initialization and termination to the .init and .fini sections. In
contrast, Linux has additionally supported the .preinit_array,
.init_array, and .fini_array sections for over a decade through glibc.
With this commit, DragonFly becomes the first BSD to support these
arrays of function pointers. It was tested using test cases taken from
glibc, gnu ld linker, and the gold linker.
For the main executable file, the .init_array and .fini_array sections
are handled by crt1, just like .init and .fini are. In the case of
a statically linked binary, the .preinit_array section is also handled
by crt1. The real-time linker handles the .init_array and .fini_array
sections for dynamically shared objects (libraries) and .preinit_array
for dynamically-linked binaries. There are no .preinit_array sections
in the DSOs per standard.
These sections are described by the System V Application Binary Interface
http://www.sco.com/developers/gabi/latest/ch4.sheader.html#special_sections
The .init_array and .fini_array handling by rtld was reviewed by
Konstantin Belousov.