patches/binutils/2.15.90.0.3/binutils-20040817-linkonce.patch
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Sat Feb 24 11:00:05 2007 +0000 (2007-02-24)
changeset 1 eeea35fbf182
permissions -rw-r--r--
Add the full crosstool-NG sources to the new repository of its own.
You might just say: 'Yeah! crosstool-NG's got its own repo!".
Unfortunately, that's because the previous repo got damaged beyond repair and I had no backup.
That means I'm putting backups in place in the afternoon.
That also means we've lost history... :-(
yann@1
     1
From http://sources.redhat.com/ml/binutils/2004-08/msg00190.html
yann@1
     2
yann@1
     3
Date: Tue, 17 Aug 2004 12:04:29 +0200
yann@1
     4
From: Jakub Jelinek <jakub at redhat dot com>
yann@1
     5
To: binutils at sources dot redhat dot com
yann@1
     6
Subject: [PATCH] Fix `defined in discarded section' errors when building ia64 gcc
yann@1
     7
Message-ID: <20040817100429.GL30497@sunsite.ms.mff.cuni.cz>
yann@1
     8
Reply-To: Jakub Jelinek <jakub at redhat dot com>
yann@1
     9
References: <20040817090201.GK30497@sunsite.ms.mff.cuni.cz>
yann@1
    10
In-Reply-To: <20040817090201 dot GK30497 at sunsite dot ms dot mff dot cuni dot cz>
yann@1
    11
yann@1
    12
On Tue, Aug 17, 2004 at 11:02:01AM +0200, Jakub Jelinek wrote:
yann@1
    13
> Current gcc 3.4.x (at least gcc-3_4-rhl-branch) doesn't build with CVS
yann@1
    14
> binutils (nor 2.15.91.0.2).
yann@1
    15
> The problem is that libstdc++.so linking fails with:
yann@1
    16
> `.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
yann@1
    17
> The problem is that both io-inst.s and sstream-inst.s have
yann@1
    18
> .gnu.linkonce.t._ZNSdD2Ev definition, but because io-inst.cc
yann@1
    19
> also instantiates some templates sstream-inst.cc doesn't instantiate,
yann@1
    20
> the inliner can do a better job in io-inst.cc.
yann@1
    21
> The result is that _ZNSdD2Ev in io-inst.cc is a leaf routine, while
yann@1
    22
> it is not in sstream-inst.cc (in assembly,
yann@1
    23
> _ZNSdD2Ev in io-inst.s starts with .prologue and no .save directives,
yann@1
    24
> while _ZNSdD2Ev] in sstream-inst.s has .prologue 12, 35 and some
yann@1
    25
> .save directives.
yann@1
    26
> IA-64 ABI allows leaf routines to have no unwind section at all,
yann@1
    27
> which means .gnu.linkonce.ia64unw._ZNSdD2Ev is not created in
yann@1
    28
> io-inst.o at all and as .gnu.linkonce.t._ZNSdD2Ev comes first
yann@1
    29
> and wins, .gnu.linkonce.ia64unw._ZNSdD2Ev in sstream.o suddenly
yann@1
    30
> references a discarded section.
yann@1
    31
> 
yann@1
    32
> Not sure what should be done here, but certainly the compiler
yann@1
    33
> isn't at fault here, it is a binutils problem.
yann@1
    34
> One fix could be to create empty .gnu.linkonce.ia64unw.* section
yann@1
    35
> in assembler, another special case ia64 unwind sections in the linker.
yann@1
    36
yann@1
    37
Here is a patch for the first possibility.
yann@1
    38
It certainly makes libstdc++.so to link and even the unwind info looks
yann@1
    39
good on brief skimming.
yann@1
    40
yann@1
    41
2004-08-17  Jakub Jelinek  <jakub@redhat.com>
yann@1
    42
yann@1
    43
	* config/tc-ia64.c (start_unwind_section): Add linkonce_empty
yann@1
    44
	argument, don't do anything if current section is not
yann@1
    45
	.gnu.linkonce.t.* and linkonce_empty is set.
yann@1
    46
	(generate_unwind_image, dot_endp): Adjust callers, call
yann@1
    47
	start_unwind_section (*, 1) if nothing will be put into the
yann@1
    48
	section.
yann@1
    49
yann@1
    50
--- binutils/gas/config/tc-ia64.c.jj	2004-07-30 11:42:24.000000000 +0200
yann@1
    51
+++ binutils/gas/config/tc-ia64.c	2004-08-17 13:45:04.288173205 +0200
yann@1
    52
@@ -1,5 +1,6 @@
yann@1
    53
 /* tc-ia64.c -- Assembler for the HP/Intel IA-64 architecture.
yann@1
    54
-   Copyright 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
yann@1
    55
+   Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2004
yann@1
    56
+   Free Software Foundation, Inc.
yann@1
    57
    Contributed by David Mosberger-Tang <davidm@hpl.hp.com>
yann@1
    58
 
yann@1
    59
    This file is part of GAS, the GNU Assembler.
yann@1
    60
@@ -3297,7 +3298,7 @@ static char *special_linkonce_name[] =
yann@1
    61
   };
yann@1
    62
 
yann@1
    63
 static void
yann@1
    64
-start_unwind_section (const segT text_seg, int sec_index)
yann@1
    65
+start_unwind_section (const segT text_seg, int sec_index, int linkonce_empty)
yann@1
    66
 {
yann@1
    67
   /*
yann@1
    68
     Use a slightly ugly scheme to derive the unwind section names from
yann@1
    69
@@ -3359,6 +3360,8 @@ start_unwind_section (const segT text_se
yann@1
    70
       prefix = special_linkonce_name [sec_index - SPECIAL_SECTION_UNWIND];
yann@1
    71
       suffix += sizeof (".gnu.linkonce.t.") - 1;
yann@1
    72
     }
yann@1
    73
+  else if (linkonce_empty)
yann@1
    74
+    return;
yann@1
    75
 
yann@1
    76
   prefix_len = strlen (prefix);
yann@1
    77
   suffix_len = strlen (suffix);
yann@1
    78
@@ -3444,7 +3447,7 @@ generate_unwind_image (const segT text_s
yann@1
    79
       expressionS exp;
yann@1
    80
       bfd_reloc_code_real_type reloc;
yann@1
    81
 
yann@1
    82
-      start_unwind_section (text_seg, SPECIAL_SECTION_UNWIND_INFO);
yann@1
    83
+      start_unwind_section (text_seg, SPECIAL_SECTION_UNWIND_INFO, 0);
yann@1
    84
 
yann@1
    85
       /* Make sure the section has 4 byte alignment for ILP32 and
yann@1
    86
 	 8 byte alignment for LP64.  */
yann@1
    87
@@ -3485,6 +3488,8 @@ generate_unwind_image (const segT text_s
yann@1
    88
 	  unwind.personality_routine = 0;
yann@1
    89
 	}
yann@1
    90
     }
yann@1
    91
+  else
yann@1
    92
+    start_unwind_section (text_seg, SPECIAL_SECTION_UNWIND_INFO, 1);
yann@1
    93
 
yann@1
    94
   free_saved_prologue_counts ();
yann@1
    95
   unwind.list = unwind.tail = unwind.current_entry = NULL;
yann@1
    96
@@ -4164,7 +4169,7 @@ dot_endp (dummy)
yann@1
    97
       subseg_set (md.last_text_seg, 0);
yann@1
    98
       unwind.proc_end = expr_build_dot ();
yann@1
    99
 
yann@1
   100
-      start_unwind_section (saved_seg, SPECIAL_SECTION_UNWIND);
yann@1
   101
+      start_unwind_section (saved_seg, SPECIAL_SECTION_UNWIND, 0);
yann@1
   102
 
yann@1
   103
       /* Make sure that section has 4 byte alignment for ILP32 and
yann@1
   104
          8 byte alignment for LP64.  */
yann@1
   105
@@ -4204,6 +4209,9 @@ dot_endp (dummy)
yann@1
   106
 			    bytes_per_address);
yann@1
   107
 
yann@1
   108
     }
yann@1
   109
+  else
yann@1
   110
+    start_unwind_section (saved_seg, SPECIAL_SECTION_UNWIND, 1);
yann@1
   111
+
yann@1
   112
   subseg_set (saved_seg, saved_subseg);
yann@1
   113
 
yann@1
   114
   /* Parse names of main and alternate entry points and set symbol sizes.  */
yann@1
   115
yann@1
   116
yann@1
   117
	Jakub
yann@1
   118