+2007-08-06 Daniel Jacobowitz <dan@codesourcery.com>
+
+ * elf.c (rewrite_elf_program_header): Handle sections not sorted
+ by address.
+ (copy_elf_program_header): Likewise.
+
2007-08-04 H.J. Lu <hongjiu.lu@intel.com>
* elf-bfd.h (xvec_get_elf_backend_data): Add const.
|| (bed->want_p_paddr_set_to_zero &&
IS_CONTAINED_BY_VMA (output_section, segment)))
{
- if (matching_lma == 0)
+ if (matching_lma == 0 || output_section->lma < matching_lma)
matching_lma = output_section->lma;
/* We assume that if the section fits within the segment
bfd_size_type amt;
Elf_Internal_Shdr *this_hdr;
asection *first_section = NULL;
+ asection *lowest_section = NULL;
/* FIXME: Do we need to copy PT_NULL segment? */
if (segment->p_type == PT_NULL)
if (ELF_IS_SECTION_IN_SEGMENT_FILE (this_hdr, segment))
{
if (!first_section)
- first_section = section;
+ first_section = lowest_section = section;
+ if (section->lma < lowest_section->lma)
+ lowest_section = section;
section_count++;
}
}
if (!map->includes_phdrs && !map->includes_filehdr)
/* There is some other padding before the first section. */
- map->p_vaddr_offset = ((first_section ? first_section->lma : 0)
+ map->p_vaddr_offset = ((lowest_section ? lowest_section->lma : 0)
- segment->p_paddr);
if (section_count != 0)