summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Jacobowitz <dan@debian.org>2007-08-06 18:35:18 +0000
committerDaniel Jacobowitz <dan@debian.org>2007-08-06 18:35:18 +0000
commitfd1dffbec1c0bc7f58ce98fcaea9a8f1f2a9e5f9 (patch)
tree411b2e3d1e644199041e0810b341c879256bbf01
parent32afd06f407a1bdc1d07df9986688e9859d608b6 (diff)
downloadgdb-fd1dffbec1c0bc7f58ce98fcaea9a8f1f2a9e5f9.tar.gz
* elf.c (rewrite_elf_program_header): Handle sections not sorted
by address. (copy_elf_program_header): Likewise.
-rw-r--r--bfd/ChangeLog6
-rw-r--r--bfd/elf.c9
2 files changed, 12 insertions, 3 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 9ad32c480f1..50ce8c0aff7 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,9 @@
+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.
diff --git a/bfd/elf.c b/bfd/elf.c
index 39678f6be1f..4bc5a78ff4e 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -5286,7 +5286,7 @@ rewrite_elf_program_header (bfd *ibfd, bfd *obfd)
|| (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
@@ -5539,6 +5539,7 @@ copy_elf_program_header (bfd *ibfd, bfd *obfd)
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)
@@ -5553,7 +5554,9 @@ copy_elf_program_header (bfd *ibfd, bfd *obfd)
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++;
}
}
@@ -5599,7 +5602,7 @@ copy_elf_program_header (bfd *ibfd, bfd *obfd)
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)