700-binutils-20040817-linkonce.patch 4.8 KB

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