This is the mail archive of the binutils@sourceware.org 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]

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


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


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