Changed behaviour of --as-needed

Andreas Schwab schwab@suse.de
Mon Mar 27 16:48:00 GMT 2006
Given the following files:

$ cat liba.c
extern double log (double);

int a (double b) { return log (b); }
$ cat main.c
extern int a (double);

int main (void)
{
  a (1.0);
  return 0;
}
$ gcc -o liba.so -shared liba.c

Note that liba.so is not linked against -lm.  Now when trying to link them
together while using --as-needed, I get an undefined references:

$ gcc main.o liba.so -Wl,-as-needed -lm
liba.so: undefined reference to `log'

This is a side effect of the patch for PR 2434.  Is this the intended
behaviour?

Andreas.

-- 
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany
PGP key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."



More information about the Binutils mailing list