patches/binutils/2.15.90.0.3/binutils-20040817-linkonce.patch
changeset 330 447b203edc2e
parent 329 419d959441ed
child 331 0c05f9ea3254
     1.1 --- a/patches/binutils/2.15.90.0.3/binutils-20040817-linkonce.patch	Tue Aug 14 19:32:22 2007 +0000
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,118 +0,0 @@
     1.4 -From http://sources.redhat.com/ml/binutils/2004-08/msg00190.html
     1.5 -
     1.6 -Date: Tue, 17 Aug 2004 12:04:29 +0200
     1.7 -From: Jakub Jelinek <jakub at redhat dot com>
     1.8 -To: binutils at sources dot redhat dot com
     1.9 -Subject: [PATCH] Fix `defined in discarded section' errors when building ia64 gcc
    1.10 -Message-ID: <20040817100429.GL30497@sunsite.ms.mff.cuni.cz>
    1.11 -Reply-To: Jakub Jelinek <jakub at redhat dot com>
    1.12 -References: <20040817090201.GK30497@sunsite.ms.mff.cuni.cz>
    1.13 -In-Reply-To: <20040817090201 dot GK30497 at sunsite dot ms dot mff dot cuni dot cz>
    1.14 -
    1.15 -On Tue, Aug 17, 2004 at 11:02:01AM +0200, Jakub Jelinek wrote:
    1.16 -> Current gcc 3.4.x (at least gcc-3_4-rhl-branch) doesn't build with CVS
    1.17 -> binutils (nor 2.15.91.0.2).
    1.18 -> The problem is that libstdc++.so linking fails with:
    1.19 -> `.gnu.linkonce.t._ZNSdD2Ev' referenced in section `.gnu.linkonce.ia64unw._ZNSdD2Ev' of .libs/sstream-inst.o: defined in discarded section `.gnu.linkonce.t._ZNSdD2Ev' of .libs/sstream-inst.o
    1.20 -> The problem is that both io-inst.s and sstream-inst.s have
    1.21 -> .gnu.linkonce.t._ZNSdD2Ev definition, but because io-inst.cc
    1.22 -> also instantiates some templates sstream-inst.cc doesn't instantiate,
    1.23 -> the inliner can do a better job in io-inst.cc.
    1.24 -> The result is that _ZNSdD2Ev in io-inst.cc is a leaf routine, while
    1.25 -> it is not in sstream-inst.cc (in assembly,
    1.26 -> _ZNSdD2Ev in io-inst.s starts with .prologue and no .save directives,
    1.27 -> while _ZNSdD2Ev] in sstream-inst.s has .prologue 12, 35 and some
    1.28 -> .save directives.
    1.29 -> IA-64 ABI allows leaf routines to have no unwind section at all,
    1.30 -> which means .gnu.linkonce.ia64unw._ZNSdD2Ev is not created in
    1.31 -> io-inst.o at all and as .gnu.linkonce.t._ZNSdD2Ev comes first
    1.32 -> and wins, .gnu.linkonce.ia64unw._ZNSdD2Ev in sstream.o suddenly
    1.33 -> references a discarded section.
    1.34 -> 
    1.35 -> Not sure what should be done here, but certainly the compiler
    1.36 -> isn't at fault here, it is a binutils problem.
    1.37 -> One fix could be to create empty .gnu.linkonce.ia64unw.* section
    1.38 -> in assembler, another special case ia64 unwind sections in the linker.
    1.39 -
    1.40 -Here is a patch for the first possibility.
    1.41 -It certainly makes libstdc++.so to link and even the unwind info looks
    1.42 -good on brief skimming.
    1.43 -
    1.44 -2004-08-17  Jakub Jelinek  <jakub@redhat.com>
    1.45 -
    1.46 -	* config/tc-ia64.c (start_unwind_section): Add linkonce_empty
    1.47 -	argument, don't do anything if current section is not
    1.48 -	.gnu.linkonce.t.* and linkonce_empty is set.
    1.49 -	(generate_unwind_image, dot_endp): Adjust callers, call
    1.50 -	start_unwind_section (*, 1) if nothing will be put into the
    1.51 -	section.
    1.52 -
    1.53 ---- binutils/gas/config/tc-ia64.c.jj	2004-07-30 11:42:24.000000000 +0200
    1.54 -+++ binutils/gas/config/tc-ia64.c	2004-08-17 13:45:04.288173205 +0200
    1.55 -@@ -1,5 +1,6 @@
    1.56 - /* tc-ia64.c -- Assembler for the HP/Intel IA-64 architecture.
    1.57 --   Copyright 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
    1.58 -+   Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2004
    1.59 -+   Free Software Foundation, Inc.
    1.60 -    Contributed by David Mosberger-Tang <davidm@hpl.hp.com>
    1.61 - 
    1.62 -    This file is part of GAS, the GNU Assembler.
    1.63 -@@ -3297,7 +3298,7 @@ static char *special_linkonce_name[] =
    1.64 -   };
    1.65 - 
    1.66 - static void
    1.67 --start_unwind_section (const segT text_seg, int sec_index)
    1.68 -+start_unwind_section (const segT text_seg, int sec_index, int linkonce_empty)
    1.69 - {
    1.70 -   /*
    1.71 -     Use a slightly ugly scheme to derive the unwind section names from
    1.72 -@@ -3359,6 +3360,8 @@ start_unwind_section (const segT text_se
    1.73 -       prefix = special_linkonce_name [sec_index - SPECIAL_SECTION_UNWIND];
    1.74 -       suffix += sizeof (".gnu.linkonce.t.") - 1;
    1.75 -     }
    1.76 -+  else if (linkonce_empty)
    1.77 -+    return;
    1.78 - 
    1.79 -   prefix_len = strlen (prefix);
    1.80 -   suffix_len = strlen (suffix);
    1.81 -@@ -3444,7 +3447,7 @@ generate_unwind_image (const segT text_s
    1.82 -       expressionS exp;
    1.83 -       bfd_reloc_code_real_type reloc;
    1.84 - 
    1.85 --      start_unwind_section (text_seg, SPECIAL_SECTION_UNWIND_INFO);
    1.86 -+      start_unwind_section (text_seg, SPECIAL_SECTION_UNWIND_INFO, 0);
    1.87 - 
    1.88 -       /* Make sure the section has 4 byte alignment for ILP32 and
    1.89 - 	 8 byte alignment for LP64.  */
    1.90 -@@ -3485,6 +3488,8 @@ generate_unwind_image (const segT text_s
    1.91 - 	  unwind.personality_routine = 0;
    1.92 - 	}
    1.93 -     }
    1.94 -+  else
    1.95 -+    start_unwind_section (text_seg, SPECIAL_SECTION_UNWIND_INFO, 1);
    1.96 - 
    1.97 -   free_saved_prologue_counts ();
    1.98 -   unwind.list = unwind.tail = unwind.current_entry = NULL;
    1.99 -@@ -4164,7 +4169,7 @@ dot_endp (dummy)
   1.100 -       subseg_set (md.last_text_seg, 0);
   1.101 -       unwind.proc_end = expr_build_dot ();
   1.102 - 
   1.103 --      start_unwind_section (saved_seg, SPECIAL_SECTION_UNWIND);
   1.104 -+      start_unwind_section (saved_seg, SPECIAL_SECTION_UNWIND, 0);
   1.105 - 
   1.106 -       /* Make sure that section has 4 byte alignment for ILP32 and
   1.107 -          8 byte alignment for LP64.  */
   1.108 -@@ -4204,6 +4209,9 @@ dot_endp (dummy)
   1.109 - 			    bytes_per_address);
   1.110 - 
   1.111 -     }
   1.112 -+  else
   1.113 -+    start_unwind_section (saved_seg, SPECIAL_SECTION_UNWIND, 1);
   1.114 -+
   1.115 -   subseg_set (saved_seg, saved_subseg);
   1.116 - 
   1.117 -   /* Parse names of main and alternate entry points and set symbol sizes.  */
   1.118 -
   1.119 -
   1.120 -	Jakub
   1.121 -