* elf.c (rewrite_elf_program_header): Don't wrap p_paddr to

include file or program headers.
This commit is contained in:
Alan Modra
2008-08-01 06:39:04 +00:00
parent 3823320924
commit 010c8431b0
2 changed files with 27 additions and 9 deletions

View File

@ -1,3 +1,8 @@
2008-08-01 Alan Modra <amodra@bigpond.net.au>
* elf.c (rewrite_elf_program_header): Don't wrap p_paddr to
include file or program headers.
2008-07-30 Alan Modra <amodra@bigpond.net.au> 2008-07-30 Alan Modra <amodra@bigpond.net.au>
* coff-ppc.c, coffgen.c, ecoff.c, ecofflink.c, elf.c, elf32-frv.c, * coff-ppc.c, coffgen.c, ecoff.c, ecofflink.c, elf.c, elf32-frv.c,

View File

@ -5559,9 +5559,19 @@ rewrite_elf_program_header (bfd *ibfd, bfd *obfd)
/* Offset the segment physical address from the lma /* Offset the segment physical address from the lma
to allow for space taken up by elf headers. */ to allow for space taken up by elf headers. */
if (map->includes_filehdr) if (map->includes_filehdr)
{
if (map->p_paddr >= iehdr->e_ehsize)
map->p_paddr -= iehdr->e_ehsize; map->p_paddr -= iehdr->e_ehsize;
else
{
map->includes_filehdr = FALSE;
map->includes_phdrs = FALSE;
}
}
if (map->includes_phdrs) if (map->includes_phdrs)
{
if (map->p_paddr >= iehdr->e_phnum * iehdr->e_phentsize)
{ {
map->p_paddr -= iehdr->e_phnum * iehdr->e_phentsize; map->p_paddr -= iehdr->e_phnum * iehdr->e_phentsize;
@ -5573,6 +5583,9 @@ rewrite_elf_program_header (bfd *ibfd, bfd *obfd)
phdr_adjust_num = iehdr->e_phnum; phdr_adjust_num = iehdr->e_phnum;
phdr_adjust_seg = map; phdr_adjust_seg = map;
} }
else
map->includes_phdrs = FALSE;
}
} }
/* Step Three: Loop over the sections again, this time assigning /* Step Three: Loop over the sections again, this time assigning