701-binutils-dup-sections.patch 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. See http://sources.redhat.com/ml/binutils/2004-08/msg00256.html
  2. Date: Fri, 20 Aug 2004 21:13:43 -0400
  3. From: Daniel Jacobowitz <drow at false dot org>
  4. To: binutils at sources dot redhat dot com
  5. Subject: Re: Handle SEC_LINK_DUPLICATES_SAME_CONTENTS for arm-linux
  6. Message-ID: <20040821011342.GA30319@nevyn.them.org>
  7. Mail-Followup-To: binutils at sources dot redhat dot com
  8. References: <20040818145518.GA9774@nevyn.them.org> <20040819055040.GA11820@lucon.org> <20040819080034.GE21716@bubble.modra.org> <20040820173240.GA17678@nevyn.them.org> <20040821003737.GB16016@bubble.modra.org>
  9. In-Reply-To: <20040821003737 dot GB16016 at bubble dot modra dot org>
  10. On Sat, Aug 21, 2004 at 10:07:38AM +0930, Alan Modra wrote:
  11. > On Fri, Aug 20, 2004 at 01:32:40PM -0400, Daniel Jacobowitz wrote:
  12. > > Thanks. How's this?
  13. >
  14. > As you might have guessed from my rather slack review of your previous
  15. > patch, I trust you enough to give the OK without proper review. But
  16. > since you asked... :)
  17. Checked in as so.
  18. --
  19. Daniel Jacobowitz
  20. [ rediffed against binutils-2.15.91.0.2, with some elbow grease ]
  21. 2004-08-20 Daniel Jacobowitz <dan@debian.org>
  22. * elflink.c (_bfd_elf_section_already_linked): Handle
  23. SEC_LINK_DUPLICATES_SAME_CONTENTS.
  24. --- binutils-2.15.91.0.2/bfd/elflink.c.old 2004-07-27 21:36:08.000000000 -0700
  25. +++ binutils-2.15.91.0.2/bfd/elflink.c 2004-08-26 06:38:07.000000000 -0700
  26. @@ -9359,6 +9359,35 @@
  27. (_("%s: %s: warning: duplicate section `%s' has different size\n"),
  28. bfd_archive_filename (abfd), name);
  29. break;
  30. + case SEC_LINK_DUPLICATES_SAME_CONTENTS:
  31. + if (sec->size != l->sec->size)
  32. + (*_bfd_error_handler)
  33. + (_("%B: duplicate section `%A' has different size\n"),
  34. + bfd_archive_filename (abfd), sec);
  35. + else if (sec->size != 0)
  36. + {
  37. + bfd_byte *sec_contents, *l_sec_contents;
  38. +
  39. + if (!bfd_malloc_and_get_section (abfd, sec, &sec_contents))
  40. + (*_bfd_error_handler)
  41. + (_("%B: warning: could not read contents of section `%A'\n"),
  42. + bfd_archive_filename (abfd), sec);
  43. + else if (!bfd_malloc_and_get_section (l->sec->owner, l->sec,
  44. + &l_sec_contents))
  45. + (*_bfd_error_handler)
  46. + (_("%B: warning: could not read contents of section `%A'\n"),
  47. + bfd_archive_filename(l->sec->owner), l->sec);
  48. + else if (memcmp (sec_contents, l_sec_contents, sec->size) != 0)
  49. + (*_bfd_error_handler)
  50. + (_("%B: warning: duplicate section `%A' has different contents\n"),
  51. + bfd_archive_filename (abfd), sec);
  52. +
  53. + if (sec_contents)
  54. + free (sec_contents);
  55. + if (l_sec_contents)
  56. + free (l_sec_contents);
  57. + }
  58. + break;
  59. }
  60. /* Set the output_section field so that lang_add_section