This is the mail archive of the binutils@sourceware.org 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: VMA section overlap warnings for overlays


Hi,

If we have a single segment containing a BSS section followed by
overlays then we still get the overlap warning. 

Does the following patch look like the correct fix? I believe it fixes
my original test case, and I've also tested it on i686-pc-linux-gnu
without any problems.

Thanks,
Dave.

Bfd/ChangeLog:

2010-05-07  David Stubbs  <stubbs@icerasemi.com>

	* elf.c (assign_file_positions_for_load_sections): Calculate
adjust
	based on file size instead of memory size. Increment p->p_memsz
by 
	vma based calculation instead of adjust.

Index: bfd/elf.c
===================================================================
RCS file: /cvs/src/src/bfd/elf.c,v
retrieving revision 1.510
diff -u -p -r1.510 elf.c
--- bfd/elf.c	24 Apr 2010 01:05:24 -0000	1.510
+++ bfd/elf.c	7 May 2010 15:41:09 -0000
@@ -4453,17 +4453,17 @@ assign_file_positions_for_load_sections 
 		      && ((this_hdr->sh_flags & SHF_TLS) == 0
 			  || p->p_type == PT_TLS))))
 	    {
-	      bfd_vma adjust = sec->lma - (p->p_paddr + p->p_memsz);
+	      bfd_vma adjust = sec->lma - (p->p_paddr + p->p_filesz);
 
-	      if (sec->lma < p->p_paddr + p->p_memsz)
+	      if (sec->lma < p->p_paddr + p->p_filesz)
 		{
 		  (*_bfd_error_handler)
 		    (_("%B: section %A lma 0x%lx overlaps previous
sections"),
 		     abfd, sec, (unsigned long) sec->lma);
 		  adjust = 0;
-		  sec->lma = p->p_paddr + p->p_memsz;
+		  sec->lma = p->p_paddr + p->p_filesz;
 		}
-	      p->p_memsz += adjust;
+	      p->p_memsz += sec->vma - (p->p_vaddr + p->p_memsz);
 
 	      if (this_hdr->sh_type != SHT_NOBITS)
 		{


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