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: weakref and static


On Dec 11, 2005, Alexandre Oliva <aoliva@redhat.com> wrote:

> On Dec  1, 2005, gkeating@apple.com (Geoffrey Keating) wrote:

>> The easiest solution to this is to require that weakrefs must be
>> 'static', because the name that they define is not visible outside
>> this translation unit.

> While this is true, not all properties of static names hold for
> weakrefs.  If the name they refer to is not itself static, none of the
> local-binding analysis properties will apply correctly if the wekaref
> is marked as static.  I felt it was safer to keep it extern.

As evidenced by the following testcase:

extern int i;
static int j __attribute__((weakref("i")));
int f() {
  return j;
}

whose output assembly for AMD64 is:
[...]
        movl    j(%rip), %eax
[...]
        .weakref        j,i
[...]

So you see, j(%rip) is only valid when a symbol is known to be defined
in the same loadable module, but this is definitely not known for the
testcase above.

I thus propose your change to be reverted, and request you to explain
what you were trying to fix with this patch so that I can try to do
something about it.

-- 
Alexandre Oliva         http://www.lsd.ic.unicamp.br/~oliva/
Red Hat Compiler Engineer   aoliva@{redhat.com, gcc.gnu.org}
Free Software Evangelist  oliva@{lsd.ic.unicamp.br, gnu.org}


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