diff options
author | Alan Modra <amodra@gmail.com> | 2020-01-23 11:35:51 +1030 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2020-01-23 19:53:25 +1030 |
commit | 67641dd326e026b84d0e4ce47f32f71132449e27 (patch) | |
tree | 43cf74c137c28cefcac1692b2d66cb7913798ab3 /bfd | |
parent | 403d1bd91dffc9e6f5029faaa9cce7c07f268d52 (diff) | |
download | gdb-67641dd326e026b84d0e4ce47f32f71132449e27.zip gdb-67641dd326e026b84d0e4ce47f32f71132449e27.tar.gz gdb-67641dd326e026b84d0e4ce47f32f71132449e27.tar.bz2 |
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.
Diffstat (limited to 'bfd')
-rw-r--r-- | bfd/ChangeLog | 6 | ||||
-rw-r--r-- | bfd/elf.c | 16 |
2 files changed, 17 insertions, 5 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 6359324..97f5384 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,9 @@ +2020-01-23 Alan Modra <amodra@gmail.com> + + PR 25444 + * elf.c (assign_file_positions_for_load_sections): Avoid divide + by zero when p_align is zero. + 2020-01-22 Maxim Blinov <maxim.blinov@embecosm.com> * bfd/elfnn-riscv.c (riscv_skip_prefix): New. @@ -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 { |