Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch from .init_array constructors to /proc/self/auxv. #385

Merged
merged 9 commits into from Aug 8, 2022
13 changes: 12 additions & 1 deletion Cargo.toml
Expand Up @@ -100,7 +100,13 @@ targets = [
]

[features]
default = ["std"]

# By default, use `std` and use libc for aux values.
#
# It turns out to be bizarrely awkward to obtain the aux values reliably and
# efficiently on Linux from anywhere other than libc. We can do it, but most
# users are better served by just using libc for this.
default = ["std", "use-libc-auxv"]

# This enables use of std. Disabling this enables `#![no_std], and requires
# nightly Rust.
Expand Down Expand Up @@ -170,6 +176,11 @@ all-apis = [
"time",
]

# When using the linux_raw backend, and not using Mustang, should we use libc
# for reading the aux vectors, instead of reading them ourselves from
# /proc/self/auxv?
use-libc-auxv = ["libc"]

# Expose io-lifetimes' features for third-party crate impls.
async-std = ["io-lifetimes/async-std"]
tokio = ["io-lifetimes/tokio"]
Expand Down
12 changes: 0 additions & 12 deletions src/backend/libc/param/auxv.rs
Expand Up @@ -52,15 +52,3 @@ pub(crate) fn linux_execfn() -> &'static CStr {
cstr!("")
}
}

/// Initialize process-wide state.
#[cfg(any(
target_vendor = "mustang",
not(any(target_env = "gnu", target_env = "musl")),
))]
#[inline]
#[doc(hidden)]
pub(crate) unsafe fn init(_envp: *mut *mut u8) {
// Nothing to do. This is the libc backend, and libc does the
// initialization for us.
}
4 changes: 4 additions & 0 deletions src/backend/linux_raw/elf.rs
@@ -1,6 +1,10 @@
//! The ELF ABI.

#![allow(non_snake_case)]
#![cfg_attr(
all(not(target_vendor = "mustang"), feature = "use-libc-auxv"),
allow(dead_code)
)]

pub(super) const SELFMAG: usize = 4;
pub(super) const ELFMAG: [u8; SELFMAG] = [0x7f, b'E', b'L', b'F'];
Expand Down