git: rtld: Add support for preinit, init, and fini arrays
John Marino
marino at crater.dragonflybsd.org
Sat Feb 11 12:04:28 PST 2012
commit b28bf640312db2b299faff75052fbb01d67fd821
Author: John Marino <draco at marino.st>
Date: Sat Feb 11 20:17:51 2012 +0100
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.
Summary of changes:
lib/csu/i386/crt1_c.c | 30 +++++++
lib/csu/x86_64/crt1.c | 30 +++++++
libexec/rtld-elf/i386/rtld_machdep.h | 3 +
libexec/rtld-elf/rtld.c | 133 +++++++++++++++++++++++++++++---
libexec/rtld-elf/rtld.h | 7 ++
libexec/rtld-elf/x86_64/rtld_machdep.h | 3 +
6 files changed, 194 insertions(+), 12 deletions(-)
http://gitweb.dragonflybsd.org/dragonfly.git/commitdiff/b28bf640312db2b299faff75052fbb01d67fd821
--
DragonFly BSD source repository
More information about the Commits
mailing list