Subject: Cleaning up more ld.elf_so cruft
To: None <tech-userlevel@netbsd.org>
From: Charles M. Hannum <abuse@spamalicious.com>
List: tech-userlevel
Date: 10/02/2002 20:10:20
So, the startup interface between ld.elf_so and executables is a
complete crock.
1) In order to allow init functions in shared libraries to make
reference to the environment, __progname, et al, we currently have
ld.elf_so inspect the executable's symbol table to find these items
and patch them. Among other things, this violates the separation
between ld.elf_so and the executable's execution environment. It
is not acceptable.
2) We pass a pointer to an INTERNAL DATA STRUCTURE in ld.elf_so back
to the executable, to be used by the dl*(3) functions to fetch
function pointers.
What I propose is this:
a) Replace the Obj_Entry pointer used for __mainprog_obj with a
pointer to a fictitious data structure which contains pointers to
the dl*(3) entry points, _rtld_exit(), and a new function (herein
temporarily called _rtld_do_init()).
b) Rather than running the init functions immediately, control is
instead passed to the executable, which uses the function pointer
to call _rtld_do_init(), after setting up __progname, __ps_strings,
environ, etc.
c) Therefore, the above-mentioned symbols will not be hacked by
ld.elf_so.
d) The `cleanup' function pointer will no longer be passed or used by
crt0, and will instead be taken from the structure mentioned in
part a.
e) To enable ld.elf_so to transparently detect new executables and
switch modes of operation, and to prevent chicken-and-egg problems,
the version number for the .note.netbsd.ident tag (in
ld.elf_so/sysident.h) will for a time be set to a static value. It
may be permanently left as a static value in sysident.h, but I'm
not certain of that yet.
f) Compatibility code in ld.elf_so will be present under `#ifdef
COMPAT_16', which will be enabled by default.
This will happen next Wednesday unless someone sways me with a sound
technical reason to not do it.