public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* --as-needed handling of shared libraries that fail -Wl,-z,defs
@ 2005-05-19 16:43 Jakub Jelinek
  2005-05-20 10:02 ` Alan Modra
  2005-05-20 19:02 ` Mike Hearn
  0 siblings, 2 replies; 5+ messages in thread
From: Jakub Jelinek @ 2005-05-19 16:43 UTC (permalink / raw)
  To: binutils

Hi!

--as-needed doesn't seem to try satisfy undefined references in shared
libraries:

ldd -d -r /usr/lib64/libreadline.so.4
undefined symbol: BC    (/usr/lib64/libreadline.so.4)
undefined symbol: PC    (/usr/lib64/libreadline.so.4)
undefined symbol: UP    (/usr/lib64/libreadline.so.4)
undefined symbol: tgetnum       (/usr/lib64/libreadline.so.4)
undefined symbol: tgoto (/usr/lib64/libreadline.so.4)
undefined symbol: tgetflag      (/usr/lib64/libreadline.so.4)
undefined symbol: tputs (/usr/lib64/libreadline.so.4)
undefined symbol: tgetent       (/usr/lib64/libreadline.so.4)
undefined symbol: tgetstr       (/usr/lib64/libreadline.so.4)
        libc.so.6 => /lib64/libc.so.6 (0x0000003a33900000)
        /lib64/ld-linux-x86-64.so.2 (0x0000555555555000)
echo 'int main (void) { return 0; }' | gcc -xc - -o test -lreadline -Wl,--as-needed -ltermcap -Wl,--no-as-needed; ./test
./test: symbol lookup error: /usr/lib64/libreadline.so.4: undefined symbol: BC

Is this desirable or should we change --as-needed to attempt to satisfy even
those?  Particularly for -lreadline, it makes sense to not depend on
libtermcap resp. libncurses, as those symbols can be provided by either
of those libraries and some applications prefer one over the other and vice
versa.

	Jakub

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: --as-needed handling of shared libraries that fail -Wl,-z,defs
  2005-05-19 16:43 --as-needed handling of shared libraries that fail -Wl,-z,defs Jakub Jelinek
@ 2005-05-20 10:02 ` Alan Modra
  2005-05-20 11:31   ` Jakub Jelinek
  2005-05-20 19:02 ` Mike Hearn
  1 sibling, 1 reply; 5+ messages in thread
From: Alan Modra @ 2005-05-20 10:02 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: binutils

On Thu, May 19, 2005 at 06:37:16PM +0200, Jakub Jelinek wrote:
> --as-needed doesn't seem to try satisfy undefined references in shared
> libraries:

No, as the ld doc says it "causes DT_NEEDED tags to only be emitted
for libraries that satisfy some symbol reference from regular objects
which is undefined at the point that the library was linked."

Note the "regular objects".  I'm not sure now why I wrote it that way.
It would be trivial to change, but I'd suggest using another option to
control behaviour.

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: --as-needed handling of shared libraries that fail -Wl,-z,defs
  2005-05-20 10:02 ` Alan Modra
@ 2005-05-20 11:31   ` Jakub Jelinek
  2005-05-20 13:52     ` Alan Modra
  0 siblings, 1 reply; 5+ messages in thread
From: Jakub Jelinek @ 2005-05-20 11:31 UTC (permalink / raw)
  To: binutils

On Fri, May 20, 2005 at 07:23:49PM +0930, Alan Modra wrote:
> On Thu, May 19, 2005 at 06:37:16PM +0200, Jakub Jelinek wrote:
> > --as-needed doesn't seem to try satisfy undefined references in shared
> > libraries:
> 
> No, as the ld doc says it "causes DT_NEEDED tags to only be emitted
> for libraries that satisfy some symbol reference from regular objects
> which is undefined at the point that the library was linked."

Ok, fine, no problem with that.  But in that case we should issue
an error about unsatisfied references.

gcc -o /tmp/nothing{,.c} -Wl,-u,readline -lreadline
/usr/lib/gcc/x86_64-redhat-linux/3.4.3/../../../../lib64/libreadline.so: undefined reference to `tgetnum'
/usr/lib/gcc/x86_64-redhat-linux/3.4.3/../../../../lib64/libreadline.so: undefined reference to `tgoto'
/usr/lib/gcc/x86_64-redhat-linux/3.4.3/../../../../lib64/libreadline.so: undefined reference to `tgetflag'
/usr/lib/gcc/x86_64-redhat-linux/3.4.3/../../../../lib64/libreadline.so: undefined reference to `BC'
/usr/lib/gcc/x86_64-redhat-linux/3.4.3/../../../../lib64/libreadline.so: undefined reference to `tputs'
/usr/lib/gcc/x86_64-redhat-linux/3.4.3/../../../../lib64/libreadline.so: undefined reference to `PC'
/usr/lib/gcc/x86_64-redhat-linux/3.4.3/../../../../lib64/libreadline.so: undefined reference to `tgetent'
/usr/lib/gcc/x86_64-redhat-linux/3.4.3/../../../../lib64/libreadline.so: undefined reference to `UP'
/usr/lib/gcc/x86_64-redhat-linux/3.4.3/../../../../lib64/libreadline.so: undefined reference to `tgetstr'
collect2: ld returned 1 exit status

gcc -o /tmp/nothing{,.c} -Wl,-u,readline -lreadline -Wl,--as-needed -ltermcap -Wl,--no-as-needed; /tmp/nothing
/tmp/nothing: symbol lookup error: /usr/lib64/libreadline.so.4: undefined symbol: BC

	Jakub

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: --as-needed handling of shared libraries that fail -Wl,-z,defs
  2005-05-20 11:31   ` Jakub Jelinek
@ 2005-05-20 13:52     ` Alan Modra
  0 siblings, 0 replies; 5+ messages in thread
From: Alan Modra @ 2005-05-20 13:52 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: binutils

On Fri, May 20, 2005 at 12:02:25PM +0200, Jakub Jelinek wrote:
> On Fri, May 20, 2005 at 07:23:49PM +0930, Alan Modra wrote:
> > On Thu, May 19, 2005 at 06:37:16PM +0200, Jakub Jelinek wrote:
> > > --as-needed doesn't seem to try satisfy undefined references in shared
> > > libraries:
> > 
> > No, as the ld doc says it "causes DT_NEEDED tags to only be emitted
> > for libraries that satisfy some symbol reference from regular objects
> > which is undefined at the point that the library was linked."
> 
> Ok, fine, no problem with that.  But in that case we should issue
> an error about unsatisfied references.

Yes.  The code needs rewriting to do that.  The trouble is that the
symbol table state isn't restored back to what is was before loading the
as-needed lib.  See the comment above elflink.c:elf_smash_syms.

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: --as-needed handling of shared libraries that fail -Wl,-z,defs
  2005-05-19 16:43 --as-needed handling of shared libraries that fail -Wl,-z,defs Jakub Jelinek
  2005-05-20 10:02 ` Alan Modra
@ 2005-05-20 19:02 ` Mike Hearn
  1 sibling, 0 replies; 5+ messages in thread
From: Mike Hearn @ 2005-05-20 19:02 UTC (permalink / raw)
  To: binutils

On Thu, 19 May 2005 18:37:16 +0200, Jakub Jelinek wrote:
> --as-needed doesn't seem to try satisfy undefined references in shared
> libraries:

I thought this error meant that libreadline was built incorrectly. It
needs symbols from libtermcap but has no DT_NEEDED entry for it - isn't
this a mistake in the libreadline build system?

thanks -mike

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2005-05-20 15:34 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-05-19 16:43 --as-needed handling of shared libraries that fail -Wl,-z,defs Jakub Jelinek
2005-05-20 10:02 ` Alan Modra
2005-05-20 11:31   ` Jakub Jelinek
2005-05-20 13:52     ` Alan Modra
2005-05-20 19:02 ` Mike Hearn

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).