summaryrefslogtreecommitdiff
path: root/src/user/lib/elfload.c
diff options
context:
space:
mode:
authordzwdz2023-01-25 20:16:22 +0100
committerdzwdz2023-01-25 20:16:22 +0100
commit17bfb0ef0a48330b1d54e61fe3c30d83528d2d90 (patch)
treeb3d4aed1f408edcb17fe5c86fccaeacaa2a5a48a /src/user/lib/elfload.c
parent2ad6ee8ed15d1bf898645a16dbc06991a3c1425e (diff)
style: typedef structs, shorter namespaces
I've wanted to do this for a while, and since I've just had a relatively large refactor commit (pcpy), this is as good of a time as any. Typedefing structs was mostly inspired by Plan 9's coding style. It makes some lines of code much shorter at basically no expense. Everything related to userland kept old-style struct definitions, so as not to force that style onto other people. I also considered changing SCREAMING_ENUM_FIELDS to NicerLookingCamelcase, but I didn't, just in case that'd be confusing.
Diffstat (limited to 'src/user/lib/elfload.c')
-rw-r--r--src/user/lib/elfload.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/user/lib/elfload.c b/src/user/lib/elfload.c
index a4ee91e..cb7ce58 100644
--- a/src/user/lib/elfload.c
+++ b/src/user/lib/elfload.c
@@ -46,7 +46,7 @@ static bool load_phdr(const void *elf, void *exebase, size_t idx) {
}
// TODO overlap check
// TODO don't ignore flags
- _syscall_memflag(exebase + phdr->p_vaddr, phdr->p_memsz, MEMFLAG_PRESENT);
+ _sys_memflag(exebase + phdr->p_vaddr, phdr->p_memsz, MEMFLAG_PRESENT);
// TODO check that filesz <= memsz
memcpy(exebase + phdr->p_vaddr, elf + phdr->p_offset, phdr->p_filesz);
return true;
@@ -122,8 +122,8 @@ void _freejmp(void *entry, void *low, size_t imglen, const char **argv, char **e
uintptr_t high = (uintptr_t)low + imglen;
uint64_t buf[] = {
- EXECBUF_SYSCALL, _SYSCALL_MEMFLAG, 0, (uintptr_t)low, 0, 0, 0,
- EXECBUF_SYSCALL, _SYSCALL_MEMFLAG, high, ~0 - 0xF000 - high, 0, 0, 0,
+ EXECBUF_SYSCALL, _SYS_MEMFLAG, 0, (uintptr_t)low, 0, 0, 0,
+ EXECBUF_SYSCALL, _SYS_MEMFLAG, high, ~0 - 0xF000 - high, 0, 0, 0,
EXECBUF_JMP, (uintptr_t)entry,
};
execbuf_chstack(stack, buf, sizeof buf);
@@ -137,7 +137,7 @@ static void *elf_loadmem(struct Elf64_Ehdr *ehdr) {
exebase = (void*)0;
break;
case ET_DYN:
- exebase = _syscall_memflag((void*)0x1000, spread, MEMFLAG_FINDFREE);
+ exebase = _sys_memflag((void*)0x1000, spread, MEMFLAG_FINDFREE);
if (!exebase)
return NULL;
break;
@@ -146,7 +146,7 @@ static void *elf_loadmem(struct Elf64_Ehdr *ehdr) {
}
for (size_t phi = 0; phi < ehdr->e_phnum; phi++) {
if (!load_phdr((void*)ehdr, exebase, phi)) {
- _syscall_memflag(exebase, spread, 0);
+ _sys_memflag(exebase, spread, 0);
return NULL;
}
}
@@ -160,7 +160,7 @@ void elf_exec(void *base, char **argv, char **envp) {
void *exebase = elf_loadmem(ehdr);
if (!exebase) return;
- void *newstack = _syscall_memflag((void*)0x11000, 0x1000, MEMFLAG_FINDFREE | MEMFLAG_PRESENT);
+ void *newstack = _sys_memflag((void*)0x11000, 0x1000, MEMFLAG_FINDFREE | MEMFLAG_PRESENT);
if (!newstack) return;
_freejmp_chstack(exebase + ehdr->e_entry, exebase, elf_spread(ehdr) + 0x1000, (const char**)argv, envp, newstack);