Make no-copy-dt-needed default?

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Make no-copy-dt-needed default?

Michael Matz
Hello,

what do people think about switching the default for
add_DT_NEEDED_for_dynamic to false, i.e. make --no-copy-dt-needed-entries
the default for GNU ld?

The linux distros Fedora, Debian and Ubuntu already do that with local
patches, openSUSE is going to follow suit, and AFAIK gold has the same
behaviour (without the possibility to change it).  It potentially can
cause some minor hickups with current build systems, exactly in those
cases where people relied on other libraries being included via recursive
DT_NEEDED instead of listing the dependencies in the link editing command,
i.e. in cases that would break already right now with static archives.

As Fedora and Debian are using this switched default already for some
time I'd expect most projects with an active upstream would be fixed
meanwhile.  A good summary of what exactly is implied by such a change is
e.g. at http://fedoraproject.org/wiki/UnderstandingDSOLinkChange .

I realize that just because some random linux distros are doing something
shouldn't necessarily imply a change in upstream binutils, but in this
case I think it makes sense.

So, should I propose a patch?


Ciao,
Michael.
Reply | Threaded
Open this post in threaded view
|

Re: Make no-copy-dt-needed default?

Ian Lance Taylor-3
Michael Matz <[hidden email]> writes:

> what do people think about switching the default for
> add_DT_NEEDED_for_dynamic to false, i.e. make --no-copy-dt-needed-entries
> the default for GNU ld?
>
> The linux distros Fedora, Debian and Ubuntu already do that with local
> patches, openSUSE is going to follow suit, and AFAIK gold has the same
> behaviour (without the possibility to change it).  It potentially can
> cause some minor hickups with current build systems, exactly in those
> cases where people relied on other libraries being included via recursive
> DT_NEEDED instead of listing the dependencies in the link editing command,
> i.e. in cases that would break already right now with static archives.
>
> As Fedora and Debian are using this switched default already for some
> time I'd expect most projects with an active upstream would be fixed
> meanwhile.  A good summary of what exactly is implied by such a change is
> e.g. at http://fedoraproject.org/wiki/UnderstandingDSOLinkChange .
>
> I realize that just because some random linux distros are doing something
> shouldn't necessarily imply a change in upstream binutils, but in this
> case I think it makes sense.
>
> So, should I propose a patch?


Obviously I think it makes sense.

Ian
Reply | Threaded
Open this post in threaded view
|

Re: Make no-copy-dt-needed default?

Michael Matz
Hi,

On Tue, 16 Aug 2011, Ian Lance Taylor wrote:

> > So, should I propose a patch?
>
> Obviously I think it makes sense.

Something like this then (no regressions on x86_64-linux).


Ciao,
Michael.
--
        * ldmain.c (add_DT_NEEDED_for_dynamic): Default to FALSE.
        * ld.texinfo (--copy-dt-needed-entries): Mention new default.

Index: ld.texinfo
===================================================================
RCS file: /cvs/src/src/ld/ld.texinfo,v
retrieving revision 1.279
diff -u -p -r1.279 ld.texinfo
--- ld.texinfo 9 Aug 2011 13:10:44 -0000 1.279
+++ ld.texinfo 16 Aug 2011 15:58:50 -0000
@@ -1258,21 +1258,20 @@ option.
 @itemx --no-copy-dt-needed-entries
 This option affects the treatment of dynamic libraries referred to
 by DT_NEEDED tags @emph{inside} ELF dynamic libraries mentioned on the
-command line.  Normally the linker will add a DT_NEEDED tag to the
+command line.  Normally the linker won't add a DT_NEEDED tag to the
 output binary for each library mentioned in a DT_NEEDED tag in an
-input dynamic library.  With @option{--no-copy-dt-needed-entries}
+input dynamic library.  With @option{--copy-dt-needed-entries}
 specified on the command line however any dynamic libraries that
-follow it will have their DT_NEEDED entries ignored.  The default
-behaviour can be restored with @option{--copy-dt-needed-entries}.
+follow it will have their DT_NEEDED entries added.  The default
+behaviour can be restored with @option{--no-copy-dt-needed-entries}.
 
 This option also has an effect on the resolution of symbols in dynamic
-libraries.  With the default setting dynamic libraries mentioned on
-the command line will be recursively searched, following their
-DT_NEEDED tags to other libraries, in order to resolve symbols
-required by the output binary.  With
-@option{--no-copy-dt-needed-entries} specified however the searching
-of dynamic libraries that follow it will stop with the dynamic
-library itself.  No DT_NEEDED links will be traversed to resolve
+libraries.  With @option{--copy-dt-needed-entries} dynamic libraries
+mentioned on the command line will be recursively searched, following
+their DT_NEEDED tags to other libraries, in order to resolve symbols
+required by the output binary.  With the default setting however
+the searching of dynamic libraries that follow it will stop with the
+dynamic library itself.  No DT_NEEDED links will be traversed to resolve
 symbols.
 
 @cindex cross reference table
Index: ldmain.c
===================================================================
RCS file: /cvs/src/src/ld/ldmain.c,v
retrieving revision 1.158
diff -u -p -r1.158 ldmain.c
--- ldmain.c 4 Aug 2011 20:47:46 -0000 1.158
+++ ldmain.c 16 Aug 2011 15:58:50 -0000
@@ -105,7 +105,7 @@ bfd_boolean add_DT_NEEDED_for_regular;
 /* True means create DT_NEEDED entries for dynamic libraries that
    are DT_NEEDED by dynamic libraries specifically mentioned on
    the command line.  */
-bfd_boolean add_DT_NEEDED_for_dynamic = TRUE;
+bfd_boolean add_DT_NEEDED_for_dynamic;
 
 /* TRUE if we should demangle symbol names.  */
 bfd_boolean demangling;
Reply | Threaded
Open this post in threaded view
|

Re: Make no-copy-dt-needed default?

Matthias Klose-6
On 08/16/2011 06:01 PM, Michael Matz wrote:
> Hi,
>
> On Tue, 16 Aug 2011, Ian Lance Taylor wrote:
>
>>> So, should I propose a patch?
>>
>> Obviously I think it makes sense.
>
> Something like this then (no regressions on x86_64-linux).

I didn't use a *ix platform other than Linux for a long time, but maybe limit
this change to Linux at first?

  Matthias
Reply | Threaded
Open this post in threaded view
|

Re: Make no-copy-dt-needed default?

Ian Lance Taylor-3
Matthias Klose <[hidden email]> writes:

> On 08/16/2011 06:01 PM, Michael Matz wrote:
>> Hi,
>>
>> On Tue, 16 Aug 2011, Ian Lance Taylor wrote:
>>
>>>> So, should I propose a patch?
>>>
>>> Obviously I think it makes sense.
>>
>> Something like this then (no regressions on x86_64-linux).
>
> I didn't use a *ix platform other than Linux for a long time, but maybe limit
> this change to Linux at first?

Why?  No other ELF linker behaves as GNU ld currently does.

(I should say that I will leave actual approval of the patch to one of
the more active binutils maintainers.)

Ian
Reply | Threaded
Open this post in threaded view
|

Re: Make no-copy-dt-needed default?

Nick Clifton
In reply to this post by Michael Matz
Hi Michael,


> * ldmain.c (add_DT_NEEDED_for_dynamic): Default to FALSE.
> * ld.texinfo (--copy-dt-needed-entries): Mention new default.

Approved - please apply.

If anyone complains then on my head be it.

Cheers
   Nick
Reply | Threaded
Open this post in threaded view
|

Re: Make no-copy-dt-needed default?

Ralf Wildenhues
In reply to this post by Michael Matz
* Michael Matz wrote on Tue, Aug 16, 2011 at 06:01:34PM CEST:
> * ldmain.c (add_DT_NEEDED_for_dynamic): Default to FALSE.
> * ld.texinfo (--copy-dt-needed-entries): Mention new default.

Could this be mentioned in NEWS too, please?

Thanks,
Ralf
Reply | Threaded
Open this post in threaded view
|

Re: Make no-copy-dt-needed default?

Nick Clifton
Hi Ralf,

> * Michael Matz wrote on Tue, Aug 16, 2011 at 06:01:34PM CEST:
>> * ldmain.c (add_DT_NEEDED_for_dynamic): Default to FALSE.
>> * ld.texinfo (--copy-dt-needed-entries): Mention new default.
>
> Could this be mentioned in NEWS too, please?

Thanks for catching this.  I have checked in the patch below.

Cheers
   Nick

ld/ChangeLog
2011-08-26  Nick Clifton  <[hidden email]>

        * NEWS: Mention that --no-copy-dt-needed-entries is now the
        default.

Index: ld/NEWS
===================================================================
RCS file: /cvs/src/src/ld/NEWS,v
retrieving revision 1.119
diff -u -3 -p -r1.119 NEWS
--- ld/NEWS     11 Jul 2011 15:03:09 -0000      1.119
+++ ld/NEWS     26 Aug 2011 12:46:39 -0000
@@ -1,5 +1,8 @@
  -*- text -*-

+* --copy-dt-needed-entries is no longer enabled by default.  Instead
+  --no-copy-dt-needed-entries is the default.
+
  * INPUT_SECTION_FLAGS has been added to the linker script language
  to allow selection of input sections by section header section flags.