diff options
author | jdp <jdp@FreeBSD.org> | 2000-07-26 04:24:40 +0000 |
---|---|---|
committer | jdp <jdp@FreeBSD.org> | 2000-07-26 04:24:40 +0000 |
commit | d9182b54c97cee64b9a529f7d4b2a2edcb4b7d42 (patch) | |
tree | 66c01b2ede6bbd3d771f195d218bcea5e7196f24 /libexec/rtld-elf/rtld.h | |
parent | d2ae8075f6713abaac375072d77376110b146400 (diff) | |
download | FreeBSD-src-d9182b54c97cee64b9a529f7d4b2a2edcb4b7d42.zip FreeBSD-src-d9182b54c97cee64b9a529f7d4b2a2edcb4b7d42.tar.gz |
Revamp the code that calls shared libraries' init and fini functions.
Formerly the init functions were called in the opposite of the
order in which libraries were loaded, and libraries were loaded
according to a breadth-first traversal of the dependency graph.
That ordering came from SVR4.0, and it was easy to implement but
not always sensible.
Now we do a depth-first walk over the dependency graph and call
the init functions in an order such that each shared object's needed
objects are initialized before the shared object itself. At the
same time we build a list of finalization (fini) functions in the
opposite order, to guarantee correct C++ destructor ordering whenever
possible. (It may not be possible if dlopen and dlclose are used
in strange ways, but we come as close as one can come.)
The need for this renovation has become apparent as more programs
have started using multithreading. The multithreaded C library
libc_r requires initialization, whereas the standard libc does not.
Since virtually every other object depends on the C library, it is
important that it get initialized first.
Diffstat (limited to 'libexec/rtld-elf/rtld.h')
-rw-r--r-- | libexec/rtld-elf/rtld.h | 10 |
1 files changed, 2 insertions, 8 deletions
diff --git a/libexec/rtld-elf/rtld.h b/libexec/rtld-elf/rtld.h index ab00437..86d8181 100644 --- a/libexec/rtld-elf/rtld.h +++ b/libexec/rtld-elf/rtld.h @@ -60,16 +60,9 @@ typedef struct Struct_Objlist_Entry { typedef STAILQ_HEAD(Struct_Objlist, Struct_Objlist_Entry) Objlist; -/* Lists of init or fini functions */ +/* Types of init and fini functions */ typedef void (*InitFunc)(void); -typedef struct Struct_Funclist_Entry { - STAILQ_ENTRY(Struct_Funclist_Entry) link; - InitFunc func; -} Funclist_Entry; - -typedef STAILQ_HEAD(Struct_Funclist, Struct_Funclist_Entry) Funclist; - /* Lists of shared object dependencies */ typedef struct Struct_Needed_Entry { struct Struct_Needed_Entry *next; @@ -160,6 +153,7 @@ typedef struct Struct_Obj_Entry { bool symbolic; /* True if generated with "-Bsymbolic" */ bool traced; /* Already printed in ldd trace output */ bool jmpslots_done; /* Already have relocated the jump slots */ + bool init_done; /* Already have added object to init list */ struct link_map linkmap; /* for GDB */ Objlist dldags; /* Object belongs to these dlopened DAGs (%) */ |