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]

[PATCH] packing sections into elf segments



I'd like to submit the following patch for consideration, it fixes a 
problem I reported earlier today when the bfd backend would perform seeks 
to negative file offsets when a segment contains sections that are linked 
for different virtual addresses, but are to be loaded at one physical 
address.

It makes more sense to me that when we are trying to adjust for the 
alignment padding between sections by adjusting file positions, that we 
should be using the LMAs not the VMAs, after all, the code later in the 
same loop uses LMAs for adjusting the file size.

The patch should have no effect on the behaviour of the normal case, where 
the VMA and LMA are identical.

R.

<date>  Richard Earnshaw (rearnsha@arm.com)

	* elf.c (assign_file_positions_for_segments): Use the LMA when 
	adjusting for inter-section alignment padding.


Index: elf.c
===================================================================
RCS file: /thirdparty/cvs/gnu/utils/bfd/elf.c,v
retrieving revision 1.1.1.1
diff -p -r1.1.1.1 elf.c
*** elf.c	2001/06/28 15:58:45	1.1.1.1
--- elf.c	2001/10/26 17:33:09
*************** assign_file_positions_for_segments (abfd
*** 2929,2938 ****
  
  	  /* The section may have artificial alignment forced by a
  	     link script.  Notice this case by the gap between the
! 	     cumulative phdr vma and the section's vma.  */
! 	  if (p->p_vaddr + p->p_memsz < sec->vma)
  	    {
! 	      bfd_vma adjust = sec->vma - (p->p_vaddr + p->p_memsz);
  
  	      p->p_memsz += adjust;
  	      off += adjust;
--- 2929,2938 ----
  
  	  /* The section may have artificial alignment forced by a
  	     link script.  Notice this case by the gap between the
! 	     cumulative phdr lma and the section's lma.  */
! 	  if (p->p_paddr + p->p_memsz < sec->lma)
  	    {
! 	      bfd_vma adjust = sec->lma - (p->p_paddr + p->p_memsz);
  
  	      p->p_memsz += adjust;
  	      off += adjust;

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