bug-binutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug ld/14323] New: Linker fails to handle weak alias with __start_SECNA


From: hjl.tools at gmail dot com
Subject: [Bug ld/14323] New: Linker fails to handle weak alias with __start_SECNAME symbol
Date: Mon, 02 Jul 2012 19:39:19 +0000

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: address@hidden
        ReportedBy: address@hidden
    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

address@hidden 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;
}
address@hidden 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;
}
address@hidden 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
address@hidden 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.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]