tinycc-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Tinycc-devel] tccpe.c / resolve_sym() leaks LoadLibrary() handles


From: egodust
Subject: Re: [Tinycc-devel] tccpe.c / resolve_sym() leaks LoadLibrary() handles
Date: Mon, 28 Apr 2008 18:48:42 +0100

Also,

I think most people just use the tcc_run(), so it doesn't matter that
LoadLibrary() is called incorrectly..

The way that importing/DLL usage on Win32 works with TCC is very
limited at the moment anyway, if you want to use other DLLs you have
to use LoadLibrary() from the TCC code, there seems no way to
magically add exports at runtime for code to use.. unless you write
out the DEF files before code compiles?

:\

On Mon, Apr 28, 2008 at 6:27 PM, grischka <address@hidden> wrote:
> Can't you just store the DLL-handle into the DLLReference structure?
>
>  --- grischka
>
>  From: "egodust"
>
>
> > Heyas,
>  >
>  > When a compiled TCC binary image is memory linked, resolve_sym() is
>  > given the symbol to find, it looks
>  > for the assocated DLL (using DEF file info) and calls LoadLibrary(),
>  > using GetProcAddress() to get the function
>  > pointer.
>  >
>  > This is problematic:
>  >
>  > 1. LoadLibrary() is called, per symbol, if multiple symbols from the
>  > same DLL are used, LoadLibrary() is called
>  >     per symbol.
>  >
>  > 2. LoadLibrary() is referenced counted and might overflow for many symbols
>  >
>  > 3. FreeLibrary() is never called, which means the DLLs are not freed,
>  > until process shutdown
>  >
>  > Imagine an application has loaded a custom dll (foo.dll) which TCC
>  > also LoadLibrary()s, the app then FreeLibrary()'s
>  >     at some point, but resolve_sym() has messed with the refcnt so the
>  > DLL can't be unloaded until exit(0)
>  >
>  > -
>  >
>  > resolve_sym() should defer loading libraries to another function which
>  > keeps track of the DLLs that have
>  > been LoadLibrary()'d, so that tcc_delete() can free them, it also
>  > means that LoadLibrary() is only called
>  > once per DLL when it needs to be mapped, and other symbols in the same
>  > DLL use the same handle with
>  > GetProcAddress()?
>  >
>  > Kind Regards,
>  > Sam
>  >
>  >
>  > _______________________________________________
>  > Tinycc-devel mailing list
>  > address@hidden
>  > http://lists.nongnu.org/mailman/listinfo/tinycc-devel
>
>
>  _______________________________________________
>  Tinycc-devel mailing list
>  address@hidden
>  http://lists.nongnu.org/mailman/listinfo/tinycc-devel
>




reply via email to

[Prev in Thread] Current Thread [Next in Thread]