From: Alan Modra Date: Thu, 23 Jan 2020 01:05:51 +0000 (+1030) Subject: PR25444, Floating point exception in _bfd_elf_compute_section_file_positions X-Git-Tag: binutils-2_34~11 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=9d4684ce5baf54f6f9cf73f96de836e255eeb7ba;p=thirdparty%2Fbinutils-gdb.git PR25444, Floating point exception in _bfd_elf_compute_section_file_positions PR 25444 * elf.c (assign_file_positions_for_load_sections): Avoid divide by zero when p_align is zero. (cherry picked from commit 67641dd326e026b84d0e4ce47f32f71132449e27) --- diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 37bc1c60f3c..41a60ffb397 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,6 +1,11 @@ 2020-01-29 Alan Modra Apply from master + 2020-01-23 Alan Modra + PR 25444 + * elf.c (assign_file_positions_for_load_sections): Avoid divide + by zero when p_align is zero. + 2020-01-22 Alan Modra * elf64-ppc.c (ppc64_elf_size_stubs): Correct condition under which __tls_get_addr calls will be eliminated. diff --git a/bfd/elf.c b/bfd/elf.c index 08aaab644a8..a8d98a60f4e 100644 --- a/bfd/elf.c +++ b/bfd/elf.c @@ -5755,11 +5755,17 @@ assign_file_positions_for_load_sections (bfd *abfd, { p->p_offset = off; if (no_contents) - /* Put meaningless p_offset for PT_LOAD segments - without file contents somewhere within the first - page, in an attempt to not point past EOF. */ - p->p_offset = off % (p->p_align > maxpagesize - ? p->p_align : maxpagesize); + { + /* Put meaningless p_offset for PT_LOAD segments + without file contents somewhere within the first + page, in an attempt to not point past EOF. */ + bfd_size_type align = maxpagesize; + if (align < p->p_align) + align = p->p_align; + if (align < 1) + align = 1; + p->p_offset = off % align; + } } else {