This is the mail archive of the
binutils@sourceware.cygnus.com
mailing list for the binutils project.
ld and common symbols
- To: binutils at sourceware dot cygnus dot com
- Subject: ld and common symbols
- From: Philip Blundell <Philip dot Blundell at pobox dot com>
- Date: Tue, 21 Dec 1999 21:19:46 +0000
Using the latest binutils from CVS I am seeing what seems to be a change in
behaviour relating to ld and common symbols.
With a test like this:
$ cat >t1.c
int foo; /* common */
int bar = 1; /* initialised */
^D
$ cat >t2.c
int foo = 1; /* initialised */
int bar = 1; /* initialised */
^D
$ gcc -c t1.c
$ gcc -c t2.c
$ ar cq t.a t2.o
$ ld t1.o t.a
older versions of the linker seemed to be content with the common declaration
of `foo' in t1.o. The current linker instead favours pulling in the archive
member in order to get an initialised definition of `foo'. In this case that
causes `bar' to be multiply defined and so you get a link error.
This patch seems a likely candidate for having caused the change, though I
haven't verified that this is the case.
1999-12-10 Nick Clifton <nickc@cygnus.com>
* elflink.h (elf_link_is_defined_archive_symbol): New
function: Decide if a symbol, in an archive map is there
because it is defined in the archive element, or because it is
just another common declaration of it.
(elf_link_add_archive_symbols): Use
elf_link_is_defined_archive_symbol to decide if an archive
element contain a reference to a common symbol should be
linked in or not.
Can anybody explain whether the "new" behaviour is intentional or accidental?
Thanks
p.