[Top][All Lists]

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

[Bug gold/15478] -no-as-needed required to avoid runtime symbol lookup e

From: sparkprime at gmail dot com
Subject: [Bug gold/15478] -no-as-needed required to avoid runtime symbol lookup error
Date: Sun, 19 May 2013 23:26:42 +0000


--- Comment #8 from Dave Cunningham <sparkprime at gmail dot com> 2013-05-19 
23:26:42 UTC ---
There doesn't seem to be any relationship between --allow-shlib-undefined and

There is no undefined symbol in the link job, everything is satisfied by the
libraries on the commandline and gold does not complain about any undefined
symbol.  The problem is that gold decides not to add DT_NEEDED for one of the
libraries because it wrongly believes that it does not need to.  This yields an
error when the generated binary is executed and the symbols are resolved at
runtime (unless one uses LD_PRELOAD to add the library that gold missed out).

Turning off --as-needed seems to be a fine workaround (gcc adds it by default,
which is half the problem).

If you plan to only support a weaker version of --as-needed than is supported
in the previous binutils, I think it would be appropriate to rename the
commandline parameter to avoid compatability issues.  At least change the
documentation to be more specific about what 'needed' means in this version
compared to previously.  However, I don't think you have any compelling reason
to ignore symbols in the .so files on the commandline, so the easiest option is
to be backwards-compatible.

Here is the documentation from older binutils which talks about --as-needed
interpreting undefined symbols both .o and .so files:

           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 or not.  --as-needed causes a DT_NEEDED
           tag to only be emitted for a library that
           satisfies an undefined symbol reference from a
           regular object file or, if the library is not
           found in the DT_NEEDED lists of other libraries
           linked up to that point, an undefined symbol
           reference from another dynamic library.
           --no-as-needed restores the default behaviour.

The gold documentation is very ambiguous:

              Only set DT_NEEDED for shared libraries if used

Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.

reply via email to

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