Why ld not read some non-virtual thunk in a import library or dll?

Bo Yang techrazy.yang@gmail.com
Tue Jul 8 06:09:00 GMT 2008


2008/7/8 Bo Yang <techrazy.yang@gmail.com>:
> Hi,
>   I am now building Mozilla with Gcc-4.3.0 and binutils 2.18. And I
> came across a strange LD error when I link some library to create a
> DLL. For detail , I make a cross-compile env for Mingw32 on a Linux
> machine. And there is a DLL import library, called
> libxpcom_core.dll.a, which provice some symbols. In this library,
> there are one class called nsHashProperytBag which multiple inherit
> from some other virtual base class. And this class implements all the
> virtual methods. In the libxpcom_core.dll.a, I use nm to examine what
> it contain, I found it contain all the symbols. I mean, take for
> example, there is a SetProperty virtual method in the
> nsHashPropertyBag, then there are two symbol for this method: one is
> the just the "nsHashPropertyBag::SetProperty
> " and the other is "non-virtual thunk to nsHashPropertyBag::SetProperty".
>
>   Then, I use this library to create some new DLL. I make a class
> called "Test" which just inherit the nsHashPropertyBag. And I compile
> the class and link it with the libxpcom_core.dll.a. But it failed, and
> the errors are a bunch of "undefined reference to non-virtual thunk to
> ...". I use the LD's -cref option to examine where each symbol
> appears, but to my surprise, for each "non-virtual thunk to..", the
> ones in the libxpcom_core.dll.a is not read at all. And I use the LD's
> -M to see the symbol map, there is no "non-virtual thunks" appearing
> in the memeory at all.
>
>   And when I link directly to a DLL, this happend too. I am sure all
> the __attribute__(dllimport) and export are set correctly. And the
> "non-virutal thunks" are rightly in the libxpcom_core.dll.a and the
> DLL. I am just wodering why LD did not read these "non-virtual thunk "
> out of the library and use them to link.
>
>   Also, I try to make a set of classes and library to reproduce this
> problem. I have create an exact set of classes with the same
> inheritance of Mozilla code. But, I can't reproduce the problem, it is
> really annoying.
>
>   Could you please help me? If you need more information, please tell
> me. Any advice will be appreciated very much!
>

And after some more insight, I find something new to this problem. I
compile Mozilla with gcc 3.4.2, and there is no problem. So, I copy
the libxpcom_core.dll.a from the gcc 3.4.2 build to the gcc 4.3.0
build.  I mean, I use the gcc 3.4.2 output libxpcom_core.dll.a to link
with the gcc 4.3.0 objects with gcc 4.3.0. To my surprise it succeed.
So, I think the difference between the two libxpcom_core.dll.a should
be very important. And I paste them here:

--- 3.4.2	2008-07-07 20:32:17.000000000 -0700
+++ 4.3.0	2008-07-07 20:32:26.000000000 -0700
@@ -88,9 +88,9 @@
 00000000 i .idata$6
 00000000 i .idata$7
 00000000 t .text
-00000000 T __ZThn4_N17nsHashPropertyBag7ReleaseEv@4
+00000000 T __ZThn4_N17nsHashPropertyBag7ReleaseEv
          U __head_xpcom_core_dll
-00000000 I __imp___ZThn4_N17nsHashPropertyBag7ReleaseEv@4
+00000000 I __imp___ZThn4_N17nsHashPropertyBag7ReleaseEv

 d001368.o:
 00000000 i .idata$4
@@ -98,9 +98,9 @@
 00000000 i .idata$6
 00000000 i .idata$7
 00000000 t .text
-00000000 T __ZThn4_N17nsHashPropertyBag6HasKeyERK18nsAString_internalPi@12
+00000000 T __ZThn4_N17nsHashPropertyBag6HasKeyERK18nsAString_internalPi
          U __head_xpcom_core_dll
-00000000 I __imp___ZThn4_N17nsHashPropertyBag6HasKeyERK18nsAString_internalPi@12
+00000000 I __imp___ZThn4_N17nsHashPropertyBag6HasKeyERK18nsAString_internalPi

 d001367.o:
 00000000 i .idata$4
@@ -108,9 +108,9 @@
 00000000 i .idata$6
 00000000 i .idata$7
 00000000 t .text
-00000000 T __ZThn4_N17nsHashPropertyBag6AddRefEv@4
+00000000 T __ZThn4_N17nsHashPropertyBag6AddRefEv
          U __head_xpcom_core_dll
-00000000 I __imp___ZThn4_N17nsHashPropertyBag6AddRefEv@4
+00000000 I __imp___ZThn4_N17nsHashPropertyBag6AddRefEv

 d001366.o:
 00000000 i .idata$4
@@ -118,9 +118,9 @@
 00000000 i .idata$6
 00000000 i .idata$7
 00000000 t .text
-00000000 T __ZThn4_N17nsHashPropertyBag3GetERK18nsAString_internalPP10nsIVariant@12
+00000000 T __ZThn4_N17nsHashPropertyBag3GetERK18nsAString_internalPP10nsIVariant
          U __head_xpcom_core_dll
-00000000 I __imp___ZThn4_N17nsHashPropertyBag3GetERK18nsAString_internalPP10nsIVariant@12
+00000000 I __imp___ZThn4_N17nsHashPropertyBag3GetERK18nsAString_internalPP10nsIVariant

 d001365.o:
 00000000 i .idata$4
@@ -128,9 +128,9 @@
 00000000 i .idata$6
 00000000 i .idata$7
 00000000 t .text
-00000000 T __ZThn4_N17nsHashPropertyBag24SetPropertyAsAUTF8StringERK18nsAString_internalRK19nsACString_internal@12
+00000000 T __ZThn4_N17nsHashPropertyBag24SetPropertyAsAUTF8StringERK18nsAString_internalRK19nsACString_internal
          U __head_xpcom_core_dll
-00000000 I __imp___ZThn4_N17nsHashPropertyBag24SetPropertyAsAUTF8StringERK18nsAString_internalRK19nsACString_internal@12
+00000000 I __imp___ZThn4_N17nsHashPropertyBag24SetPropertyAsAUTF8StringERK18nsAString_internalRK19nsACString_internal

 d001364.o:
 00000000 i .idata$4
@@ -138,9 +138,9 @@
 00000000 i .idata$6
 00000000 i .idata$7
 00000000 t .text
-00000000 T __ZThn4_N17nsHashPropertyBag24GetPropertyAsAUTF8StringERK18nsAString_internalR19nsACString_internal@12
+00000000 T __ZThn4_N17nsHashPropertyBag24GetPropertyAsAUTF8StringERK18nsAString_internalR19nsACString_internal
          U __head_xpcom_core_dll
-00000000 I __imp___ZThn4_N17nsHashPropertyBag24GetPropertyAsAUTF8StringERK18nsAString_internalR19nsACString_internal@12
+00000000 I __imp___ZThn4_N17nsHashPropertyBag24GetPropertyAsAUTF8StringERK18nsAString_internalR19nsACString_internal

 d001363.o:
 00000000 i .idata$4
@@ -148,9 +148,9 @@
 00000000 i .idata$6
 00000000 i .idata$7
 00000000 t .text
-00000000 T __ZThn4_N17nsHashPropertyBag22SetPropertyAsInterfaceERK18nsAString_internalP11nsISupports@12
+00000000 T __ZThn4_N17nsHashPropertyBag22SetPropertyAsInterfaceERK18nsAString_internalP11nsISupports
          U __head_xpcom_core_dll
-00000000 I __imp___ZThn4_N17nsHashPropertyBag22SetPropertyAsInterfaceERK18nsAString_internalP11nsISupports@12
+00000000 I __imp___ZThn4_N17nsHashPropertyBag22SetPropertyAsInterfaceERK18nsAString_internalP11nsISupports

 d001362.o:
 00000000 i .idata$4
@@ -158,9 +158,9 @@
 00000000 i .idata$6
 00000000 i .idata$7
 00000000 t .text
-00000000 T __ZThn4_N17nsHashPropertyBag22GetPropertyAsInterfaceERK18nsAString_internalRK4nsIDPPv@16
+00000000 T __ZThn4_N17nsHashPropertyBag22GetPropertyAsInterfaceERK18nsAString_internalRK4nsIDPPv
          U __head_xpcom_core_dll
-00000000 I __imp___ZThn4_N17nsHashPropertyBag22GetPropertyAsInterfaceERK18nsAString_internalRK4nsIDPPv@16
+00000000 I __imp___ZThn4_N17nsHashPropertyBag22GetPropertyAsInterfaceERK18nsAString_internalRK4nsIDPPv

 d001361.o:
 00000000 i .idata$4
@@ -168,9 +168,9 @@
 00000000 i .idata$6
 00000000 i .idata$7
 00000000 t .text
-00000000 T __ZThn4_N17nsHashPropertyBag21SetPropertyAsACStringERK18nsAString_internalRK19nsACString_internal@12
+00000000 T __ZThn4_N17nsHashPropertyBag21SetPropertyAsACStringERK18nsAString_internalRK19nsACString_internal
          U __head_xpcom_core_dll
-00000000 I __imp___ZThn4_N17nsHashPropertyBag21SetPropertyAsACStringERK18nsAString_internalRK19nsACString_internal@12
+00000000 I __imp___ZThn4_N17nsHashPropertyBag21SetPropertyAsACStringERK18nsAString_internalRK19nsACString_internal

 d001360.o:
 00000000 i .idata$4
@@ -178,9 +178,9 @@
 00000000 i .idata$6
 00000000 i .idata$7
 00000000 t .text
-00000000 T __ZThn4_N17nsHashPropertyBag21GetPropertyAsACStringERK18nsAString_internalR19nsACString_internal@12
+00000000 T __ZThn4_N17nsHashPropertyBag21GetPropertyAsACStringERK18nsAString_internalR19nsACString_internal
          U __head_xpcom_core_dll
-00000000 I __imp___ZThn4_N17nsHashPropertyBag21GetPropertyAsACStringERK18nsAString_internalR19nsACString_internal@12
+00000000 I __imp___ZThn4_N17nsHashPropertyBag21GetPropertyAsACStringERK18nsAString_internalR19nsACString_internal

 d001359.o:
 00000000 i .idata$4
@@ -188,9 +188,9 @@
 00000000 i .idata$6
 00000000 i .idata$7
 00000000 t .text
-00000000 T __ZThn4_N17nsHashPropertyBag20SetPropertyAsAStringERK18nsAString_internalS2_@12
+00000000 T __ZThn4_N17nsHashPropertyBag20SetPropertyAsAStringERK18nsAString_internalS2_
          U __head_xpcom_core_dll
-00000000 I __imp___ZThn4_N17nsHashPropertyBag20SetPropertyAsAStringERK18nsAString_internalS2_@12
+00000000 I __imp___ZThn4_N17nsHashPropertyBag20SetPropertyAsAStringERK18nsAString_internalS2_

 d001358.o:
 00000000 i .idata$4
@@ -198,9 +198,9 @@
 00000000 i .idata$6
 00000000 i .idata$7
 00000000 t .text
-00000000 T __ZThn4_N17nsHashPropertyBag20GetPropertyAsAStringERK18nsAString_internalRS0_@12
+00000000 T __ZThn4_N17nsHashPropertyBag20GetPropertyAsAStringERK18nsAString_internalRS0_
          U __head_xpcom_core_dll
-00000000 I __imp___ZThn4_N17nsHashPropertyBag20GetPropertyAsAStringERK18nsAString_internalRS0_@12
+00000000 I __imp___ZThn4_N17nsHashPropertyBag20GetPropertyAsAStringERK18nsAString_internalRS0_

 d001357.o:
 00000000 i .idata$4
@@ -208,9 +208,9 @@
 00000000 i .idata$6
 00000000 i .idata$7
 00000000 t .text
-00000000 T __ZThn4_N17nsHashPropertyBag19SetPropertyAsUint64ERK18nsAString_internaly@16
+00000000 T __ZThn4_N17nsHashPropertyBag19SetPropertyAsUint64ERK18nsAString_internaly
          U __head_xpcom_core_dll
-00000000 I __imp___ZThn4_N17nsHashPropertyBag19SetPropertyAsUint64ERK18nsAString_internaly@16
+00000000 I __imp___ZThn4_N17nsHashPropertyBag19SetPropertyAsUint64ERK18nsAString_internaly

 d001356.o:
 00000000 i .idata$4
@@ -218,9 +218,9 @@
 00000000 i .idata$6
 00000000 i .idata$7
 00000000 t .text
-00000000 T __ZThn4_N17nsHashPropertyBag19SetPropertyAsUint32ERK18nsAString_internalj@12
+00000000 T __ZThn4_N17nsHashPropertyBag19SetPropertyAsUint32ERK18nsAString_internalj
          U __head_xpcom_core_dll
-00000000 I __imp___ZThn4_N17nsHashPropertyBag19SetPropertyAsUint32ERK18nsAString_internalj@12
+00000000 I __imp___ZThn4_N17nsHashPropertyBag19SetPropertyAsUint32ERK18nsAString_internalj

 d001355.o:
 00000000 i .idata$4
@@ -228,9 +228,9 @@
 00000000 i .idata$6
 00000000 i .idata$7
 00000000 t .text
-00000000 T __ZThn4_N17nsHashPropertyBag19SetPropertyAsDoubleERK18nsAString_internald@16
+00000000 T __ZThn4_N17nsHashPropertyBag19SetPropertyAsDoubleERK18nsAString_internald
          U __head_xpcom_core_dll
-00000000 I __imp___ZThn4_N17nsHashPropertyBag19SetPropertyAsDoubleERK18nsAString_internald@16
+00000000 I __imp___ZThn4_N17nsHashPropertyBag19SetPropertyAsDoubleERK18nsAString_internald

 d001354.o:
 00000000 i .idata$4
@@ -238,9 +238,9 @@
 00000000 i .idata$6
 00000000 i .idata$7
 00000000 t .text
-00000000 T __ZThn4_N17nsHashPropertyBag19GetPropertyAsUint64ERK18nsAString_internalPy@12
+00000000 T __ZThn4_N17nsHashPropertyBag19GetPropertyAsUint64ERK18nsAString_internalPy
          U __head_xpcom_core_dll
-00000000 I __imp___ZThn4_N17nsHashPropertyBag19GetPropertyAsUint64ERK18nsAString_internalPy@12
+00000000 I __imp___ZThn4_N17nsHashPropertyBag19GetPropertyAsUint64ERK18nsAString_internalPy

 d001353.o:
 00000000 i .idata$4
@@ -248,9 +248,9 @@
 00000000 i .idata$6
 00000000 i .idata$7
 00000000 t .text
-00000000 T __ZThn4_N17nsHashPropertyBag19GetPropertyAsUint32ERK18nsAString_internalPj@12
+00000000 T __ZThn4_N17nsHashPropertyBag19GetPropertyAsUint32ERK18nsAString_internalPj
          U __head_xpcom_core_dll
-00000000 I __imp___ZThn4_N17nsHashPropertyBag19GetPropertyAsUint32ERK18nsAString_internalPj@12
+00000000 I __imp___ZThn4_N17nsHashPropertyBag19GetPropertyAsUint32ERK18nsAString_internalPj

 d001352.o:
 00000000 i .idata$4
@@ -258,9 +258,9 @@
 00000000 i .idata$6
 00000000 i .idata$7
 00000000 t .text
-00000000 T __ZThn4_N17nsHashPropertyBag19GetPropertyAsDoubleERK18nsAString_internalPd@12
+00000000 T __ZThn4_N17nsHashPropertyBag19GetPropertyAsDoubleERK18nsAString_internalPd
          U __head_xpcom_core_dll
-00000000 I __imp___ZThn4_N17nsHashPropertyBag19GetPropertyAsDoubleERK18nsAString_internalPd@12
+00000000 I __imp___ZThn4_N17nsHashPropertyBag19GetPropertyAsDoubleERK18nsAString_internalPd

 d001351.o:
 00000000 i .idata$4
@@ -268,9 +268,9 @@
 00000000 i .idata$6
 00000000 i .idata$7
 00000000 t .text
-00000000 T __ZThn4_N17nsHashPropertyBag18SetPropertyAsInt64ERK18nsAString_internalx@16
+00000000 T __ZThn4_N17nsHashPropertyBag18SetPropertyAsInt64ERK18nsAString_internalx
          U __head_xpcom_core_dll
-00000000 I __imp___ZThn4_N17nsHashPropertyBag18SetPropertyAsInt64ERK18nsAString_internalx@16
+00000000 I __imp___ZThn4_N17nsHashPropertyBag18SetPropertyAsInt64ERK18nsAString_internalx

 d001350.o:
 00000000 i .idata$4
@@ -278,9 +278,9 @@
 00000000 i .idata$6
 00000000 i .idata$7
 00000000 t .text
-00000000 T __ZThn4_N17nsHashPropertyBag18SetPropertyAsInt32ERK18nsAString_internali@12
+00000000 T __ZThn4_N17nsHashPropertyBag18SetPropertyAsInt32ERK18nsAString_internali
          U __head_xpcom_core_dll
-00000000 I __imp___ZThn4_N17nsHashPropertyBag18SetPropertyAsInt32ERK18nsAString_internali@12
+00000000 I __imp___ZThn4_N17nsHashPropertyBag18SetPropertyAsInt32ERK18nsAString_internali

 d001349.o:
 00000000 i .idata$4
@@ -288,9 +288,9 @@
 00000000 i .idata$6
 00000000 i .idata$7
 00000000 t .text
-00000000 T __ZThn4_N17nsHashPropertyBag18GetPropertyAsInt64ERK18nsAString_internalPx@12
+00000000 T __ZThn4_N17nsHashPropertyBag18GetPropertyAsInt64ERK18nsAString_internalPx
          U __head_xpcom_core_dll
-00000000 I __imp___ZThn4_N17nsHashPropertyBag18GetPropertyAsInt64ERK18nsAString_internalPx@12
+00000000 I __imp___ZThn4_N17nsHashPropertyBag18GetPropertyAsInt64ERK18nsAString_internalPx

 d001348.o:
 00000000 i .idata$4
@@ -298,9 +298,9 @@
 00000000 i .idata$6
 00000000 i .idata$7
 00000000 t .text
-00000000 T __ZThn4_N17nsHashPropertyBag18GetPropertyAsInt32ERK18nsAString_internalPi@12
+00000000 T __ZThn4_N17nsHashPropertyBag18GetPropertyAsInt32ERK18nsAString_internalPi
          U __head_xpcom_core_dll
-00000000 I __imp___ZThn4_N17nsHashPropertyBag18GetPropertyAsInt32ERK18nsAString_internalPi@12
+00000000 I __imp___ZThn4_N17nsHashPropertyBag18GetPropertyAsInt32ERK18nsAString_internalPi

 d001347.o:
 00000000 i .idata$4
@@ -308,9 +308,9 @@
 00000000 i .idata$6
 00000000 i .idata$7
 00000000 t .text
-00000000 T __ZThn4_N17nsHashPropertyBag17SetPropertyAsBoolERK18nsAString_internali@12
+00000000 T __ZThn4_N17nsHashPropertyBag17SetPropertyAsBoolERK18nsAString_internali
          U __head_xpcom_core_dll
-00000000 I __imp___ZThn4_N17nsHashPropertyBag17SetPropertyAsBoolERK18nsAString_internali@12
+00000000 I __imp___ZThn4_N17nsHashPropertyBag17SetPropertyAsBoolERK18nsAString_internali

 d001346.o:
 00000000 i .idata$4
@@ -318,9 +318,9 @@
 00000000 i .idata$6
 00000000 i .idata$7
 00000000 t .text
-00000000 T __ZThn4_N17nsHashPropertyBag17GetPropertyAsBoolERK18nsAString_internalPi@12
+00000000 T __ZThn4_N17nsHashPropertyBag17GetPropertyAsBoolERK18nsAString_internalPi
          U __head_xpcom_core_dll
-00000000 I __imp___ZThn4_N17nsHashPropertyBag17GetPropertyAsBoolERK18nsAString_internalPi@12
+00000000 I __imp___ZThn4_N17nsHashPropertyBag17GetPropertyAsBoolERK18nsAString_internalPi

 d001345.o:
 00000000 i .idata$4
@@ -328,9 +328,9 @@
 00000000 i .idata$6
 00000000 i .idata$7
 00000000 t .text
-00000000 T __ZThn4_N17nsHashPropertyBag14QueryInterfaceERK4nsIDPPv@12
+00000000 T __ZThn4_N17nsHashPropertyBag14QueryInterfaceERK4nsIDPPv
          U __head_xpcom_core_dll
-00000000 I __imp___ZThn4_N17nsHashPropertyBag14QueryInterfaceERK4nsIDPPv@12
+00000000 I __imp___ZThn4_N17nsHashPropertyBag14QueryInterfaceERK4nsIDPPv

 d001344.o:
 00000000 i .idata$4
@@ -338,9 +338,9 @@
 00000000 i .idata$6
 00000000 i .idata$7
 00000000 t .text
-00000000 T __ZThn4_N17nsHashPropertyBag13GetEnumeratorEPP19nsISimpleEnumerator@8
+00000000 T __ZThn4_N17nsHashPropertyBag13GetEnumeratorEPP19nsISimpleEnumerator
          U __head_xpcom_core_dll
-00000000 I __imp___ZThn4_N17nsHashPropertyBag13GetEnumeratorEPP19nsISimpleEnumerator@8
+00000000 I __imp___ZThn4_N17nsHashPropertyBag13GetEnumeratorEPP19nsISimpleEnumerator

 d001343.o:
 00000000 i .idata$4
@@ -348,9 +348,9 @@
 00000000 i .idata$6
 00000000 i .idata$7
 00000000 t .text
-00000000 T __ZThn4_N17nsHashPropertyBag11GetPropertyERK18nsAString_internalPP10nsIVariant@12
+00000000 T __ZThn4_N17nsHashPropertyBag11GetPropertyERK18nsAString_internalPP10nsIVariant
          U __head_xpcom_core_dll
-00000000 I __imp___ZThn4_N17nsHashPropertyBag11GetPropertyERK18nsAString_internalPP10nsIVariant@12
+00000000 I __imp___ZThn4_N17nsHashPropertyBag11GetPropertyERK18nsAString_internalPP10nsIVariant

 d001342.o:
 00000000 i .idata$4


And the only difference between two libxpcom_core.dll.a is that there
is a @xx at the one which gcc 3.4.2 produce. I don't understand why
this "@xx" affect linkage. I hope my information make the problem
clearly. Help please, thanks!

Regards!
Bo



More information about the Binutils mailing list