This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: PPC ld test failure


Hmm, Richard Earnshaw's 2001-10-30 change removed the p_vaddr tests
in order to support non-contiguous VMAs.

	* elf.c (_bfd_elf_make_section_from_shdr): When setting section
	LMAs, loop over segments until p_vaddr and p_memsz specify an
	extent enclosing the section.

Note that newsect->lma = hdr->sh_addr courtesy of bfd_set_section_vma,
so the first hunk isn't really changing anything.

Index: bfd/elf.c
===================================================================
RCS file: /cvs/src/src/bfd/elf.c,v
retrieving revision 1.134
diff -u -p -r1.134 elf.c
--- elf.c	2002/04/01 18:31:46	1.134
+++ elf.c	2002/04/03 13:04:30
@@ -665,11 +665,12 @@ _bfd_elf_make_section_from_shdr (abfd, h
 		  && (hdr->sh_offset + hdr->sh_size
 		      <= phdr->p_offset + phdr->p_memsz)
 		  && ((flags & SEC_LOAD) == 0
-		      || (phdr->p_offset + phdr->p_filesz
-			  >= hdr->sh_offset + hdr->sh_size)))
+		      || (hdr->sh_offset + hdr->sh_size
+			  <= phdr->p_offset + phdr->p_filesz)))
 		{
 		  if ((flags & SEC_LOAD) == 0)
-		    newsect->lma += phdr->p_paddr - phdr->p_vaddr;
+		    newsect->lma = (phdr->p_paddr
+				    + hdr->sh_addr - phdr->p_vaddr);
 		  else
 		    /* We used to use the same adjustment for SEC_LOAD
 		       sections, but that doesn't work if the segment
@@ -680,7 +681,15 @@ _bfd_elf_make_section_from_shdr (abfd, h
 		       LMAs, even if the VMAs are not.  */
 		    newsect->lma = (phdr->p_paddr
 				    + hdr->sh_offset - phdr->p_offset);
-		  break;
+
+		  /* With contiguous segments, we can't tell from file
+		     offsets whether a section with zero size should
+		     be placed at the end of one segment or the
+		     beginning of the next.  Decide based on vaddr.  */
+		  if (hdr->sh_addr >= phdr->p_vaddr
+		      && (hdr->sh_addr + hdr->sh_size
+			  <= phdr->p_vaddr + phdr->p_memsz))
+		    break;
 		}
 	    }
 	}

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]