PR22048, Incorrect .eh_frame section in libc.so
H.J. Lu
hjl.tools@gmail.com
Thu Aug 31 05:01:00 GMT 2017
On Wed, Aug 30, 2017 at 8:57 PM, Alan Modra <amodra@gmail.com> wrote:
> Yep, there is definitely an incorrect .eh_frame section in libc.so.
> It has a ZERO terminator in the middle!
>
> PR 21441
> PR 22048
> * elflink.c (bfd_elf_discard_info): Don't pad embedded zero
> terminators.
>
> diff --git a/bfd/elflink.c b/bfd/elflink.c
> index ceacb37..f6f57fa 100644
> --- a/bfd/elflink.c
> +++ b/bfd/elflink.c
> @@ -13878,17 +13878,22 @@ bfd_elf_discard_info (bfd *output_bfd, struct bfd_link_info *info)
> /* Any prior sections must pad the last FDE out to the
> output section alignment. Otherwise we might have zero
> padding between sections, which would be seen as a
> - terminator. */
> + terminator. If there is a terminator in the middle of
> + FDEs, don't increase its size as that will write bogus
> + data of whatever was after the terminator in the input
> + file, to the output file. */
> for (; i != NULL; i = i->map_tail.s)
> - {
> - bfd_size_type size = (i->size + eh_alignment - 1) & -eh_alignment;
> - if (i->size != size)
> - {
> - i->size = size;
> - changed = 1;
> - eh_changed = 1;
> - }
> - }
> + if (i->size != 4)
> + {
> + bfd_size_type size
> + = (i->size + eh_alignment - 1) & -eh_alignment;
> + if (i->size != size)
> + {
> + i->size = size;
> + changed = 1;
> + eh_changed = 1;
> + }
> + }
> }
> if (eh_changed)
> elf_link_hash_traverse (elf_hash_table (info),
>
Here is a testcase.
--
H.J.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Add-a-test-for-PR-ld-22048.patch
Type: text/x-patch
Size: 2549 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20170831/9a2767c2/attachment.bin>
More information about the Binutils
mailing list