diff --git a/Cargo.toml b/Cargo.toml index 4dc26b4..3430d60 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,9 +23,6 @@ maintenance = { status = "actively-developed" } is-it-maintained-issue-resolution = { repository = "enarx/vdso" } is-it-maintained-open-issues = { repository = "enarx/vdso" } -[dev-dependencies] -libc = "0.2.67" - [dependencies] -crt0stack = "0.1" goblin = "0.6.0" +libc = "0.2.67" diff --git a/src/lib.rs b/src/lib.rs index 4dbca93..73b9af8 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -5,7 +5,6 @@ #![deny(missing_docs)] #![deny(clippy::all)] -use crt0stack::{Entry, Reader}; use std::ffi::CStr; use std::os::raw::c_char; use std::slice::from_raw_parts; @@ -112,14 +111,13 @@ pub struct Vdso<'a>(&'a Header); impl Vdso<'static> { /// Locates the vDSO by parsing the auxiliary vectors pub fn locate() -> Option { - for aux in Reader::from_environ().done() { - if let Entry::SysInfoEHdr(addr) = aux { - let hdr = unsafe { Header::from_ptr(&*(addr as *const _))? }; - return Some(Self(hdr)); - } + let val = unsafe { libc::getauxval(libc::AT_SYSINFO_EHDR) }; + // getauxval returns 0 if entry was not found + if val == 0 { + return None; } - - None + let hdr = unsafe { Header::from_ptr(&*(val as *const _))? }; + Some(Self(hdr)) } }