This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]