* dll_init.cc (dll_list::detach): Eliminate reliance on passed in dll address.

Infer from module of caller instead.
(cygwin_detach_dll): Ignore dll_index argument.
* dll_init.h (dll_list::detach): Reflect argument change above.
This commit is contained in:
Christopher Faylor 2002-11-14 04:29:39 +00:00
parent a2dea5c333
commit 052990e6b3
3 changed files with 34 additions and 18 deletions

View File

@ -1,3 +1,10 @@
2002-11-13 Christopher Faylor <cgf@redhat.com>
* dll_init.cc (dll_list::detach): Eliminate reliance on passed in dll
address. Infer from module of caller instead.
(cygwin_detach_dll): Ignore dll_index argument.
* dll_init.h (dll_list::detach): Reflect argument change above.
2002-11-13 Christopher Faylor <cgf@redhat.com> 2002-11-13 Christopher Faylor <cgf@redhat.com>
* ioctl.cc (ioctl): Always print ioctl results, even when it's a tty. * ioctl.cc (ioctl): Always print ioctl results, even when it's a tty.

View File

@ -182,12 +182,20 @@ dll_list::alloc (HINSTANCE h, per_process *p, dll_type type)
/* Detach a DLL from the chain. */ /* Detach a DLL from the chain. */
void void
dll_list::detach (dll *d) dll_list::detach (void *retaddr)
{ {
if (!myself || myself->process_state == PID_EXITED) if (!myself || myself->process_state == PID_EXITED)
return; return;
MEMORY_BASIC_INFORMATION m;
if (!VirtualQuery (retaddr, &m, sizeof m))
return;
HMODULE h = (HMODULE) m.AllocationBase;
if (d->count <= 0) dll *d = &start;
while ((d = d->next))
if (d->handle != h)
continue;
else if (d->count <= 0)
system_printf ("WARNING: try to detach an already detached dll ..."); system_printf ("WARNING: try to detach an already detached dll ...");
else if (--d->count == 0) else if (--d->count == 0)
{ {
@ -200,6 +208,7 @@ dll_list::detach (dll *d)
if (end == d) if (end == d)
end = d->prev; end = d->prev;
VirtualFree (d, 0, MEM_RELEASE); VirtualFree (d, 0, MEM_RELEASE);
break;
} }
} }
@ -390,9 +399,9 @@ dll_noncygwin_dllcrt0 (HMODULE h, per_process *p)
} }
extern "C" void extern "C" void
cygwin_detach_dll (dll *d) cygwin_detach_dll (dll *)
{ {
dlls.detach (d); dlls.detach (__builtin_return_address (0));
} }
extern "C" void extern "C" void

View File

@ -70,7 +70,7 @@ public:
int reload_on_fork; int reload_on_fork;
dll *operator [] (const char *name); dll *operator [] (const char *name);
dll *alloc (HINSTANCE, per_process *, dll_type); dll *alloc (HINSTANCE, per_process *, dll_type);
void detach (dll *); void detach (void *);
void init (); void init ();
void load_after_fork (HANDLE, dll *); void load_after_fork (HANDLE, dll *);
dll *inext () dll *inext ()