Skip to content
Merged
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
10 changes: 5 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
name = "phdrs"
version = "0.1.0"
authors = ["Edd Barrett <[email protected]>"]
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"]
Expand Down
16 changes: 5 additions & 11 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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.
Expand Down Expand Up @@ -244,7 +237,8 @@ pub fn objects() -> Vec<Object> {
_sz: usize,
data: *mut c_void,
) -> c_int {
push_object(&mut *(data as *mut Vec<Object>), &*info); // Get Rust to push the object.
let data = data as *mut Vec<Object>;
push_object(unsafe { &mut *data }, unsafe { &*info });
0
}

Expand Down