[PATCH/RFC] Fix LD test FAIL: weak symbols on Cygwin

Kai Tietz ktietz70@googlemail.com
Fri Mar 20 09:55:00 GMT 2009


2009/3/20 Vincent R. <forumer@smartmobili.com>:
> On Thu, 19 Mar 2009 23:58:15 +0000, Dave Korn
> <dave.korn.cygwin@googlemail.com> wrote:
>> Danny, Aaron, Kai:
>>
>>   Do you guys have any references, code samples or testcases that will
> show
>>   me
>> the typical MSVC usage of weak externals so that I can understand the
>> interop
>> requirements a bit better?  Googling msdn hasn't told me anything
>> informative.
>>
>>     cheers,
>>       DaveK
>
> I also tried to google a bit because usually I am quite good at it and
> unfortunately I have found only
> one interesting reference here :
> http://support.microsoft.com/default.aspx?scid=kb;en-us;q148652
>
> In the cause section :
> The CRT libraries use weak external linkage for the new, delete, and
> DllMain functions. The MFC libraries also contain new, delete, and DllMain
> functions. These functions require the MFC libraries to be linked before
> the CRT library is linked.
>
> So I have disassembled libcmt.lib\new.obj and and found this :
>
> UNDEF:00000230 ;
> ===========================================================================
> UNDEF:00000230
> UNDEF:00000230 ; Segment type: Externs
> UNDEF:00000230 ; UNDEF
> UNDEF:00000230 ; public: __thiscall std::exception::exception(char const *
> const &, int)
> UNDEF:00000230                 extrn ??0exception@std@@QAE@ABQBDH@Z:near
> UNDEF:00000230                                         ; CODE XREF:
> std::bad_alloc::bad_alloc(void)+C p
> UNDEF:00000234 ; const type_info::`vftable'
> UNDEF:00000234                 extrn ??_7type_info@@6B@:near
> UNDEF:00000234                                         ; DATA XREF:
> .data:std::bad_alloc `RTTI Type Descriptor' o
> UNDEF:00000234                                         ;
> .data:std::exception `RTTI Type Descriptor' o
> UNDEF:00000238 ; public: virtual void * __thiscall std::bad_alloc::`scalar
> deleting destructor'(unsigned int)
> UNDEF:00000238                 extrn ??_Gbad_alloc@std@@UAEPAXI@Z_0:near
> UNDEF:0000023C ; public: virtual void * __thiscall std::bad_alloc::`vector
> deleting destructor'(unsigned int)
> UNDEF:0000023C                 extrn ??_Ebad_alloc@std@@UAEPAXI@Z:near ;
> weak
> UNDEF:0000023C                                         ; DATA XREF:
> .rdata:const std::bad_alloc::`vftable' o
> UNDEF:00000240 ; public: virtual char const * __thiscall
> std::exception::what(void)const
> UNDEF:00000240                 extrn ?what@exception@std@@UBEPBDXZ:near
> UNDEF:00000240                                         ; DATA XREF:
> .rdata:00000038 o
> UNDEF:00000244 ; public: virtual __thiscall
> std::exception::~exception(void)
> UNDEF:00000244                 extrn ??1exception@std@@UAE@XZ:near
> UNDEF:00000244                                         ; CODE XREF:
> std::bad_alloc::~bad_alloc(void)+6 j
> UNDEF:00000244                                         ;
> std::bad_alloc::`scalar deleting destructor'(uint)+E p ...
> UNDEF:00000248 ; void __cdecl operator delete(void *)
> UNDEF:00000248                 extrn ??3@YAXPAX@Z:near ; CODE XREF:
> std::bad_alloc::`scalar deleting destructor'(uint)+1A p
> UNDEF:0000024C ; public: __thiscall std::exception::exception(class
> exception::exception const &)
> UNDEF:0000024C                 extrn ??0exception@std@@QAE@ABV01@@Z:near
> UNDEF:0000024C                                         ; CODE XREF:
> std::bad_alloc::bad_alloc(bad_alloc::bad_alloc const &)+B p
> UNDEF:0000024C                                         ; DATA XREF:
> .xdata$x:00000210 o
> UNDEF:00000250 ; int __cdecl atexit(void (__cdecl *)())
> UNDEF:00000250                 extrn _atexit:near      ; CODE XREF:
> .text:0000018F p
> UNDEF:00000254 ; void *__cdecl malloc(size_t Size)
> UNDEF:00000254                 extrn _malloc:near      ; CODE XREF:
> .text:00000162 p
> UNDEF:00000258                 extrn __callnewh:near   ; CODE XREF:
> .text:00000155 p
> UNDEF:0000025C ; __stdcall _CxxThrowException(x, x)
> UNDEF:0000025C                 extrn __CxxThrowException@8:near ; CODE
> XREF: .text:000001A7 p
> UNDEF:0000025C
> UNDEF:0000025C
> UNDEF:0000025C                 end
>
> This UNDEF stuff sems to be what pecoff specs is talking about :
>
> "Weak externals are represented by a symbol table record with EXTERNAL
> storage class, UNDEF section number, and a value of zero. The weak-external
> symbol record is followed by an auxiliary record with the following
> format."
>
>
> I don't think it helps you but this is the only information I found.
>
>
>
>
>
>
>
>

Yes, it's true what Vincent found. But there is a documention about
this in pecoff_v8.doc. See section "29 Auxiliary Format 3: Weak
Externals". I think this is the best point to start from.

Cheers,
Kai

-- 
|  (\_/) This is Bunny. Copy and paste
| (='.'=) Bunny into your signature to help
| (")_(") him gain world domination



More information about the Binutils mailing list