git://scm.lunaixsky.com
/
lunaix-os.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Unifying the Lunaix's Physical Memory Model (#28)
[lunaix-os.git]
/
lunaix-os
/
kernel
/
exe
/
elf32
/
ldelf32.c
diff --git
a/lunaix-os/kernel/exe/elf32/ldelf32.c
b/lunaix-os/kernel/exe/elf32/ldelf32.c
index 97db4bdcfb43609fbc04ce3915d49ebdd9da49f1..69ae939a0c2f7595a6b1888f3891002f8ae4ddd7 100644
(file)
--- a/
lunaix-os/kernel/exe/elf32/ldelf32.c
+++ b/
lunaix-os/kernel/exe/elf32/ldelf32.c
@@
-1,10
+1,11
@@
#include <lunaix/exebi/elf32.h>
#include <lunaix/load.h>
#include <lunaix/mm/mmap.h>
#include <lunaix/exebi/elf32.h>
#include <lunaix/load.h>
#include <lunaix/mm/mmap.h>
-#include <lunaix/mm/page.h>
#include <lunaix/mm/valloc.h>
#include <lunaix/spike.h>
#include <lunaix/mm/valloc.h>
#include <lunaix/spike.h>
+#include <sys/mm/mempart.h>
+
int
elf32_smap(struct load_context* ldctx,
const struct elf32* elf,
int
elf32_smap(struct load_context* ldctx,
const struct elf32* elf,
@@
-13,7
+14,7
@@
elf32_smap(struct load_context* ldctx,
{
struct v_file* elfile = (struct v_file*)elf->elf_file;
{
struct v_file* elfile = (struct v_file*)elf->elf_file;
- assert(
PG_ALIGNED
(phdre->p_offset));
+ assert(
!va_offset
(phdre->p_offset));
int proct = 0;
if ((phdre->p_flags & PF_R)) {
int proct = 0;
if ((phdre->p_flags & PF_R)) {
@@
-29,24
+30,23
@@
elf32_smap(struct load_context* ldctx,
uintptr_t va = phdre->p_va + base_va;
struct exec_container* container = ldctx->container;
struct mmap_param param = { .vms_mnt = container->vms_mnt,
uintptr_t va = phdre->p_va + base_va;
struct exec_container* container = ldctx->container;
struct mmap_param param = { .vms_mnt = container->vms_mnt,
- .pvms =
&container->proc->mm
,
+ .pvms =
vmspace(container->proc)
,
.proct = proct,
.proct = proct,
- .offset = PG_ALIGN(phdre->p_offset),
- .mlen = ROUNDUP(phdre->p_memsz, PG_SIZE),
- .flen = phdre->p_filesz,
+ .offset = page_aligned(phdre->p_offset),
+ .mlen = page_upaligned(phdre->p_memsz),
.flags = MAP_FIXED | MAP_PRIVATE,
.type = REGION_TYPE_CODE };
struct mm_region* seg_reg;
.flags = MAP_FIXED | MAP_PRIVATE,
.type = REGION_TYPE_CODE };
struct mm_region* seg_reg;
- int status = m
em_map(NULL, &seg_reg, PG_ALIGN
(va), elfile, ¶m);
+ int status = m
map_user(NULL, &seg_reg, page_aligned
(va), elfile, ¶m);
if (!status) {
size_t next_addr = phdre->p_memsz + va;
if (!status) {
size_t next_addr = phdre->p_memsz + va;
- ldctx->end = MAX(ldctx->end,
ROUNDUP(next_addr, PG_SIZE
));
+ ldctx->end = MAX(ldctx->end,
page_upaligned(next_addr
));
ldctx->mem_sz += phdre->p_memsz;
} else {
// we probably fucked up our process
ldctx->mem_sz += phdre->p_memsz;
} else {
// we probably fucked up our process
- terminate_
proc
(-1);
+ terminate_
current
(-1);
}
return status;
}
return status;
@@
-75,8
+75,8
@@
load_executable(struct load_context* context, const struct v_file* exefile)
goto done;
}
goto done;
}
- ldpath = valloc(
512
);
- errno = elf32_find_loader(&elf, ldpath,
512
);
+ ldpath = valloc(
256
);
+ errno = elf32_find_loader(&elf, ldpath,
256
);
uintptr_t load_base = 0;
if (errno < 0) {
uintptr_t load_base = 0;
if (errno < 0) {
@@
-102,7
+102,7
@@
load_executable(struct load_context* context, const struct v_file* exefile)
goto done_close_elf32;
}
goto done_close_elf32;
}
- load_base = U
MMAP_START
;
+ load_base = U
SR_MMAP
;
}
context->entry = elf.eheader.e_entry + load_base;
}
context->entry = elf.eheader.e_entry + load_base;
@@
-116,7
+116,7
@@
load_executable(struct load_context* context, const struct v_file* exefile)
continue;
}
continue;
}
- if (phdr->p_align != P
G
_SIZE) {
+ if (phdr->p_align != P
AGE
_SIZE) {
// surprising alignment!
errno = ENOEXEC;
break;
// surprising alignment!
errno = ENOEXEC;
break;
@@
-129,6
+129,8
@@
done_close_elf32:
elf32_close(&elf);
done:
elf32_close(&elf);
done:
- vfree_safe(ldpath);
+ if (!container->argv_pp[1]) {
+ vfree_safe(ldpath);
+ }
return errno;
}
return errno;
}