Commit: Fix merge section matching in objcopy
Nick Clifton
nickc@redhat.com
Tue Oct 6 14:48:51 GMT 2020
Hi Guys,
The note merging code in objcopy/strip has a hack[1] to allow it to
match input sections with their corresponding output sections. It was
never intended to be in there for long, but I forgot about it, and it
has actually been working for the last few years. But a recent update
to annobin in Fedora rawhide has now triggered the latent bug in the
approach. So I am checking in the patch below to fix the bug and use
the correct approach - comparing section pointers not names.
Cheers
Nick
[1] I was comparing input and output section names and assuming that if
they were the same then they matched. This does not have to be true
of course and it is entirely possible to have multiple same-named
sections in the same input file.
binutils/ChangeLog
2020-10-06 Nick Clifton <nickc@redhat.com>
* objcopy.c (copy_object): Compare input and output sections by
pointer rather than name.
diff --git a/binutils/objcopy.c b/binutils/objcopy.c
index 1a6fc8a4f5..d777d740cb 100644
--- a/binutils/objcopy.c
+++ b/binutils/objcopy.c
@@ -3322,14 +3322,12 @@ copy_object (bfd *ibfd, bfd *obfd, const bfd_arch_info_type *input_arch)
/* It is likely that output sections are in the same order
as the input sections, but do not assume that this is
the case. */
- if (strcmp (bfd_section_name (merged->sec),
- bfd_section_name (osec)) != 0)
+ if (merged->sec->output_section != osec)
{
for (merged = merged_note_sections;
merged != NULL;
merged = merged->next)
- if (strcmp (bfd_section_name (merged->sec),
- bfd_section_name (osec)) == 0)
+ if (merged->sec->output_section == osec)
break;
if (merged == NULL)
More information about the Binutils
mailing list