This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: linking .common and .weak definitions


> 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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]