public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* PR25444, Floating point exception in _bfd_elf_compute_section_file_positions
@ 2020-01-23  9:23 Alan Modra
  0 siblings, 0 replies; only message in thread
From: Alan Modra @ 2020-01-23  9:23 UTC (permalink / raw)
  To: binutils

	PR 25444
	* elf.c (assign_file_positions_for_load_sections): Avoid divide
	by zero when p_align is zero.

diff --git a/bfd/elf.c b/bfd/elf.c
index 08aaab644a..c6a39848b4 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
 	    {

-- 
Alan Modra
Australia Development Lab, IBM

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-01-23  9:23 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-23  9:23 PR25444, Floating point exception in _bfd_elf_compute_section_file_positions Alan Modra

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).