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: PATCH: Adjust segment memory size for the SHT_NOBITS section


On Thu, Mar 01, 2007 at 05:08:48PM -0800, H. J. Lu wrote:
> --- 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;
>  		}
>  	    }

Look at the definition of vma_page_aligned_bias.  I'm sure you'll see
that you can simplify this code, and will end up with something like
the code for the ajustment based on lma just above, but using vma.
Then of course you'd have to wonder why the code wasn't written that
way in the first place.  Please do some digging to find out why.

-- 
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]