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]

PATCH: Adjust segment memory size for the SHT_NOBITS section


The current binutils failed on Linux/i386:

FAIL: --extract-symbol test 1 (sections)
FAIL: --extract-symbol test 1 (symbols)
FAIL: --extract-symbol test 1 (sections)
FAIL: --extract-symbol test 1 (symbols)

when my patch

http://sourceware.org/ml/binutils/2007-02/msg00408.html

is applied. The problem is we failed to adjust segment memory size for
the SHT_NOBITS section whose VMA > the page size. This patch takes
it into account.


H.J.
---
2007-03-01  H.J. Lu  <hongjiu.lu@intel.com>

	* elf.c (assign_file_positions_for_load_sections): Adjust
	segment memory size for the SHT_NOBITS section VMA > the page
	size.

--- bfd/elf.c.nobits	2007-03-01 15:25:22.000000000 -0800
+++ bfd/elf.c	2007-03-01 17:00:52.000000000 -0800
@@ -4623,11 +4623,15 @@ assign_file_positions_for_load_sections 
 		  /* The section VMA must equal the file position
 		     modulo the page size.  */
 		  bfd_size_type page = align;
+		  bfd_signed_vma diff = sec->vma - p->p_vaddr - p->p_memsz;
 		  if (page < maxpagesize)
 		    page = maxpagesize;
 		  adjust = vma_page_aligned_bias (sec->vma,
 						  p->p_vaddr + p->p_memsz,
 						  page);
+		  /* Adjust for the section VMA > the page size.  */
+		  if (diff > 0)
+		    adjust += page * (diff / page);
 		  p->p_memsz += adjust;
 		}
 	    }


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