[email protected]
[Top] [All Lists]

Re: [PATCH, 2/4] Enable libstdc++ as a DLL on windows platforms.

Subject: Re: [PATCH, 2/4] Enable libstdc++ as a DLL on windows platforms.
From: Dave Korn
Date: Sat, 18 Jul 2009 22:45:28 +0100
Aaron W. LaFramboise wrote:

> The complaint I have always had against using ld -wrap for this sort of
> thing is that it takes this command away from the users, as least
> naively.  But this may not be a big deal.

  I'm not entirely enamoured of the solution myself, but I think it's the only
alternative short of implementing unresolved references in DLLs somehow.

> In any case, MinGW doesn't have the wrappers, and we shouldn't block
> this patch (or break i386-pc-mingw32) due to this, especially since this
> is really quite minor.  I would say go ahead with your original patch.

  Thanks.  Relative to static linking, you can expect to see two FAILs in
testcases that specifically test if this feature works:

FAIL: g++.old-deja/g++.abi/cxa_vec.C execution test
FAIL: g++.old-deja/g++.brendan/new3.C execution test

> Can you give some advice on exactly how to write the wrappers, and
> exactly how they work?  It would be good to have this documented
> somewhere, if only a paragraph or two on the GCC Wiki.

  For background, I posted a good deal of detail with the first draft of the
Cygwin support patch:


  The mile-high overview is:

1)  Use --wrap always when linking to redirect all references to ONDEE(*) to
the wrapper functions in the runtime.

2)  Have a static object in the CRT that gets linked into every exe and dll
that has a struct of function pointers using weak externals to the __real_*
names to pick up references to whichever of the replacement functions are
present at final-link time but not pull any in or complain if they aren't 

3)  At start up accumulate all the overrides into one final cumulative set,
starting with libstdc++'s and overriding them with any found in the structs in
the static CRT object instances linked into each dll and finally the exe.

4)  Wrapper functions then trivially jump through the pointers in the final
cumulative set.

  If you need any more help or advice feel free to drop me a note anytime.

(*) - operators new, delete, etc., etc.

<Prev in Thread] Current Thread [Next in Thread>