[PATCH/RFC] Fix LD test FAIL: weak symbols on Cygwin
Thu Mar 19 01:41:00 GMT 2009
On Thu, Mar 19, 2009 at 12:51 PM, Aaron W. LaFramboise
> Kai Tietz wrote:
>> As far as I see the weak support for pe(p)-coff targets isn't complete.
>> The comdat stuff is half implemented and bfd uses internally just C_NT_WEAK,
>> but it should use C_WEAKEXT in most cases instead.
>> I think there is much work left to support weak in a better way.
> What I implemented specifically were the PECOFF weak symbols specified in
> the standard (C_NT_WEAK). I implemented them specifically because I needed
> them for link interoperability with MSVC code, which generates them to solve
> C++ destructor resolution.
> A lot of people feel that PECOFF should be extended with an ELF-like weak
> symbol, which presumably would be called C_WEAKEXT. The C_NT_WEAK symbols
> presently implemented by .weak in gas have some special features that make
> them behave more alike to to ELF weak symbols than implemented in
> Microsoft's tools, without breaking standard conformance. (The effect of
> this is that weak symbols generated by gas will work just fine with MS
> The only important thing that ELF symbols can do that PECOFF symbols simply
> cannot do is satisfy external references. It's my opinion that this is not
> actually a very important feature, but because ELF can do it, it comes up a
> lot on Linux-based code as a way of making two steps into one. I believe
> Danny Smith may have extended binutils ld to make this sort of thing work,
> as an extension to PECOFF, although I don't really know the status of this.
No , I haven't done this (not on purpose, anyway) nor am I keen on
Like you I would like to see weak externals implemented as close as
possible to PE-COFF spec. 'Vague definitions' should be implemented
using link-once COMDAT sections.
> I have nothing against someone implementing an extension to PECOFF that has
> ELF-style weak symbols (C_WEAKEXT); but that really has nothing to do with
> the existing weak symbol support. In any case, I think it's important we
> correctly implement the ones specified by the standard.
> Also, as far as I know, this isn't related to COMDAT sections, although
> they're a similar mechanism. I agree with you that completely implementing
> COMDAT as specified in PECOFF would be very valuable. To the extent that
> C_NT_WEAK symbols and COMDAT sections intersect, everything should work now,
> although the testsuite does not test this.
The problem is that people hear that win32 targets SUPPORT_WEAK and
automatically assume that now it can do everything that ELF .weak
does. That would be nice, as a GNU extension, but I for one would
like my object code to be understood by MS as well as GNU tools.
More information about the Binutils