look for %s@%d format symbols when resolving native methods on Windows, which obviates the need for -k flag to dlltool

This commit is contained in:
Joel Dice 2008-10-10 17:37:36 -06:00
parent e3a5c7e03f
commit 5c04c19e29
3 changed files with 9 additions and 4 deletions

View File

@ -371,7 +371,7 @@ $(executable): \
@echo "linking $(@)" @echo "linking $(@)"
ifeq ($(platform),windows) ifeq ($(platform),windows)
$(dlltool) -z $(@).def $(^) $(dlltool) -z $(@).def $(^)
$(dlltool) -k -d $(@).def -e $(@).exp $(dlltool) -d $(@).def -e $(@).exp
$(cc) $(@).exp $(^) $(lflags) -o $(@) $(cc) $(@).exp $(^) $(lflags) -o $(@)
else else
$(cc) $(^) $(rdynamic) $(lflags) -o $(@) $(cc) $(^) $(rdynamic) $(lflags) -o $(@)

View File

@ -251,7 +251,7 @@ on Mac OS X:
on Windows: on Windows:
$ dlltool -z hello.def *.o $ dlltool -z hello.def *.o
$ dlltool -k -d hello.def -e hello.exp $ dlltool -d hello.def -e hello.exp
$ g++ hello.exp *.o -L../../win32/lib -lmingwthrd -lm -lz -lws2_32 \ $ g++ hello.exp *.o -L../../win32/lib -lmingwthrd -lm -lz -lws2_32 \
-mwindows -mconsole -o hello -mwindows -mconsole -o hello
$ strip --strip-all hello.exe $ strip --strip-all hello.exe

View File

@ -167,8 +167,7 @@ resolveNativeMethod2(Thread* t, object method)
} }
#ifdef __MINGW32__ #ifdef __MINGW32__
// on windows, we also try the _%s@%d variant, since the SWT // on windows, we also try the _%s@%d and %s@%d variants
// libraries use it.
unsigned footprint = methodParameterFootprint(t, method) + 1; unsigned footprint = methodParameterFootprint(t, method) + 1;
if (methodFlags(t, method) & ACC_STATIC) { if (methodFlags(t, method) & ACC_STATIC) {
++ footprint; ++ footprint;
@ -186,6 +185,12 @@ resolveNativeMethod2(Thread* t, object method)
if (p) { if (p) {
return p; return p;
} }
// one more try without the leading underscore
p = ::resolveNativeMethod(t, undecorated + 1, decorated + 1);
if (p) {
return p;
}
#endif #endif
return 0; return 0;