summaryrefslogtreecommitdiffstats
path: root/winsup/cygwin/dll_init.h
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2011-05-28 20:17:09 +0000
committerChristopher Faylor <me@cgf.cx>2011-05-28 20:17:09 +0000
commita92339ab635febf6ce9873fecca6f3d113dbb3b5 (patch)
treed0fba808521f5ad5806afdaa0f1660a2407e6768 /winsup/cygwin/dll_init.h
parent855108782321cee83378b069fe89343f191ba28c (diff)
downloadcygnal-a92339ab635febf6ce9873fecca6f3d113dbb3b5.tar.gz
cygnal-a92339ab635febf6ce9873fecca6f3d113dbb3b5.tar.bz2
cygnal-a92339ab635febf6ce9873fecca6f3d113dbb3b5.zip
* dll_init.cc (dll_list::find_by_modname): New function to search the dll list
for a module name only (no path). (dll_list::alloc): Initialize newly-added members of struct dll. (dll_list::append): New function to factor out the append operation (used by dll_list::topsort). (dll_list::populate_deps): New function to identify dll dependencies. (dll_list::topsort): New function to sort the dll list topologically by dependencies. (dll_list::topsort_visit): New helper function for the above. * dll_init.h (dll::ndeps): New class member. (dll::deps): Ditto. (dll::modname): Ditto. (dll_list::find_by_modname): New function related to topsort. (dll_list::populate_all_deps): Ditto. (dll_list::populate_deps): Ditto. (dll_list::topsort): Ditto. (dll_list::topsort_visit): Ditto. (dll_list::append): Ditto. (pefile): New struct allowing simple introspection of dll images. * fork.cc (fork): Topologically sort the dll list before forking.
Diffstat (limited to 'winsup/cygwin/dll_init.h')
-rw-r--r--winsup/cygwin/dll_init.h29
1 files changed, 29 insertions, 0 deletions
diff --git a/winsup/cygwin/dll_init.h b/winsup/cygwin/dll_init.h
index d14cc6cb9..3a9a5c4f0 100644
--- a/winsup/cygwin/dll_init.h
+++ b/winsup/cygwin/dll_init.h
@@ -52,6 +52,9 @@ struct dll
int count;
bool has_dtors;
dll_type type;
+ long ndeps;
+ dll** deps;
+ PWCHAR modname;
WCHAR name[1];
void detach ();
int init ();
@@ -84,6 +87,13 @@ public:
void detach (void *);
void init ();
void load_after_fork (HANDLE);
+ dll *find_by_modname (const PWCHAR name);
+ void populate_all_deps ();
+ void populate_deps (dll* d);
+ void topsort ();
+ void topsort_visit (dll* d, bool goto_tail);
+ void append (dll* d);
+
dll *inext ()
{
while ((hold = hold->next))
@@ -109,6 +119,25 @@ public:
dll_list () { protect.init ("dll_list"); }
};
+/* References:
+ http://msdn.microsoft.com/en-us/windows/hardware/gg463125
+ http://msdn.microsoft.com/en-us/library/ms809762.aspx
+*/
+/* FIXME: Integrate with other similar uses in source. */
+struct pefile
+{
+ IMAGE_DOS_HEADER dos_hdr;
+
+ char* rva (long offset) { return (char*) this + offset; }
+ PIMAGE_NT_HEADERS32 pe_hdr () { return (PIMAGE_NT_HEADERS32) rva (dos_hdr.e_lfanew); }
+ PIMAGE_OPTIONAL_HEADER32 optional_hdr () { return &pe_hdr ()->OptionalHeader; }
+ PIMAGE_DATA_DIRECTORY idata_dir (DWORD which)
+ {
+ PIMAGE_OPTIONAL_HEADER32 oh = optional_hdr ();
+ return (which < oh->NumberOfRvaAndSizes)? oh->DataDirectory + which : 0;
+ }
+};
+
extern dll_list dlls;
void dll_global_dtors ();