mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-01-31 03:27:39 +00:00
[metal] Fix regression causing early crash in __new_page( ) (#900)
There was a glitch in the refactoring of __map_phdrs( ) in
commit ec480f5aa0
, which caused it to try to map the PT_NOTE
program segment into virtual memory, which in turn caused the
memory page at BANE to be wrongly remapped to the start of
the program image (0x100000) rather than physical address 0.
This affected subsequent page allocation operations because
the `struct mman` was located at BANE + 0x0500.
Co-authored-by: tkchia <tkchia-cosmo@gmx.com>
This commit is contained in:
parent
b01282e23e
commit
fcdda40f19
1 changed files with 2 additions and 0 deletions
|
@ -263,6 +263,7 @@ static textreal uint64_t __map_phdr(struct mman *mm, uint64_t *pml4t,
|
|||
uint64_t b, uint64_t m,
|
||||
struct Elf64_Phdr *p) {
|
||||
uint64_t i, f, v;
|
||||
if (p->p_type != PT_LOAD) return m;
|
||||
f = PAGE_RSRV | PAGE_U;
|
||||
if (p->p_flags & PF_W)
|
||||
f |= PAGE_V | PAGE_RW;
|
||||
|
@ -303,6 +304,7 @@ textreal void __map_phdrs(struct mman *mm, uint64_t *pml4t, uint64_t b,
|
|||
}
|
||||
m = __map_phdr(mm, pml4t, b, m,
|
||||
&(struct Elf64_Phdr){
|
||||
.p_type = PT_LOAD,
|
||||
.p_flags = (uintptr_t)ape_stack_pf,
|
||||
.p_offset = (uintptr_t)ape_stack_offset,
|
||||
.p_vaddr = ABS64(ape_stack_vaddr),
|
||||
|
|
Loading…
Reference in a new issue