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]
Other format: [Raw text]

copy_private_bfd_data: Do not merge segments whose LMAs do not overlap


Hi Guys,

  Does anyone forsee any problems with the patch below ?

  It fixes the code in copy_private_bfd_data() that tries to copy the
  program headers.  The problem was that the code would merge together
  segments whose VMAs overlapped, even if they had different LMAs.
  This causes problems because it can leave sections without a
  suitable segment to contain them.

  I have tested the patch with an x86 native and an arm-elf cross
  compiler with no new faults encountered, but I thought I would check
  with the group first before committing it.

Cheers
        Nick

2003-02-13  Nick Clifton  <nickc@redhat.com>

	* elf.c (SEGMENT_AFTER_SEGMENT): Add third parameter - the
	address field to use in the comparison.
        (SEGMENT_OVERLAPS): Check that LMAs overlap as well.

Index: bfd/elf.c
===================================================================
RCS file: /cvs/src/src/bfd/elf.c,v
retrieving revision 1.178
diff -c -3 -p -w -r1.178 elf.c
*** bfd/elf.c	7 Feb 2003 14:27:59 -0000	1.178
--- bfd/elf.c	13 Feb 2003 18:04:04 -0000
*************** copy_private_bfd_data (ibfd, obfd)
*** 4656,4668 ****
     && ! section->segment_mark)
  
    /* Returns TRUE iff seg1 starts after the end of seg2.  */
! #define SEGMENT_AFTER_SEGMENT(seg1, seg2)				\
!   (seg1->p_vaddr >= SEGMENT_END (seg2, seg2->p_vaddr))
  
!   /* Returns TRUE iff seg1 and seg2 overlap.  */
  #define SEGMENT_OVERLAPS(seg1, seg2)					\
!   (!(SEGMENT_AFTER_SEGMENT (seg1, seg2)					\
!      || SEGMENT_AFTER_SEGMENT (seg2, seg1)))
  
    /* Initialise the segment mark field.  */
    for (section = ibfd->sections; section != NULL; section = section->next)
--- 4656,4675 ----
     && ! section->segment_mark)
  
    /* Returns TRUE iff seg1 starts after the end of seg2.  */
! #define SEGMENT_AFTER_SEGMENT(seg1, seg2, field)			\
!   (seg1->field >= SEGMENT_END (seg2, seg2->field))
  
!   /* Returns TRUE iff seg1 and seg2 overlap. Segments overlap iff both
!      their VMA address ranges and their LMA address ranges overlap.
!      It is possible to have overlapping VMA ranges without overlapping LMA
!      ranges.  RedBoot images for example can have both .data and .bss mapped
!      to the same VMA range, but with the .data section mapped to a different
!      LMA.  */
  #define SEGMENT_OVERLAPS(seg1, seg2)					\
!   (   !(SEGMENT_AFTER_SEGMENT (seg1, seg2, p_vaddr)			\
!         || SEGMENT_AFTER_SEGMENT (seg2, seg1, p_vaddr)) 		\
!    && !(SEGMENT_AFTER_SEGMENT (seg1, seg2, p_paddr)			\
!         || SEGMENT_AFTER_SEGMENT (seg2, seg1, p_paddr)))
  
    /* Initialise the segment mark field.  */
    for (section = ibfd->sections; section != NULL; section = section->next)


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