http://sourceware.org/bugzilla/show_bug.cgi?id=14322

             Bug #: 14322
           Summary: Linker fails to properly handle __start_SECNAME symbol
           Product: binutils
           Version: 2.23 (HEAD)
            Status: NEW
          Severity: normal
          Priority: P2
         Component: ld
        AssignedTo: unassig...@sourceware.org
        ReportedBy: hjl.to...@gmail.com
    Classification: Unclassified


[hjl@gnu-6 xxx]$ cat x.c
#include <stdio.h>

extern char *bar ();
extern char __start__data_foo;

int
main ()
{
  char *p = bar ();
  printf ("%p: %p\n", &__start__data_foo, p);
  return 0;
}
[hjl@gnu-6 xxx]$ cat foo.c
#include <stdio.h>

#if 1
int foo __attribute__ ((section ("_data_foo"))) = 0;
extern char __start__data_foo;
#else
char __start__data_foo = 30;
#endif

char *
bar ()
{
  char *p = &__start__data_foo;
  printf ("%p: %p\n", &__start__data_foo, p);
  return p;
}
[hjl@gnu-6 xxx]$ 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
0x7ffff7ffc9e0: 0x7ffff7ffc9e0
(nil): 0x7ffff7ffc9e0
[hjl@gnu-6 xxx]$ 

GCC should generate ".type __start__data_foo,%object" even if
__start__data_foo is undefined and linker should handle it more
gracefully.

-- 
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
bug-binutils@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-binutils

Reply via email to