diff options
author | Alan Modra <amodra@gmail.com> | 2008-08-01 06:39:04 +0000 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2008-08-01 06:39:04 +0000 |
commit | 010c8431b082740e5156b9623ba9495fc0dd1c52 (patch) | |
tree | ec83481332253879383aa1ce920be321ed0d0f2d /bfd/elf.c | |
parent | 3823320924933c184884f72d6a29710cd186d334 (diff) | |
download | gdb-010c8431b082740e5156b9623ba9495fc0dd1c52.zip gdb-010c8431b082740e5156b9623ba9495fc0dd1c52.tar.gz gdb-010c8431b082740e5156b9623ba9495fc0dd1c52.tar.bz2 |
* elf.c (rewrite_elf_program_header): Don't wrap p_paddr to
include file or program headers.
Diffstat (limited to 'bfd/elf.c')
-rw-r--r-- | bfd/elf.c | 33 |
1 files changed, 23 insertions, 10 deletions
@@ -5559,19 +5559,32 @@ rewrite_elf_program_header (bfd *ibfd, bfd *obfd) /* Offset the segment physical address from the lma to allow for space taken up by elf headers. */ if (map->includes_filehdr) - map->p_paddr -= iehdr->e_ehsize; + { + if (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) { - map->p_paddr -= iehdr->e_phnum * iehdr->e_phentsize; - - /* iehdr->e_phnum is just an estimate of the number - of program headers that we will need. Make a note - here of the number we used and the segment we chose - to hold these headers, so that we can adjust the - offset when we know the correct value. */ - phdr_adjust_num = iehdr->e_phnum; - phdr_adjust_seg = map; + if (map->p_paddr >= iehdr->e_phnum * iehdr->e_phentsize) + { + map->p_paddr -= iehdr->e_phnum * iehdr->e_phentsize; + + /* iehdr->e_phnum is just an estimate of the number + of program headers that we will need. Make a note + here of the number we used and the segment we chose + to hold these headers, so that we can adjust the + offset when we know the correct value. */ + phdr_adjust_num = iehdr->e_phnum; + phdr_adjust_seg = map; + } + else + map->includes_phdrs = FALSE; } } |