Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ xxhash-rust = "0.8.15"
ntest = "0.9.5"
terminal_size = "0.4"
zstd = "0.14"
fspy_elf_loader = { path = "crates/fspy_elf_loader" }

[workspace.metadata.cargo-shear]
ignored = [
Expand Down
4 changes: 3 additions & 1 deletion crates/fspy_elf_loader/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[package]
name = "fspy_elf_loader"
version = "0.1.0"
links = "fspy_elf_loader"
authors.workspace = true
edition.workspace = true
license.workspace = true
Expand All @@ -10,7 +11,8 @@ rust-version.workspace = true
[target.'cfg(any(target_os = "linux", target_os = "none"))'.dependencies]
elf = { workspace = true }
fspy_nostd = { workspace = true }
linux-raw-sys = { workspace = true, features = ["auxvec", "no_std"] }
linux-raw-sys = { workspace = true, features = ["auxvec", "errno", "general", "no_std", "prctl"] }
syscalls = { workspace = true }

[target.'cfg(target_os = "linux")'.dev-dependencies]
tempfile = { workspace = true }
Expand Down
5 changes: 3 additions & 2 deletions crates/fspy_elf_loader/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ the kernel will not, once it never sees the target.

## Support

Native little-endian ELF64 on x86-64 and AArch64. `PT_GNU_STACK` must be
non-executable. `ET_EXEC` that overlaps any retained mapping is rejected.
Native little-endian ELF64 on x86-64 and AArch64. An executable `PT_GNU_STACK`
maps the stack executable, as Linux does. `ET_EXEC` that overlaps any retained
mapping is rejected.

| | `PT_INTERP` | no `PT_INTERP` |
| --------- | ------------------------------------------------- | -------------------------------------------------- |
Expand Down
20 changes: 20 additions & 0 deletions crates/fspy_elf_loader/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
include!("src/launcher_region.rs");

fn main() {
println!("cargo::rerun-if-changed=build.rs");
println!("cargo::rerun-if-changed=src/launcher_region.rs");
if std::env::var("CARGO_CFG_TARGET_OS").as_deref() == Ok("none") {
// Leave the low 4 GiB available while staying in application regions
// of the current LLVM Linux ASan and C/C++ TSan layouts. AArch64's
// base also fits smaller virtual address spaces, including 39-bit.
// Older AArch64 TSan runtimes can reject 8 GiB; see the README.
// This is a placement convention; fixed targets can still overlap it.
let image_base = match std::env::var("CARGO_CFG_TARGET_ARCH").as_deref() {
Ok("x86_64") => LAUNCHER_REGION_X86_64.0, // 85 TiB
Ok("aarch64") => LAUNCHER_REGION_AARCH64.0, // 8 GiB
_ => panic!("unsupported launcher architecture"),
};
// Fixed linking resolves pointers without a startup self-relocator.
println!("cargo::metadata=link_args=--no-pie --image-base={image_base:#x}");
}
}
Loading
Loading