yann@1: See http://sources.redhat.com/ml/binutils/2004-08/msg00256.html yann@1: yann@1: Date: Fri, 20 Aug 2004 21:13:43 -0400 yann@1: From: Daniel Jacobowitz yann@1: To: binutils at sources dot redhat dot com yann@1: Subject: Re: Handle SEC_LINK_DUPLICATES_SAME_CONTENTS for arm-linux yann@1: Message-ID: <20040821011342.GA30319@nevyn.them.org> yann@1: Mail-Followup-To: binutils at sources dot redhat dot com yann@1: 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> yann@1: In-Reply-To: <20040821003737 dot GB16016 at bubble dot modra dot org> yann@1: yann@1: On Sat, Aug 21, 2004 at 10:07:38AM +0930, Alan Modra wrote: yann@1: > On Fri, Aug 20, 2004 at 01:32:40PM -0400, Daniel Jacobowitz wrote: yann@1: > > Thanks. How's this? yann@1: > yann@1: > As you might have guessed from my rather slack review of your previous yann@1: > patch, I trust you enough to give the OK without proper review. But yann@1: > since you asked... :) yann@1: yann@1: Checked in as so. yann@1: yann@1: -- yann@1: Daniel Jacobowitz yann@1: yann@1: [ rediffed against binutils-2.15.91.0.2, with some elbow grease ] yann@1: yann@1: 2004-08-20 Daniel Jacobowitz yann@1: yann@1: * elflink.c (_bfd_elf_section_already_linked): Handle yann@1: SEC_LINK_DUPLICATES_SAME_CONTENTS. yann@1: --- binutils-2.15.91.0.2/bfd/elflink.c.old 2004-07-27 21:36:08.000000000 -0700 yann@1: +++ binutils-2.15.91.0.2/bfd/elflink.c 2004-08-26 06:38:07.000000000 -0700 yann@1: @@ -9359,6 +9359,35 @@ yann@1: (_("%s: %s: warning: duplicate section `%s' has different size\n"), yann@1: bfd_archive_filename (abfd), name); yann@1: break; yann@1: + case SEC_LINK_DUPLICATES_SAME_CONTENTS: yann@1: + if (sec->size != l->sec->size) yann@1: + (*_bfd_error_handler) yann@1: + (_("%B: duplicate section `%A' has different size\n"), yann@1: + bfd_archive_filename (abfd), sec); yann@1: + else if (sec->size != 0) yann@1: + { yann@1: + bfd_byte *sec_contents, *l_sec_contents; yann@1: + yann@1: + if (!bfd_malloc_and_get_section (abfd, sec, &sec_contents)) yann@1: + (*_bfd_error_handler) yann@1: + (_("%B: warning: could not read contents of section `%A'\n"), yann@1: + bfd_archive_filename (abfd), sec); yann@1: + else if (!bfd_malloc_and_get_section (l->sec->owner, l->sec, yann@1: + &l_sec_contents)) yann@1: + (*_bfd_error_handler) yann@1: + (_("%B: warning: could not read contents of section `%A'\n"), yann@1: + bfd_archive_filename(l->sec->owner), l->sec); yann@1: + else if (memcmp (sec_contents, l_sec_contents, sec->size) != 0) yann@1: + (*_bfd_error_handler) yann@1: + (_("%B: warning: duplicate section `%A' has different contents\n"), yann@1: + bfd_archive_filename (abfd), sec); yann@1: + yann@1: + if (sec_contents) yann@1: + free (sec_contents); yann@1: + if (l_sec_contents) yann@1: + free (l_sec_contents); yann@1: + } yann@1: + break; yann@1: } yann@1: yann@1: /* Set the output_section field so that lang_add_section