aboutsummaryrefslogtreecommitdiff
path: root/bfd/elf.c
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@airs.com>1995-11-29 19:14:33 +0000
committerIan Lance Taylor <ian@airs.com>1995-11-29 19:14:33 +0000
commit44ef8897daee098e361b279406693bc6849c61e5 (patch)
treeaf250e30c84b8bc2239fe857c964abe46ceedeac /bfd/elf.c
parent27fb8f2933cd65eb68179a79f0078034f20cfb2c (diff)
downloadgdb-44ef8897daee098e361b279406693bc6849c61e5.zip
gdb-44ef8897daee098e361b279406693bc6849c61e5.tar.gz
gdb-44ef8897daee098e361b279406693bc6849c61e5.tar.bz2
* elf.c (assign_file_positions_for_segments): Fix case where extra
program headers were allocated.
Diffstat (limited to 'bfd/elf.c')
-rw-r--r--bfd/elf.c19
1 files changed, 8 insertions, 11 deletions
diff --git a/bfd/elf.c b/bfd/elf.c
index b00997f..ba00bc8 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -1835,13 +1835,15 @@ assign_file_positions_for_segments (abfd)
{
unsigned int i;
asection **secpp;
- boolean adjusted;
p->p_type = m->p_type;
if (m->p_flags_valid)
p->p_flags = m->p_flags;
+ if (p->p_type == PT_LOAD && m->count > 0)
+ off += (m->sections[0]->vma - off) % bed->maxpagesize;
+
if (m->count == 0)
p->p_vaddr = 0;
else
@@ -1864,7 +1866,6 @@ assign_file_positions_for_segments (abfd)
p->p_filesz = 0;
p->p_memsz = 0;
- adjusted = false;
if (p->p_type == PT_LOAD)
{
p->p_offset = off;
@@ -1890,7 +1891,6 @@ assign_file_positions_for_segments (abfd)
p->p_memsz = off;
p->p_vaddr -= off;
p->p_paddr -= off;
- adjusted = true;
}
if (mi->p_type == PT_PHDR)
pi_phdr = pi;
@@ -1927,14 +1927,11 @@ assign_file_positions_for_segments (abfd)
adjust = (sec->vma - off) % bed->maxpagesize;
if (adjust != 0)
{
- if (i == 0 && ! adjusted)
- p->p_offset += adjust;
- else
- {
- p->p_memsz += adjust;
- if ((flags & SEC_LOAD) != 0)
- p->p_filesz += adjust;
- }
+ if (i == 0)
+ abort ();
+ p->p_memsz += adjust;
+ if ((flags & SEC_LOAD) != 0)
+ p->p_filesz += adjust;
off += adjust;
}