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