diff --git a/Cargo.toml b/Cargo.toml index a2adecf..d3ac463 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,14 +2,14 @@ name = "phdrs" version = "0.1.0" authors = ["Edd Barrett "] -edition = "2018" +edition = "2024" license = "Apache-2.0 OR MIT" [dependencies] -libc = { version = "0.2.94", default-features = false } -core = { version = "1.0.0", optional = true, package = 'rustc-std-workspace-core' } -compiler_builtins = { version = "0.1.16", optional = true } -alloc = { version = "1.0.0", optional = true, package = "rustc-std-workspace-alloc" } +libc = { version = "0.2.172", default-features = false } +core = { version = "1.0.1", optional = true, package = 'rustc-std-workspace-core' } +compiler_builtins = { version = "0.1.156", optional = true } +alloc = { version = "1.0.1", optional = true, package = "rustc-std-workspace-alloc" } [features] default = ["std"] diff --git a/src/lib.rs b/src/lib.rs index 0a1f654..989f9a2 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -2,11 +2,11 @@ #![cfg(not(feature = "rustc-dep-of-std"))] extern crate alloc; -use libc::{c_int, c_void, dl_iterate_phdr, dl_phdr_info}; pub use libc::{ - PF_MASKPROC, PT_DYNAMIC, PT_GNU_EH_FRAME, PT_GNU_RELRO, PT_HIOS, PT_HIPROC, PT_INTERP, PT_LOAD, - PT_LOOS, PT_LOPROC, PT_NOTE, PT_NULL, PT_PHDR, PT_SHLIB, PT_TLS, + PF_MASKPROC, PF_R, PF_W, PF_X, PT_DYNAMIC, PT_GNU_EH_FRAME, PT_GNU_RELRO, PT_HIOS, PT_HIPROC, + PT_INTERP, PT_LOAD, PT_LOOS, PT_LOPROC, PT_NOTE, PT_NULL, PT_PHDR, PT_SHLIB, PT_TLS, }; +use libc::{c_int, c_void, dl_iterate_phdr, dl_phdr_info}; use core::{ ffi::CStr, @@ -32,13 +32,6 @@ use libc::{ Elf32_Word as Elf_Word, Elf32_Xword as Elf_Xword, }; -/// Executable program segment -const PF_X: u32 = 1; -/// Writable program segment -const PF_W: u32 = 2; -/// Readable program segment -const PF_R: u32 = 4; - /// Contains information about an "object" in the virtual address space. /// This corresponds with a `dl_phdr_info` in C. Note that the contents of the C struct differ /// between platforms. We expose only the common fields for now. @@ -244,7 +237,8 @@ pub fn objects() -> Vec { _sz: usize, data: *mut c_void, ) -> c_int { - push_object(&mut *(data as *mut Vec), &*info); // Get Rust to push the object. + let data = data as *mut Vec; + push_object(unsafe { &mut *data }, unsafe { &*info }); 0 }