PATCH: Allow sections in adjacent pages to be included in the same segment
H.J. Lu
hjl.tools@gmail.com
Fri Jul 25 13:48:00 GMT 2008
On Tue, Jul 22, 2008 at 4:19 AM, Nick Clifton <nickc@redhat.com> wrote:
> Hi Guys,
>
> I am applying the patch below to fix the assignment of adjacent ELF
> sections to a segment. At the moment the code looks like this:
>
> else if (BFD_ALIGN (last_hdr->lma + last_size, maxpagesize)
> < BFD_ALIGN (hdr->lma, maxpagesize))
> {
> /* If putting this section in this segment would force us to
> skip a page in the segment, then we need a new segment. */
> new_segment = TRUE;
> }
>
> which does not work as intended because BFD_ALIGN always rounds its
> argument up to the next alignment boundary. So for example if one
> section ended at 0x1fff and the next (potential) section to be
> allocated started at 0x2001 and the pagesize was 0x1000 then the
> comparison above would check "0x2000 < 0x3000" and so decide that a
> new segment was needed.
>
> The revised test looks like this:
>
> else if (BFD_ALIGN (last_hdr->lma + last_size, maxpagesize) + maxpagesize
> < hdr->lma)
>
> so that it rounds up the end address of the previous section but
> compares it directly with the start address of the current section.
> The "+ maxpagesize" is there so that we actually allow for sections
> that are in separate pages but not more than one page apart. The
> code has to be careful however to handle the case where rounding up
> the end address of the previous section wraps around the end of the
> address space so the actual patch looks like this:
>
Hi Nick,
Is there a testcase for this?
Thanks.
--
H.J.
More information about the Binutils
mailing list