This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/42568] [Cygwin] BLOCKDATA referenced in EXTERNAL not loading from library
- From: "ian at airs dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 5 Jan 2010 16:09:41 -0000
- Subject: [Bug fortran/42568] [Cygwin] BLOCKDATA referenced in EXTERNAL not loading from library
- References: <bug-42568-18131@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #22 from ian at airs dot com 2010-01-05 16:09 -------
For ELF, when the GNU linker has seen a common symbol, and then sees that
symbol in the archive map, it will look in the object to see whether the object
defines the symbol (rather than simply providing another common definition).
If the object does define the symbol, then it is pulled into the link. See
http://sourceware.org/ml/binutils/1999-12/msg00015.html . This was done for
compatibility with the SunOS and HP/UX linkers, but in retrospect I think it
may have been a mistake.
For the PE target used on cygwin, the GNU linker does not do this. It follows
the simpler rule. For that matter, the gold linker also does not do this.
So, yes, the linkers behave differently. If you need to provide a common
definition, and you also need to force that common definition to pull in a
definition from an archive, then the compiler should arrange for that to
happen. The easy way is: whenever you have a definition, also define some
other symbol. Whenever you have a common symbol, also include an undefined
reference to that definition.
--
ian at airs dot com changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |ian at airs dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42568