ASSERT refers to PROVIDEd symbols
Ben Elliston
bje@redhat.com
Tue May 7 14:18:00 GMT 2002
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
More information about the Binutils
mailing list