PROVIDE in linker script broken for expressions with more than two references

Robert Norton rnorton@broadcom.com
Wed Sep 24 11:54:00 GMT 2008


Hi,

There seems to be a bug in the way that ld handles PROVIDE. If there are more than two symbols referenced in an expression which are defined using PROVIDE then the third is erroneously flagged as undefined. For example:

$ cat > test.ld
SECTIONS
{
PROVIDE(a = 1);
PROVIDE(b = 2);
PROVIDE(c = 4);
foo = a + b + c;
}
$ cat > test.c
int main(void)
{
  return 0;
}
$ gcc test.ld test.c
/usr/lib/../lib64/libc.so:6: undefined symbol `c' referenced in expression
collect2: ld returned 1 exit status

If any one of a, b or c is defined without using PROVIDE or if the expression for foo references only two of a, b and c then it works as expected. This was tested using binutils 2.18 and using latest HEAD build.

Has anyone experienced this bug before? Does anyone familiar with ldexp.c know why this might be the case? I'm guessing some sort of problem with the recursion in ldexp.c but I don't understand it enough yet.

Many thanks,

Robert



More information about the Binutils mailing list