linking .common and .weak definitions
Richard Earnshaw
rearnsha@arm.com
Mon Feb 10 15:19:00 GMT 2003
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.
More information about the Gcc
mailing list