diff options
author | Ian Moffett <ian@osmora.org> | 2025-09-16 20:47:29 -0400 |
---|---|---|
committer | Ian Moffett <ian@osmora.org> | 2025-09-16 20:47:29 -0400 |
commit | 43c0f3a7914a5ff45eace344556244699ee0c206 (patch) | |
tree | 85bedc84347386840c5404791a1f279534f8a376 | |
parent | d17f846427d32a104338cebccde9799c56587304 (diff) |
kern: elf: Don't load blank program headers
Signed-off-by: Ian Moffett <ian@osmora.org>
-rw-r--r-- | src/sys/os/os_elf64.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/src/sys/os/os_elf64.c b/src/sys/os/os_elf64.c index 8f95f9c..ad13424 100644 --- a/src/sys/os/os_elf64.c +++ b/src/sys/os/os_elf64.c @@ -119,11 +119,6 @@ elf64_do_load(Elf64_Ehdr *eh, struct proc *proc) prot = 0; phdr = PHDR_I(phdr_base, i); - /* Don't cover blank segments */ - if (phdr->p_memsz == 0) { - continue; - } - /* What segment type is this? */ switch (phdr->p_type) { case PT_LOAD: @@ -134,6 +129,10 @@ elf64_do_load(Elf64_Ehdr *eh, struct proc *proc) if (ISSET(phdr->p_flags, PF_X)) prot |= PROT_EXEC; + if (phdr->p_memsz == 0 && phdr->p_filesz == 0) { + continue; + } + /* Re-align the length */ misalign = phdr->p_memsz & (PSIZE - 1); len = phdr->p_memsz; |