bug-gnu-utils
[Top][All Lists]
Advanced

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

Common symbols cause load from archive


From: Ian Dall
Subject: Common symbols cause load from archive
Date: Sat, 29 Jun 2002 00:13:13 +0930

When linked with

sibyl:-test $ pc532-netbsd-ld -V
GNU ld version 2.12.90 20020606
  Supported emulations:
   ns32knbsd

the following code from the gcc testsuite fails:

int glob;

g (x)
{
  glob = x;
  return 0;
}

f (x)
{
  int a = ~x;
  while (a)
    a = g (a);
}

main ()
{
  f (3);
  if (glob != -4)
    abort ();
  exit (0);
}

What happens is that "glob" is a common symbol after assembling, but
it causes glob.o to be loaded from libc.a, and then it gets resolved
to an address in the text segment and a core dump results when it is
assigned to.

Is this behaviour correct? It seems to be as documented except that I
think archives should probably only be searched to resolve undefined
variables, not common variables.

sibyl:-test $ pc532-netbsd-nm 960218-1.o | grep glob
00000004 C _glob
sibyl:-test $ pc532-netbsd-nm 960218-1 | grep glob
0000112c T ___do_global_ctors
00001100 T ___do_global_dtors
00001348 T _glob
00002268 T _globfree
00001348 t glob.o

Ian



reply via email to

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