This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
linking .common and .weak definitions
- From: Richard Earnshaw <rearnsha at arm dot com>
- To: gcc at gcc dot gnu dot org
- Cc: Richard dot Earnshaw at arm dot com
- Date: Mon, 10 Feb 2003 15:18:15 +0000
- Subject: linking .common and .weak definitions
- Organization: ARM Ltd.
- Reply-to: Richard dot Earnshaw at arm dot com
Currently gcc.c-torture/execute/960218-1.c fails on arm-netbsdelf because
we get a warning from the linker about a "compatibility" glob()
definition. However, on reflection I'm not convinced that the test's
behaviour is well defined when compiling with -fcommon (the default). The
definition of 'glob' in the source is uninitialized, which leads to it
being output as a .common block.
A .common is a tentative definition with no contents, and similarly a
.weak is also a tentative definition with contents. In the absence of a
further strong definition it therefore does not seam unreasonable for the
linker to try to combine these two. Do others agree?
If we accept that the test as it is currently specified is ill-defined,
then there are two options.
1) Always compile 960218-1.c with -fno-common
2) Ensure that glob is initialized so that it isn't give a .common
definition in the output file.
Comments?
R.