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
- From: "H. J. Lu" <hjl at lucon dot org>
- To: binutils at sources dot redhat dot com
- Date: Wed, 18 Aug 2004 22:50:40 -0700
- Subject: Re: Handle SEC_LINK_DUPLICATES_SAME_CONTENTS for arm-linux
- References: <20040818145518.GA9774@nevyn.them.org>
On Wed, Aug 18, 2004 at 10:55:19AM -0400, Daniel Jacobowitz wrote:
> The ARM linker uses SEC_LINK_DUPLICATES_SAME_CONTENTS for some note sections
> (probably more of them than it really ought to, but...). This isn't handled
> properly by one of HJ's COMDAT support patches, which just aborted in this
> case.
>
> OK?
>
> --
> Daniel Jacobowitz
>
> 2004-08-18 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.93
> diff -u -p -r1.93 elflink.c
> --- bfd/elflink.c 9 Aug 2004 06:02:03 -0000 1.93
> +++ bfd/elflink.c 11 Aug 2004 22:55:52 -0000
> @@ -9397,6 +9397,35 @@ _bfd_elf_section_already_linked (bfd *ab
> (_("%s: %s: warning: duplicate section `%s' has different size\n"),
> bfd_archive_filename (abfd), name);
> break;
> +
> + case SEC_LINK_DUPLICATES_SAME_CONTENTS:
> + if (sec->size != l->sec->size)
> + (*_bfd_error_handler)
> + (_("%s: %s: warning: duplicate section `%s' has different size\n"),
> + bfd_archive_filename (abfd), name);
> + else
> + {
> + char *sec_contents, *l_sec_contents;
> + sec_contents = bfd_malloc (sec->size);
> + l_sec_contents = bfd_malloc (sec->size);
> + /* No way to report failure here... */
> + if (sec_contents && l_sec_contents
> + && bfd_get_section_contents (abfd, sec, sec_contents,
> + 0, sec->size)
> + && bfd_get_section_contents (l->sec->owner, l->sec,
> + l_sec_contents,
> + 0, l->sec->size)
> + && memcmp (sec_contents, l_sec_contents,
> + sec->size) != 0)
> + (*_bfd_error_handler)
> + (_("%s: %s: warning: duplicate section `%s' has different contents\n"),
> + bfd_archive_filename (abfd), name);
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.
> + 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
Will this compile for mainline? Alan has removed bfd_archive_filename
with his error_handler change.
H.J.