This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
PATCH: Fix off by one error in mapping sections to segments
- From: Nick Clifton <nickc at redhat dot com>
- To: binutils at sourceware dot org
- Date: Thu, 24 Jul 2008 08:51:00 +0100
- Subject: PATCH: Fix off by one error in mapping sections to segments
Hi Guys,
I had an off by one error in my recent update to the code to map
sections to segments. If one section ended right on a page boundary
and the next section started exactly at the beginning of the next
but one page, the algorithm would still allocate the sections to the
same segment, rather than splitting them up.
Fixed by applying the following patch.
Cheers
Nick
bfd/ChangeLog
2008-07-24 Nick Clifton <nickc@redhat.com>
* elf.c (_bfd_elf_map_sections_to_segments): Catch off by one
error assigning sections to segments.
Index: bfd/elf.c
===================================================================
RCS file: /cvs/src/src/bfd/elf.c,v
retrieving revision 1.456
diff -c -3 -p -r1.456 elf.c
*** bfd/elf.c 22 Jul 2008 11:19:01 -0000 1.456
--- bfd/elf.c 24 Jul 2008 07:47:38 -0000
*************** _bfd_elf_map_sections_to_segments (bfd *
*** 3728,3734 ****
else if ((BFD_ALIGN (last_hdr->lma + last_size, maxpagesize) + maxpagesize
> last_hdr->lma)
&& (BFD_ALIGN (last_hdr->lma + last_size, maxpagesize) + maxpagesize
! < hdr->lma))
{
/* If putting this section in this segment would force us to
skip a page in the segment, then we need a new segment. */
--- 3728,3734 ----
else if ((BFD_ALIGN (last_hdr->lma + last_size, maxpagesize) + maxpagesize
> last_hdr->lma)
&& (BFD_ALIGN (last_hdr->lma + last_size, maxpagesize) + maxpagesize
! <= hdr->lma))
{
/* If putting this section in this segment would force us to
skip a page in the segment, then we need a new segment. */