weak references not working right

Weak references, via the __weakref__ attribute do not work correctly,
the example code

#include <stdio.h>

void my_foo(void) __attribute__((__weakref__("foo")));

int
main(int ac, char *av[])
{
printf("my_foo %p\n", my_foo);

if (my_foo != NULL)
my_foo();

return 0;
}

shows the problem, when compiled with pcc results in undefined references to "foo"
what should happen I think, is that the assembler output references "my_foo" and a

.weakref my_foo,foo

line is emitted, this allows the linker to decide if foo can be resolved, or if it should
supply a nil value..

Description

Weak references, via the __weakref__ attribute do not work correctly,
the example code
#include <stdio.h>
void my_foo(void) __attribute__((__weakref__("foo")));
int
main(int ac, char *av[])
{
printf("my_foo %p\n", my_foo);
if (my_foo != NULL)
my_foo();
return 0;
}
shows the problem, when compiled with pcc results in undefined references to "foo"
what should happen I think, is that the assembler output references "my_foo" and a
.weakref my_foo,foo
line is emitted, this allows the linker to decide if foo can be resolved, or if it should
supply a nil value..

Anders Magnusson added a comment - 25/Jun/11 04:12 PM weakref is not supported except for recent binutils. I have some support for it in pcc, but it should probably be checked in configure whether it exist or not.