This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
RE: i386: Problems with references to import symbols.
- From: Danny Smith <dannysmith at clear dot net dot nz>
- To: 'Richard Henderson' <rth at redhat dot com>, 'Dave Korn' <dave dot korn at artimi dot com>
- Cc: 'Kai Tietz' <Kai dot Tietz at onevision dot com>, 'GCC Development' <gcc at gcc dot gnu dot org>
- Date: Thu, 22 Mar 2007 10:12:29 +1200
- Subject: RE: i386: Problems with references to import symbols.
Richard Henderson wrote
> On Wed, Mar 21, 2007 at 04:16:20PM -0000, Dave Korn wrote:
> > Presumably there would be no problem in just waiting
> until runtime to
> > initialise the my_malloc_hook variable dynamically instead
> of trying to
> > statically initialise it?
>
> Dunno. One could also wait to expand *__imp_foo, for functions,
> until expanding the function call. And then this variable would
> receive the address of the import library thunk.
>
> What does VC++ do? I'm mostly wondering about what pointer
> equality guarantees we can make.
>
>
For code like this
extern __declspec(dllimport) void foo();
void Bar() { return foo();}
void (* pfn_myfoo)(void) = foo;
void my_Bar() { return *pfn_myfoo();}
VC++6 uses the __imp__foo reference to resolve the call in Bar, but
an import lib thunk _foo to resolve pfn_myfoo and the call in my_Bar.
The mingw/cygwin workaround has been to add -mno-fun-dllimport to
command line to avoid the problem.
Danny
> r~
>