This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: PATCH: Adjust segment memory size for the SHT_NOBITS section
- From: Alan Modra <amodra at bigpond dot net dot au>
- To: "H. J. Lu" <hjl at lucon dot org>
- Cc: binutils at sources dot redhat dot com
- Date: Fri, 2 Mar 2007 13:32:12 +1030
- Subject: Re: PATCH: Adjust segment memory size for the SHT_NOBITS section
- References: <20070302010848.GA22840@lucon.org>
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