This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
ASSERT refers to PROVIDEd symbols
- From: Ben Elliston <bje at redhat dot com>
- To: binutils at sources dot redhat dot com
- Date: Tue, 7 May 2002 17:18:56 -0400 (EDT)
- Subject: ASSERT refers to PROVIDEd symbols
The ld manual describes the behavior of the PROVIDE directive as
follows:
``In some cases, it is desirable for a linker script to define a symbol
only if it is referenced and is not defined by any object included in
the link.''
I have encountered a problem best described using the trivial test
case below:
PROVIDE (foo = 0);
PROVIDE (bar = foo);
Trying a number of different versions of ld over the last four years,
I consistently get the same error:
test.ld:3: undefined symbol `foo' referenced in expression
It seems that a reference in a linker script is treated differently to
a reference in an object file. Thus, the reference to foo in "bar =
foo" does not trigger the PROVIDE above it for foo. This is an
annoyance because it makes the ASSERT directive much less useful if
the assertion wishes to refer to a symbol that may or may not exist in
the input object file(s).
Is what I am trying to do outside of ld's current capabilities?
Ben