From 4fbb8ec338dadf52109ca731316da8c15ff1d01e Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Fri, 20 Feb 2026 11:54:52 +1100 Subject: [PATCH 1/4] fix(redox-rt): add base address to `e_entry` Signed-off-by: Anhad Singh --- redox-rt/src/proc.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/redox-rt/src/proc.rs b/redox-rt/src/proc.rs index f094733896..d314b6805e 100644 --- a/redox-rt/src/proc.rs +++ b/redox-rt/src/proc.rs @@ -227,7 +227,7 @@ pub fn fexec_impl( return Ok(FexecResult::Interp { path: interpreter_path, interp_override: InterpOverride { - at_entry: header.e_entry as usize, + at_entry: base_addr + header.e_entry as usize, at_phnum: phnum, at_phent: phentsize, phdrs_vaddr, @@ -297,7 +297,7 @@ pub fn fexec_impl( push(r#override.phdrs_vaddr)?; push(AT_PHDR)?; } else { - push(header.e_entry as usize)?; + push(base_addr + header.e_entry as usize)?; push(AT_ENTRY)?; push(phdrs_vaddr)?; push(AT_PHDR)?; From 4c0d4c79633c4ccec83e91e92f4033b2a6417da6 Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Fri, 20 Feb 2026 11:58:28 +1100 Subject: [PATCH 2/4] fix(redox-rt): update min mmap address for ET_EXEC Signed-off-by: Anhad Singh --- redox-rt/src/proc.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/redox-rt/src/proc.rs b/redox-rt/src/proc.rs index d314b6805e..05852690a1 100644 --- a/redox-rt/src/proc.rs +++ b/redox-rt/src/proc.rs @@ -135,13 +135,15 @@ pub fn fexec_impl( }); } let span = span.expect("ELF executables must contain at least one `PT_LOAD` segment"); + let span_size = (span.end - span.start).next_multiple_of(PAGE_SIZE); + let base_addr = if header.e_type == ET_DYN { // PIE - let span_size = (span.end - span.start).next_multiple_of(PAGE_SIZE); let addr = mmap_anon_remote(&grants_fd, 0, 0, span_size, MapFlags::PROT_NONE)?; update_min_mmap_addr(addr, span_size); addr } else { + update_min_mmap_addr(span.start, span_size); 0 }; From 09f52fd1630d8e8534c9a7e46e9de823d074df2d Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Fri, 20 Feb 2026 12:00:29 +1100 Subject: [PATCH 3/4] fix(redox-rt): FIXED_NOREPLACE for ET_EXEC Signed-off-by: Anhad Singh --- redox-rt/src/proc.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/redox-rt/src/proc.rs b/redox-rt/src/proc.rs index 05852690a1..bda825a893 100644 --- a/redox-rt/src/proc.rs +++ b/redox-rt/src/proc.rs @@ -143,6 +143,13 @@ pub fn fexec_impl( update_min_mmap_addr(addr, span_size); addr } else { + mmap_anon_remote( + &grants_fd, + 0, + span.start, + span_size, + MapFlags::MAP_FIXED_NOREPLACE, + )?; update_min_mmap_addr(span.start, span_size); 0 }; From 1c5668acd4a3c07dcfc490d3eb3ba86612184df9 Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Fri, 20 Feb 2026 16:30:49 +1100 Subject: [PATCH 4/4] feat(dso): do not zero memory The region is mapped with the `MAP_ANONYMOUS` and thus already initialised with zeros. According to POSIX Issue 8: > Anonymous memory objects shall be initialized to all bits zero. Signed-off-by: Anhad Singh --- src/ld_so/dso.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/ld_so/dso.rs b/src/ld_so/dso.rs index a4b4cbe129..6dfa71df71 100644 --- a/src/ld_so/dso.rs +++ b/src/ld_so/dso.rs @@ -558,7 +558,6 @@ impl DSO { ); } log::trace!(" = {:p}", ptr); - ptr::write_bytes(ptr.cast::(), 0, size); _r_debug .lock() .insert(ptr as usize, path, ptr as usize + l_ld as usize);