This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: linking .common and .weak definitions
- From: Richard Earnshaw <rearnsha at arm dot com>
- To: Alan Modra <amodra at bigpond dot net dot au>
- Cc: Richard dot Earnshaw at arm dot com, gcc at gcc dot gnu dot org
- Date: Tue, 11 Feb 2003 09:43:25 +0000
- Subject: Re: linking .common and .weak definitions
- Organization: ARM Ltd.
- Reply-to: Richard dot Earnshaw at arm dot com
> bfd/elflink.h has this to say:
>
> We treat a common symbol as a definition if the symbol in the
> shared library is a function, since common symbols always
> represent variables; this can cause confusion in principle, but
> any such confusion would seem to indicate an erroneous program or
> shared library. We also permit a common symbol in a regular
> object to override a weak symbol in a shared object.
>
> I'm curious as to why this code isn't working for you.
Hmm, well the executable does work; but because the linker has issued a
diagnostic the test is marked as failing to compile, so we never try to
run it.
$ gcc test.c
/var/tmp/ccyt36B0.o: In function `main':
/var/tmp/ccyt36B0.o(.text+0x20): warning: reference to compatibility
glob(); include <glob.h> for correct reference
I'm happy if that's the way we want .weak and .common to combine, but I
don't think the warning should be triggered in that case.
The warning is generated with the following:
#define __warn_references(sym,msg) \
__asm__(".section .gnu.warning." #sym " ; .ascii \"" msg "\" ; .text");
__warn_references(glob, "warning: reference to compatibility glob();
include <glob.h> for correct reference")
R.