summaryrefslogtreecommitdiff
path: root/boot
diff options
context:
space:
mode:
authorRoland McGrath <roland@gnu.org>1995-05-13 22:20:43 +0000
committerRoland McGrath <roland@gnu.org>1995-05-13 22:20:43 +0000
commit9e835c5ded1b21f323dac18bcf84870c1cbb13f9 (patch)
tree980d6306f4cd0c922fae7b5028b32905599ce1e2 /boot
parente0d736bf81d5e9aa8b5cfdb244ec5c83baa1e91e (diff)
(load_image): Fixed alignment calculation in ELF segment loading.
Diffstat (limited to 'boot')
-rw-r--r--boot/boot.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/boot/boot.c b/boot/boot.c
index 869da3e5..9ab14725 100644
--- a/boot/boot.c
+++ b/boot/boot.c
@@ -283,11 +283,13 @@ load_image (task_t t,
vm_allocate (mach_task_self (), &buf, bufsz, 1);
lseek (fd, ph->p_offset, SEEK_SET);
read (fd, buf + (ph->p_offset & (ph->p_align - 1)), ph->p_filesz);
+ ph->p_memsz = ((ph->p_vaddr + ph->p_memsz + ph->p_align - 1)
+ & ~(ph->p_align - 1));
ph->p_vaddr &= ~(ph->p_align - 1);
- ph->p_memsz += ph->p_align - 1;
- ph->p_memsz &= ~(ph->p_align - 1);
+ ph->p_memsz -= ph->p_vaddr;
vm_allocate (t, (vm_address_t*)&ph->p_vaddr, ph->p_memsz, 0);
- vm_write (t, ph->p_vaddr, (vm_address_t)buf, bufsz);
+ vm_write (t, ph->p_vaddr, buf, bufsz);
+ vm_deallocate (mach_task_self (), buf, bufsz);
vm_protect (t, ph->p_vaddr, ph->p_memsz, 0,
((ph->p_flags & PF_R) ? VM_PROT_READ : 0) |
((ph->p_flags & PF_W) ? VM_PROT_WRITE : 0) |