http://sourceware.org/bugzilla/show_bug.cgi?id=14323
Bug #: 14323
Summary: Linker fails to handle weak alias with __start_SECNAME
symbol
Product: binutils
Version: 2.23 (HEAD)
Status: NEW
Severity: normal
Priority: P2
Component: ld
AssignedTo: [email protected]
ReportedBy: [email protected]
Classification: Unclassified
When a __start_SECNAME symbol happens to have the same
value and section with a weak alias, linker doesn't set
up alias properly. On Linux/x86-64, I got
[hjl@gnu-6 alias-6]$ cat x.c
#include <stdlib.h>
#include <stdio.h>
extern int foo_alias;
extern int x1, x2;
extern char *bar ();
extern char __start__data_foo;
int
main ()
{
char *p = bar ();
printf ("%d\n", foo_alias);
printf ("%p: %p\n", &__start__data_foo, p);
printf ("%d\n", x1);
printf ("%d\n", x2);
if (foo_alias != -1)
abort ();
return 0;
}
[hjl@gnu-6 alias-6]$ cat foo.c
#include <stdio.h>
int foo __attribute__ ((section ("_data_foo"))) = 0;
extern int foo_alias __attribute__ ((weak, alias ("foo")));
extern char __start__data_foo;
int x1 = 1;
int x2 = 2;
char *
bar ()
{
char *p = &__start__data_foo;
printf ("foo before: %d\n", foo);
foo = -1;
printf ("foo after: %d\n", foo);
printf ("%p: %p\n", &__start__data_foo, p);
return p;
}
[hjl@gnu-6 alias-6]$ make
gcc -B./ -c -o x.o x.c
gcc -B./ -fPIC -c -o foo.o foo.c
gcc -B./ -shared -o libfoo.so foo.o
gcc -B./ -o x x.o libfoo.so -Wl,-rpath,.
./ld: warning: type and size of dynamic symbol `__start__data_foo' are not
defined
./x
foo before: 0
foo after: -1
0x600c0c: 0x600c0c
2
0x600c0c: 0x600c0c
1
2
make: *** [all] Aborted
[hjl@gnu-6 alias-6]$
--
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
_______________________________________________
bug-binutils mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/bug-binutils