patches/binutils/2.19/150-warn-textrel.patch
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Sun Sep 12 23:51:25 2010 +0200 (2010-09-12)
changeset 2123 ff2181adbd28
permissions -rw-r--r--
cc/gcc: disable complibs if not selected

Force gcc to not link with some companion libraries when
there are not needed (because selected-out).

There is no option to tell gcc *not* to build the Graphite and/or
LTO stuff. They *will* be built if gcc finds the suitable companion
libraries. If we do not provide them, but the host has them, then
gcc *will* find them, and link with them.

Consider the following:
- host has suitable PPL and CLooG (eg. Debian Squeeze)
- user wants to build gcc>=4.4
- user de-selects GRAPHITE
- gcc will find the hosts PPL and CLooG, and will use them
- the user moves the toolchain to an older host that does
not have them (eg. Debian Lenny)
- the toolchain fails, when it was properly setup not to

So, explicitly tell gcc *not* to use unneeded companion libs.

Signed-off-by: "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
     1 Original patch from Gentoo:
     2 gentoo/src/patchsets/binutils/2.19/66_all_binutils-2.18.50.0.2-warn-textrel.patch
     3 
     4 textrels are bad for forcing copy-on-write (this affects everyone),
     5 and for security/runtime code generation, this affects security ppl.
     6 But in either case, it doesn't matter who needs textrels, it's
     7 the very fact that they're needed at all.
     8 
     9 diff -durN binutils-2.19.orig/bfd/elflink.c binutils-2.19/bfd/elflink.c
    10 --- binutils-2.19.orig/bfd/elflink.c	2008-11-23 16:49:47.000000000 +0100
    11 +++ binutils-2.19/bfd/elflink.c	2008-11-23 16:49:14.000000000 +0100
    12 @@ -10820,14 +10820,12 @@
    13  	goto error_return;
    14  
    15        /* Check for DT_TEXTREL (late, in case the backend removes it).  */
    16 -      if (info->warn_shared_textrel && info->shared)
    17 +      o = bfd_get_section_by_name (dynobj, ".dynamic");
    18 +      if (info->warn_shared_textrel && o != NULL)
    19  	{
    20  	  bfd_byte *dyncon, *dynconend;
    21  
    22  	  /* Fix up .dynamic entries.  */
    23 -	  o = bfd_get_section_by_name (dynobj, ".dynamic");
    24 -	  BFD_ASSERT (o != NULL);
    25 -
    26  	  dyncon = o->contents;
    27  	  dynconend = o->contents + o->size;
    28  	  for (; dyncon < dynconend; dyncon += bed->s->sizeof_dyn)
    29 @@ -10839,7 +10837,7 @@
    30  	      if (dyn.d_tag == DT_TEXTREL)
    31  		{
    32  		 info->callbacks->einfo
    33 -		    (_("%P: warning: creating a DT_TEXTREL in a shared object.\n"));
    34 +		    (_("%P: warning: creating a DT_TEXTREL in object.\n"));
    35  		  break;
    36  		}
    37  	    }
    38 diff -durN binutils-2.19.orig/ld/ldmain.c binutils-2.19/ld/ldmain.c
    39 --- binutils-2.19.orig/ld/ldmain.c	2008-08-17 05:12:50.000000000 +0200
    40 +++ binutils-2.19/ld/ldmain.c	2008-11-23 16:52:37.000000000 +0100
    41 @@ -274,6 +274,7 @@
    42    link_info.relax_pass = 1;
    43    link_info.pei386_auto_import = -1;
    44    link_info.spare_dynamic_tags = 5;
    45 +  link_info.warn_shared_textrel = TRUE;
    46    link_info.path_separator = ':';
    47  
    48    ldfile_add_arch ("");