[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug gas/9687] Weak symbols not working on mingw32

From: dave dot korn dot cygwin at gmail dot com
Subject: [Bug gas/9687] Weak symbols not working on mingw32
Date: 19 Mar 2009 02:14:00 -0000

------- Additional Comments From dave dot korn dot cygwin at gmail dot com  
2009-03-19 02:14 -------
  Hi tcl_de, thanks for Cc'ing me into this bug report.

(In reply to comment #2)
> (In reply to comment #1)
> >      As a GNU extension, weak symbols that do not specify an alternate
> >      symbol are supported.  If the symbol is undefined when linking,
> >      the symbol uses a default value.
> Well, doesn't that paragraph tell that me that as a GNU extension weak symbols
> are supported?
> Shouldn't those two files just compile cleanly on mingw32 then as they do on
> linux because "as a GNU extension weak symbols are supported"?

  You have misread the paragraph.  As a gnu extension, "weak symbols that do not
specify an alternate symbol" are supported.

  On PE targets, binutils supports weak externals, a limited form of weak symbol
that acts as an alias for a default value.  As a GNU extension (above what MSVC
toolchain) supports, you may define these symbols *without* defining the default
symbol that they act as an alias for. 

  Normally (MSVC toolchain) you must supply a default definition along with
every weak symbol, in the same .o file.  Refer to this final line of the second
paragraph of section 5.5.3 (Auxiliary Format 3: Weak externals) of the PE-COFF
spec v8:

  "  The external symbol, sym2, must always be linked; typically, it is defined
in the module that contains the weak reference to sym1.  "

  IIUC the GNU extension is to allow sym2 to optionally be an undefined external
symbol, rather than defined in the module.

  The weak support in binutils is currently limited, as it was only developed
enough to provide interoperability with the MSVC toolchain, which uses these
"weak externals" to resolve class destructors.  There are moves underfoot to
extend the implementation to fully (or at least more fully) support ELF weak
symbols, but that will take a little time.

  In the matter of this current bug, I found a post from Danny which summarizes
the situation:

> > Does the pe-i386 object format support weak symbol definitions?
> No.
> > Does the pe-i386 object format support weak symbol references?
> PE-COFF spec supports "weak externs".

and in particular he says:

> weak aliases also seem to work (with GNU ld) even though the
> IMAGE_WEAK_EXTERN_SEARCH_ALIAS characteristic is not set.
> I imagine the  MS linker would have trouble with GNU weak aliases
> without the flag.

  It seems the GNU linker does too.  I think that your test case ought to be
possible to make work using the existing support, though, and we should consider
whether setting the characteristic field isn't the right thing to do.



------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]