This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
[PATCH] Assigning sections to elf segments
- To: binutils at sources dot redhat dot com
- Subject: [PATCH] Assigning sections to elf segments
- From: Richard Earnshaw <rearnsha at arm dot com>
- Date: Sat, 27 Oct 2001 16:49:36 +0100
- cc: Richard dot Earnshaw at arm dot com
- Organization: ARM Ltd.
- Reply-To: Richard dot Earnshaw at arm dot com
When reading in an elf image we are currently failing to assign some
sections to segments because we are basing the calculations on the VMAs not
the LMAs. This is the final patch required to make strip work correctly if
a segment contains contiguous LMAs but non-contiguous VMAs (if both are
contiguous -- the normal case -- then the behaviour is unchanged). To
support tools that do not set the p_paddr field we fall back to using the
VMAs for segment determination.
<date> Richard Earnshaw (rearnsha@arm.com)
* elf.c (copy_private_bfd_data): If the LMA for a segment is known,
use it for matching sections to segments.
Index: elf.c
===================================================================
RCS file: /thirdparty/cvs/gnu/utils/bfd/elf.c,v
retrieving revision 1.1.1.1
diff -p -r1.1.1.1 elf.c
*** elf.c 2001/06/28 15:58:45 1.1.1.1
--- elf.c 2001/10/27 15:43:31
*************** copy_private_bfd_data (ibfd, obfd)
*** 3748,3763 ****
/* Decide if the given section should be included in the given segment.
A section will be included if:
! 1. It is within the address space of the segment,
2. It is an allocated segment,
3. There is an output section associated with it,
4. The section has not already been allocated to a previous segment. */
! #define INCLUDE_SECTION_IN_SEGMENT(section, segment) \
! ((((IS_CONTAINED_BY_VMA (section, segment) \
! || IS_SOLARIS_PT_INTERP (segment, section)) \
! && (section->flags & SEC_ALLOC) != 0) \
! || IS_COREFILE_NOTE (segment, section)) \
! && section->output_section != NULL \
&& section->segment_mark == false)
/* Returns true iff seg1 starts after the end of seg2. */
--- 3761,3779 ----
/* Decide if the given section should be included in the given segment.
A section will be included if:
! 1. It is within the address space of the segment -- we use the LMA
! if that is set for the segment and the VMA otherwise,
2. It is an allocated segment,
3. There is an output section associated with it,
4. The section has not already been allocated to a previous segment. */
! #define INCLUDE_SECTION_IN_SEGMENT(section, segment) \
! (((((segment->p_paddr \
! ? IS_CONTAINED_BY_LMA (section, segment, segment->p_paddr) \
! : IS_CONTAINED_BY_VMA (section, segment)) \
! || IS_SOLARIS_PT_INTERP (segment, section)) \
! && (section->flags & SEC_ALLOC) != 0) \
! || IS_COREFILE_NOTE (segment, section)) \
! && section->output_section != NULL \
&& section->segment_mark == false)
/* Returns true iff seg1 starts after the end of seg2. */