bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: --as-needed linker option causes trouble with -lreadline/-ltermcap


From: Bruno Haible
Subject: Re: --as-needed linker option causes trouble with -lreadline/-ltermcap
Date: Sun, 29 Mar 2009 08:11:36 +0100
User-agent: KMail/1.9.9

Ralf Wildenhues wrote:
> Anyway, I thought CVS binutils had a patch to deal with this setup,
> but reading the ld/NEWS entry, I'm not so sure anymore whether it
> is sufficient:
> 
>   * --as-needed now links in a dynamic library if it satisfies undefined
>     symbols in regular objects, or in other dynamic libraries.  In the
>     latter case the library is not linked if it is found in a DT_NEEDED
>     entry of one of the libraries already linked.

Yes, that's it. The doc of ld from version 2.16.1 to 2.19 says:

  `--as-needed'
  `--no-as-needed'
       This option affects ELF DT_NEEDED tags for dynamic libraries
       mentioned on the command line after the `--as-needed' option.
       Normally, the linker will add a DT_NEEDED tag for each dynamic
       library mentioned on the command line, regardless of whether the
       library is actually needed.  `--as-needed' 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.

It is the restriction to "regular objects" which makes ld answer the
question "Should a dependency to libtermcap be included?" with "no".

In CVS binutils, the last sentence is augmented:

                                    `--as-needed' 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, or, if the library is not found in
       the DT_NEEDED lists of other libraries linked up to that point,
       a reference from another dynamic library.

So, ld was enhanced to handle precisely the case with libncurses.

Bruno




reply via email to

[Prev in Thread] Current Thread [Next in Thread]