pub enum AuxVar<'a> {
Show 34 variants
Null,
Ignore,
ExecFd(usize),
Phdr(*const u8),
Phent(usize),
Phnum(usize),
Pagesz(usize),
Base(*const u8),
Flags(AuxVarFlags),
Entry(*const u8),
NotElf(bool),
Uid(usize),
EUid(usize),
Gid(usize),
EGid(usize),
Platform(AuxVarString<'a>),
HwCap(usize),
Clktck(usize),
Secure(bool),
BasePlatform(AuxVarString<'a>),
Random([u8; 16]),
HwCap2(usize),
ExecFn(AuxVarString<'a>),
Sysinfo(*const u8),
SysinfoEhdr(*const u8),
L1iCacheSize(usize),
L1iCacheGeometry(usize),
L1dCacheSize(usize),
L1dCacheGeometry(usize),
L2CacheSize(usize),
L2CacheGeometry(usize),
L3CacheSize(usize),
L3CacheGeometry(usize),
MinSigStkSz(usize),
}
Expand description
High-level version of an auxiliary vector (auxv
) entry. Also called
Auxiliary Variable or AT Variable.
The data/payload is either an immediate value embedded into the enum variant
or a pointer into the auxv
data area. The enum variant’s payload does not
necessarily correspond to the ABI.
§More Info
Variants§
Null
Entry with payload for type AuxVarType::Null
.
Ignore
Entry with payload for type AuxVarType::Ignore
.
ExecFd(usize)
Entry with payload for type AuxVarType::ExecFd
.
Phdr(*const u8)
Entry with payload for type AuxVarType::Phdr
.
Phent(usize)
Entry with payload for type AuxVarType::Phent
.
Phnum(usize)
Entry with payload for type AuxVarType::Phnum
.
Pagesz(usize)
Entry with payload for type AuxVarType::Pagesz
.
Base(*const u8)
Entry with payload for type AuxVarType::Base
.
Flags(AuxVarFlags)
Entry with payload for type AuxVarType::Flags
.
Entry(*const u8)
Entry with payload for type AuxVarType::Entry
.
NotElf(bool)
Entry with payload for type AuxVarType::NotElf
.
Uid(usize)
Entry with payload for type AuxVarType::Uid
.
EUid(usize)
Entry with payload for type AuxVarType::EUid
.
Gid(usize)
Entry with payload for type AuxVarType::Gid
.
EGid(usize)
Entry with payload for type AuxVarType::EGid
.
Platform(AuxVarString<'a>)
Entry with payload for type AuxVarType::Platform
.
HwCap(usize)
Entry with payload for type AuxVarType::HwCap
.
Clktck(usize)
Entry with payload for type AuxVarType::Clktck
.
Secure(bool)
Entry with payload for type AuxVarType::Secure
.
BasePlatform(AuxVarString<'a>)
Entry with payload for type AuxVarType::BasePlatform
.
Random([u8; 16])
Entry with payload for type AuxVarType::Random
.
HwCap2(usize)
Entry with payload for type AuxVarType::HwCap2
.
ExecFn(AuxVarString<'a>)
Entry with payload for type AuxVarType::ExecFn
.
Sysinfo(*const u8)
Entry with payload for type AuxVarType::Sysinfo
.
SysinfoEhdr(*const u8)
Entry with payload for type AuxVarType::SysinfoEhdr
.
L1iCacheSize(usize)
Entry with payload for type AuxVarType::L1iCacheSize
.
L1iCacheGeometry(usize)
Entry with payload for type AuxVarType::L1iCacheGeometry
.
L1dCacheSize(usize)
Entry with payload for type AuxVarType::L1dCacheSize
.
L1dCacheGeometry(usize)
Entry with payload for type AuxVarType::L1dCacheGeometry
.
L2CacheSize(usize)
Entry with payload for type AuxVarType::L2CacheSize
.
L2CacheGeometry(usize)
Entry with payload for type AuxVarType::L2CacheGeometry
.
L3CacheSize(usize)
Entry with payload for type AuxVarType::L3CacheSize
.
L3CacheGeometry(usize)
Entry with payload for type AuxVarType::L3CacheGeometry
.
MinSigStkSz(usize)
Entry with payload for type AuxVarType::MinSigStkSz
.
Implementations§
Source§impl<'a> AuxVar<'a>
impl<'a> AuxVar<'a>
Sourcepub const fn key(&self) -> AuxVarType
pub const fn key(&self) -> AuxVarType
Returns the AuxVarType
this aux var corresponds to.
Examples found in repository?
31fn main(argc: isize, argv: *const *const u8) -> isize {
32 let buffer = unsafe {
33 // 100 KiB, reasonably big.
34 // On my Linux machine, the structure needs 23 KiB
35 slice::from_raw_parts(argv.cast::<u8>(), 0x19000)
36 };
37
38 let parsed = StackLayoutRef::new(buffer, Some(argc as usize));
39
40 println!("There are {} arguments.", parsed.argc());
41 println!(" argv (raw)");
42 for (i, arg) in parsed.argv_raw_iter().enumerate() {
43 println!(" [{i}] @ {arg:?}");
44 }
45 println!(" argv");
46 // SAFETY: The pointers are valid in the address space of this process.
47 for (i, arg) in unsafe { parsed.argv_iter() }.enumerate() {
48 println!(" [{i}] {arg:?}");
49 }
50
51 println!("There are {} environment variables.", parsed.envc());
52 println!(" envv (raw)");
53 for (i, env) in parsed.envv_raw_iter().enumerate() {
54 println!(" [{i}] {env:?}");
55 }
56 println!(" envv");
57 // SAFETY: The pointers are valid in the address space of this process.
58 for (i, env) in unsafe { parsed.envv_iter() }.enumerate() {
59 println!(" [{i}] {env:?}");
60 }
61
62 println!(
63 "There are {} auxiliary vector entries/AT variables.",
64 parsed.auxv_raw_iter().count()
65 );
66 println!(" aux");
67 // ptr iter is safe for other address spaces; the other only because here user_addr == write_addr
68 for aux in unsafe { parsed.auxv_iter() } {
69 if aux.key().value_in_data_area() {
70 println!(" {:?} => @ {:?}", aux.key(), aux);
71 } else {
72 println!(" {:?} => {:?}", aux.key(), aux);
73 }
74 }
75
76 0
77}
Sourcepub fn value_raw(&self) -> usize
pub fn value_raw(&self) -> usize
Transforms any inner value into it’s corresponding serialized usize value.
This only works for variants that do not reference data exceeding the
size of an usize
.
Sourcepub const fn value_integer(&self) -> Option<usize>
pub const fn value_integer(&self) -> Option<usize>
Returns a value if the corresponding entry corresponds to a basic value/integer, and not a pointer, flags, or a boolean.
Sourcepub const fn value_flags(&self) -> Option<AuxVarFlags>
pub const fn value_flags(&self) -> Option<AuxVarFlags>
Returns the AuxVarFlags
if the corresponding entry is of type
AuxVarType::Flags
.
Sourcepub const fn value_boolean(&self) -> Option<bool>
pub const fn value_boolean(&self) -> Option<bool>
Returns a value if the corresponding entry corresponds to a boolean, and not a pointer, flags, or a basic value/integer.
Sourcepub const fn value_ptr(&self) -> Option<*const u8>
pub const fn value_ptr(&self) -> Option<*const u8>
Returns a value if the corresponding entry corresponds to a pointer, and not a boolean, flags, or a basic value/integer.
This only affects entries that point to memory outside the stack layout, i.e., the aux vector data area.
Sourcepub fn value_payload_bytes(&'a self) -> Option<&'a [u8]>
pub fn value_payload_bytes(&'a self) -> Option<&'a [u8]>
Returns a value, if the corresponding auxiliary vector entry references data in the
auxiliary vector data area of the data structure.
This returns only something for AuxVarType::Random
.
This function is safe, because the creation during parsing already guarantee memory safety (the addresses are accessed).
Sourcepub const fn value_payload_str(&'a self) -> Option<&'a AuxVarString<'a>>
pub const fn value_payload_str(&'a self) -> Option<&'a AuxVarString<'a>>
Returns a value, if the corresponding auxiliary vector entry references data in the
auxiliary vector data area of the data structure.
This returns only something for AuxVarType::Random
.
This function is safe, because the creation during parsing already guarantee memory safety (the addresses are accessed).