public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* C_WEAKEXT Weak Externals in i386-pe COFF
@ 2003-06-25  2:43 AWLaFramboise
  2003-07-04 14:57 ` Nick Clifton
  0 siblings, 1 reply; 2+ messages in thread
From: AWLaFramboise @ 2003-06-25  2:43 UTC (permalink / raw)
  To: binutils

Hi,

I'm trying to get GNU ld to link objects produced from
MSVC, and I beleive I have found a problem with binutils'
C_WEAKEXT support:

Weak externals, apparently known within binutils as
C_WEAKEXT, to Win32 as IMAGE_SYM_CLASS_WEAK_EXTERNAL,
and documented in the Win32 PE COFF spec in section 5.5.3,
are a loose analog of ELF weak symbols.  Binutils seems
to treat them the same way as their ELF counterparts, however,
they are actually substancially different.

Quoting from the spec:
"If a definition of sym1 is linked, then an external reference to the symbol is resolved normally. If a definition of sym1 is not linked, then all references to the weak external for sym1 refer to sym2 instead. The external symbol, sym2, must always be linked; typically it is defined in the module containing the weak reference to sym1."

In other words, where ELF weak symbols default to zero if
not resolved, COFF weak symbols default to some other
symbol.

Is there some way to get binutils to correctly resolve
these kinds of symbols?  Has anyone worked on this, or
had any luck getting these kinds of things to link?

If no to the above, how difficult would it be to add this
support?  (I am unfamiliar with binutils internals.)

(I'm trying to avoid using the MS linker, in part because
it doesn't seem to support GCC as well as GNU ld does.)


Any help or pointers would be appreciated,

Aaron

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: C_WEAKEXT Weak Externals in i386-pe COFF
  2003-06-25  2:43 C_WEAKEXT Weak Externals in i386-pe COFF AWLaFramboise
@ 2003-07-04 14:57 ` Nick Clifton
  0 siblings, 0 replies; 2+ messages in thread
From: Nick Clifton @ 2003-07-04 14:57 UTC (permalink / raw)
  To: AWLaFramboise; +Cc: binutils

Hi Aaron,

> I'm trying to get GNU ld to link objects produced from
> MSVC, and I beleive I have found a problem with binutils'
> C_WEAKEXT support:
>
> Weak externals, apparently known within binutils as
> C_WEAKEXT, to Win32 as IMAGE_SYM_CLASS_WEAK_EXTERNAL,
> and documented in the Win32 PE COFF spec in section 5.5.3,
> are a loose analog of ELF weak symbols.  Binutils seems
> to treat them the same way as their ELF counterparts, however,
> they are actually substancially different.
>
> Quoting from the spec:
>   "If a definition of sym1 is linked, then an external reference to
>    the symbol is resolved normally. If a definition of sym1 is not
>    linked, then all references to the weak external for sym1 refer
>    to sym2 instead. The external symbol, sym2, must always be
>    linked; typically it is defined in the module containing the weak
>    reference to sym1." 
>
> In other words, where ELF weak symbols default to zero if
> not resolved, COFF weak symbols default to some other
> symbol.
>
> Is there some way to get binutils to correctly resolve
> these kinds of symbols?

At the moment - no.

> Has anyone worked on this, or had any luck getting these kinds of
> things to link?

I do not think so. :-(

> If no to the above, how difficult would it be to add this
> support?  (I am unfamiliar with binutils internals.)

It would probably be tricky.  But it certainly is do-able.  BFD's
internals can seem daunting at first but they are not that bad
really.  Plus you can always ask on this list for help.


The files you are most likely to want to look at and modify are
bfd/coffcode.h and bfd/cofflink.c.  In particular have a look at the
function _bfd_coff_write_global_sym().

Another thing that might help is if you can create a small test case
that can be added to the linker testsuite.  That way anyone who runs
the linker tests (for a WinCE target) will be reminded that this
problem exists and they might even be motivated to fix it.

Cheers
        Nick
        

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2003-07-04 14:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-06-25  2:43 C_WEAKEXT Weak Externals in i386-pe COFF AWLaFramboise
2003-07-04 14:57 ` Nick Clifton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).