patches/binutils/2.20.1a/170-warn-textrel.patch
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Sat Dec 31 18:47:37 2011 +0100 (2011-12-31)
changeset 2829 0c3c95f911ec
parent 2088 4f21ba5f8e91
permissions -rw-r--r--
docs: credit Konrad EISELE for the initial multilib support

Konrad submitted an initial patch adding multlib support:
http://sourceware.org/ml/crossgcc/2011-11/msg00040.html

The patch was full of good ideas, but had a few issues, so
I (Yann E. MORIN) started it all from scatch, re-using part
of the original patch. This got implemented in this series:
hg log -r 446a17b5dd1e:e47d17391ae3

As I forgot to credit Konrad in these changelogs, update the
docs so that the work by Konrad gets credited. Without his
initial effort, we would probably not have had multlib support
so soon. Thank you Konrad!

Signed-off-by: "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
     1 textrels are bad for forcing copy-on-write (this affects everyone),
     2 and for security/runtime code generation, this affects security ppl.
     3 But in either case, it doesn't matter who needs textrels, it's
     4 the very fact that they're needed at all.
     5 
     6 2006-06-10  Ned Ludd  <solar@gentoo.org>, Mike Frysinger <vapier@gentoo.org>
     7 
     8 	* bfd/elflink.c (bfd_elf_final_link): Check all objects for TEXTRELs.
     9 	* ld/ldmain.c (main): Change textrel warning default to true.
    10 	* ld/testsuite/lib/ld-lib.exp (default_ld_simple_link): Scrub TEXTREL
    11 	warnings from ld output.
    12 
    13 diff -durN binutils-2.20.1.orig/bfd/elflink.c binutils-2.20.1/bfd/elflink.c
    14 --- binutils-2.20.1.orig/bfd/elflink.c	2010-08-17 19:32:11.000000000 +0200
    15 +++ binutils-2.20.1/bfd/elflink.c	2010-08-17 19:32:13.000000000 +0200
    16 @@ -10988,14 +10988,12 @@
    17  	goto error_return;
    18  
    19        /* Check for DT_TEXTREL (late, in case the backend removes it).  */
    20 -      if (info->warn_shared_textrel && info->shared)
    21 +      o = bfd_get_section_by_name (dynobj, ".dynamic");
    22 +      if (info->warn_shared_textrel && o != NULL)
    23  	{
    24  	  bfd_byte *dyncon, *dynconend;
    25  
    26  	  /* Fix up .dynamic entries.  */
    27 -	  o = bfd_get_section_by_name (dynobj, ".dynamic");
    28 -	  BFD_ASSERT (o != NULL);
    29 -
    30  	  dyncon = o->contents;
    31  	  dynconend = o->contents + o->size;
    32  	  for (; dyncon < dynconend; dyncon += bed->s->sizeof_dyn)
    33 @@ -11007,7 +11005,7 @@
    34  	      if (dyn.d_tag == DT_TEXTREL)
    35  		{
    36  		 info->callbacks->einfo
    37 -		    (_("%P: warning: creating a DT_TEXTREL in a shared object.\n"));
    38 +		    (_("%P: warning: creating a DT_TEXTREL in object.\n"));
    39  		  break;
    40  		}
    41  	    }
    42 diff -durN binutils-2.20.1.orig/ld/ldmain.c binutils-2.20.1/ld/ldmain.c
    43 --- binutils-2.20.1.orig/ld/ldmain.c	2009-09-14 13:43:29.000000000 +0200
    44 +++ binutils-2.20.1/ld/ldmain.c	2010-08-17 19:32:13.000000000 +0200
    45 @@ -280,6 +280,7 @@
    46    emulation = get_emulation (argc, argv);
    47    ldemul_choose_mode (emulation);
    48    default_target = ldemul_choose_target (argc, argv);
    49 +  link_info.warn_shared_textrel = TRUE;
    50    config.maxpagesize = bfd_emul_get_maxpagesize (default_target);
    51    config.commonpagesize = bfd_emul_get_commonpagesize (default_target);
    52    lang_init ();
    53 diff -durN binutils-2.20.1.orig/ld/testsuite/lib/ld-lib.exp binutils-2.20.1/ld/testsuite/lib/ld-lib.exp
    54 --- binutils-2.20.1.orig/ld/testsuite/lib/ld-lib.exp	2009-10-02 12:51:13.000000000 +0200
    55 +++ binutils-2.20.1/ld/testsuite/lib/ld-lib.exp	2010-08-17 19:32:13.000000000 +0200
    56 @@ -196,6 +196,10 @@
    57      # symbol, since the default linker script might use ENTRY.
    58      regsub -all "(^|\n)(\[^\n\]*: warning: cannot find entry symbol\[^\n\]*\n?)" $exec_output "\\1" exec_output
    59  
    60 +    # Gentoo tweak:
    61 +    # We want to ignore TEXTREL warnings since we force enable them by default
    62 +    regsub -all "^lt-ld-new: warning: creating a DT_TEXTREL in object\." $exec_output "\\1" exec_output
    63 +
    64      if [string match "" $exec_output] then {
    65  	return 1
    66      } else {