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.
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.
things like the .note.netbsd.ident section are provided by crti/crtn.
crti/crtn also provide the _init() and _fini() routines.
crtbegin/crtend now only provide support for ctors/dtors. This paves
the way to using the "crtstuff" provided with GCC (when we upgrade to
GCC 3.3), which provides, among other things, much better C++/Java
exception handling.
o Primary mod: alpha and i386 code for .init and .fini section fallthroughs
o Actual fallthru is not yet enabled, see csu/{alpha,i386_elf}/Makefile
o When enabled, should fix bin/12865 & should fix at least one WINE bug,
see http://www.winehq.com/hypermail/wine-devel/2001/05/0021.html
o Also, removed the function pointer hack put in to prevent gcc from
incorrectly attempting to do short calls over section boundaries,
on some architectures, rather, simply simply move ctors() and dtors()
into .init and .fini.
Other notes.
o Our crtbegin.c and crtend.c were completely in C, despite
the fact that .init and .fini section fallthroughs require machine code.
These modules implement the gnu ctors/dtors mechanism directly, eliminating
in part the need for the elf .init/.fini section fallthrough. However,
if we ever want to use the gnu-provided constructor support, we need to
do the fallthrough, at least one program (WINE) apparently uses the
feature independently, and other compilers may depend on the mechanism.
o It is amusing that the previous NetBSD _init() and _fini() were put
into the .init and .fini sections, because nothing is gained over
plain .text if they don't fall through. Cargo cult!
o Other elf ports will need to copy the alpha and i386 example mods.
use it across the board.
crt0.c now contains stuff that REALLY IS machine-dependent, or stuff that
is completely intermingled in machdep code (and thus can't be separated
easily).
constructor/destructor dispatcher via a function pointer protected from
constant propagation. Also, create (presently unused) .S files that solve
the same problem and in addition allow in-line .init section and .fini
section code. This is too big a mod for a 3.2 pullup, however.
* use COPTS instead of CFLAGS for -fPIC et al
* use ${COMPILE.c} instead of ${CC} ${CFLAGS} -c
* use FILES and FILESDIR to install pc532 objects (instead of install: rule) -
this makes it consistent with the other a.out ports (arm32, i386, m68k, sparc)
and libs in the object tree, if you use a separate object tree,
while maintaining backward compatability with other build methods.
See the notes in src/share/mk/bsd.README for full details. Note
that the `make includes' target now only installs the include files
in the build directory (if you use one--otherwise they go in DESTDIR
just like before); `make install' will install include files in
DESTDIR.