mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-19 17:18:24 +08:00
Fix bug merging notes with objcopy when no merging results in zeroes being written back into the note section.
* objcopy.c (copy_object): Skip note sections that do not have an output section. Always copy note sections, even if no changes are made.
This commit is contained in:
@ -1,3 +1,9 @@
|
|||||||
|
2019-11-07 Nick Clifton <nickc@redhat.com>
|
||||||
|
|
||||||
|
* objcopy.c (copy_object): Skip note sections that do not have
|
||||||
|
an output section. Always copy note sections, even if no
|
||||||
|
changes are made.
|
||||||
|
|
||||||
2019-11-06 Christian Eggers <ceggers@gmx.de>
|
2019-11-06 Christian Eggers <ceggers@gmx.de>
|
||||||
|
|
||||||
* readelf.c (IN_RANGE): Rename parameter OFF to NELEM. Add
|
* readelf.c (IN_RANGE): Rename parameter OFF to NELEM. Add
|
||||||
|
@ -2878,6 +2878,11 @@ copy_object (bfd *ibfd, bfd *obfd, const bfd_arch_info_type *input_arch)
|
|||||||
if (! is_mergeable_note_section (ibfd, osec))
|
if (! is_mergeable_note_section (ibfd, osec))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
/* If the section is going to be completly deleted then
|
||||||
|
do not bother to merge it. */
|
||||||
|
if (osec->output_section == NULL)
|
||||||
|
continue;
|
||||||
|
|
||||||
bfd_size_type size = bfd_section_size (osec);
|
bfd_size_type size = bfd_section_size (osec);
|
||||||
|
|
||||||
if (size == 0)
|
if (size == 0)
|
||||||
@ -2893,25 +2898,19 @@ copy_object (bfd *ibfd, bfd *obfd, const bfd_arch_info_type *input_arch)
|
|||||||
{
|
{
|
||||||
bfd_nonfatal_message (NULL, ibfd, osec,
|
bfd_nonfatal_message (NULL, ibfd, osec,
|
||||||
_("warning: could not load note section"));
|
_("warning: could not load note section"));
|
||||||
free (merged->contents);
|
|
||||||
free (merged);
|
free (merged);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
merged->size = merge_gnu_build_notes (ibfd, osec, size,
|
merged->size = merge_gnu_build_notes (ibfd, osec, size,
|
||||||
merged->contents);
|
merged->contents);
|
||||||
if (merged->size == size)
|
|
||||||
{
|
|
||||||
/* Merging achieves nothing. */
|
|
||||||
merge_debug ("Merge of section %s achieved nothing - skipping\n",
|
|
||||||
bfd_section_name (osec));
|
|
||||||
free (merged->contents);
|
|
||||||
free (merged);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (osec->output_section == NULL
|
/* FIXME: Once we have read the contents in, we must write
|
||||||
|| !bfd_set_section_size (osec->output_section, merged->size))
|
them out again. So even if the mergeing has achieved
|
||||||
|
nothing we still add this entry to the merge list. */
|
||||||
|
|
||||||
|
if (size != merged->size
|
||||||
|
&& !bfd_set_section_size (osec->output_section, merged->size))
|
||||||
{
|
{
|
||||||
bfd_nonfatal_message (NULL, obfd, osec,
|
bfd_nonfatal_message (NULL, obfd, osec,
|
||||||
_("warning: failed to set merged notes size"));
|
_("warning: failed to set merged notes size"));
|
||||||
@ -3277,16 +3276,16 @@ copy_object (bfd *ibfd, bfd *obfd, const bfd_arch_info_type *input_arch)
|
|||||||
{
|
{
|
||||||
bfd_nonfatal_message
|
bfd_nonfatal_message
|
||||||
(NULL, obfd, osec,
|
(NULL, obfd, osec,
|
||||||
_("error: failed to copy merged notes into output"));
|
_("error: failed to locate merged notes"));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! is_mergeable_note_section (obfd, osec))
|
if (merged->contents == NULL)
|
||||||
{
|
{
|
||||||
bfd_nonfatal_message
|
bfd_nonfatal_message
|
||||||
(NULL, obfd, osec,
|
(NULL, obfd, osec,
|
||||||
_("error: failed to copy merged notes into output"));
|
_("error: failed to merge notes"));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user