This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
PROVIDE in linker script broken for expressions with more than two references
- From: "Robert Norton" <rnorton at broadcom dot com>
- To: binutils <binutils at sources dot redhat dot com>
- Date: Wed, 24 Sep 2008 04:54:01 -0700
- Subject: PROVIDE in linker script broken for expressions with more than two references
- Accept-language: en-US
- Acceptlanguage: en-US
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