From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26136 invoked by alias); 5 Jan 2010 16:10:00 -0000 Received: (qmail 26042 invoked by uid 48); 5 Jan 2010 16:09:41 -0000 Date: Tue, 05 Jan 2010 16:10:00 -0000 Message-ID: <20100105160941.26041.qmail@sourceware.org> X-Bugzilla-Reason: CC References: Subject: [Bug fortran/42568] [Cygwin] BLOCKDATA referenced in EXTERNAL not loading from library In-Reply-To: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "ian at airs dot com" Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2010-01/txt/msg00547.txt.bz2 ------- 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