This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: Handle SEC_LINK_DUPLICATES_SAME_CONTENTS for arm-linux
On Thu, Aug 19, 2004 at 05:30:34PM +0930, Alan Modra wrote:
> On Wed, Aug 18, 2004 at 10:50:40PM -0700, H. J. Lu wrote:
> > On Wed, Aug 18, 2004 at 10:55:19AM -0400, Daniel Jacobowitz wrote:
> > So if one of those bfd_malloc/bfd_get_section_contents calls fails,
> > it is a success. I am not sure if I like it.
>
> Effectively, fall back to just a size check. I think that's
> reasonable.
Or we could just complain in that case too.
> No, presumably Daniel will fix that before applying. Daniel, you
> could use bfd_malloc_and_get_section here too.
Thanks. How's this?
--
Daniel Jacobowitz
2004-08-20 Daniel Jacobowitz <dan@debian.org>
* elflink.c (_bfd_elf_section_already_linked): Handle
SEC_LINK_DUPLICATES_SAME_CONTENTS.
Index: bfd/elflink.c
===================================================================
RCS file: /big/fsf/rsync/src-cvs/src/bfd/elflink.c,v
retrieving revision 1.97
diff -u -p -r1.97 elflink.c
--- bfd/elflink.c 18 Aug 2004 02:45:42 -0000 1.97
+++ bfd/elflink.c 20 Aug 2004 16:58:46 -0000
@@ -9366,6 +9366,40 @@ _bfd_elf_section_already_linked (bfd *ab
(_("%B: duplicate section `%A' has different size\n"),
abfd, sec);
break;
+
+ case SEC_LINK_DUPLICATES_SAME_CONTENTS:
+ if (sec->size != l->sec->size)
+ (*_bfd_error_handler)
+ (_("%B: duplicate section `%A' has different size\n"),
+ abfd, sec);
+ else
+ {
+ bfd_byte *sec_contents, *l_sec_contents;
+
+ if (!bfd_malloc_and_get_section (abfd, sec, &sec_contents))
+ (*_bfd_error_handler)
+ (_("%B: warning: could not read contents of section `%A'\n"),
+ abfd, sec);
+ else if (!bfd_malloc_and_get_section (l->sec->owner, l->sec,
+ &l_sec_contents))
+ (*_bfd_error_handler)
+ (_("%B: warning: could not read contents of section `%A'\n"),
+ l->sec->owner, l->sec);
+ else if (sec_contents == NULL && l_sec_contents == NULL)
+ /* OK; both sections have 0 size. */;
+ else if (sec_contents != NULL && l_sec_contents != NULL
+ && memcmp (sec_contents, l_sec_contents,
+ sec->size) != 0)
+ (*_bfd_error_handler)
+ (_("%B: warning: duplicate section `%A' has different contents\n"),
+ abfd, sec);
+
+ if (sec_contents)
+ free (sec_contents);
+ if (l_sec_contents)
+ free (l_sec_contents);
+ }
+ break;
}
/* Set the output_section field so that lang_add_section