bug-binutils
[Top][All Lists]
Advanced

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

[Bug ld/19372] both ld.bfd and ld.gold + --as-needed does not link libra


From: patrakov at gmail dot com
Subject: [Bug ld/19372] both ld.bfd and ld.gold + --as-needed does not link libraries with __init functions
Date: Tue, 22 Dec 2015 16:51:22 +0000

https://sourceware.org/bugzilla/show_bug.cgi?id=19372

Alexander E. Patrakov <patrakov at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |patrakov at gmail dot com

--- Comment #1 from Alexander E. Patrakov <patrakov at gmail dot com> ---
Well, I expect that, for completeness and consistency, the reporter wants this
not only for __init, but also for all functions with
__attribute__((constructor)).

The primary use case of --as-needed in distributions is to hide a common
upstream bug in applications, where they create useless DT_NEEDED entries by
needlessly (on ELF platforms at least) listing dependencies of their
dependencies on the ld command line. I.e. to save on rebuilds due to ABI
changes by eliminating genuinely useless dependencies. That's why some
distributions (including Ubuntu and Gentoo) use this flag by default.

Anyway, implementing the desired behavior would mean some degree of guessing of
the user's intention. How could ld know, under this mindset, that it is the
developer's genuine desire to call the constructors only, and nothing else from
this library? I.e. how could ld know that it is not just a library that is only
a dependency of a dependency, that should be in fact eliminated? I.e. the
proposal errs on the safe side of not eliminating some possibly-useless
DT_NEEDED entries.

What worries me is whether the proposal is implementable. We have this text in
"man ld":

       --warn-constructors
           Warn if any global constructors are used.  This is only useful for a
few object file formats.  For formats like COFF or ELF, the linker can not
detect the use of global constructors.

-- 
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]