AuxVarType

Enum AuxVarType 

Source
#[repr(usize)]
pub enum AuxVarType {
Show 34 variants Null = 0, Ignore = 1, ExecFd = 2, Phdr = 3, Phent = 4, Phnum = 5, Pagesz = 6, Base = 7, Flags = 8, Entry = 9, NotElf = 10, Uid = 11, EUid = 12, Gid = 13, EGid = 14, Platform = 15, HwCap = 16, Clktck = 17, Secure = 23, BasePlatform = 24, Random = 25, HwCap2 = 26, ExecFn = 31, Sysinfo = 32, SysinfoEhdr = 33, L1iCacheSize = 40, L1iCacheGeometry = 41, L1dCacheSize = 42, L1dCacheGeometry = 43, L2CacheSize = 44, L2CacheGeometry = 45, L3CacheSize = 46, L3CacheGeometry = 47, MinSigStkSz = 51,
}
Expand description

Rust-style representation of the auxiliary variable’s type.

Also see AuxVar.

  • 0-17 are architecture independent
  • >=32 are for x86_64.
  • >=40 are for power PC.

§More Info

Variants§

§

Null = 0

end of vector

§

Ignore = 1

entry should be ignored

§

ExecFd = 2

file descriptor of program

§

Phdr = 3

program headers for program

§

Phent = 4

size of program header entry

§

Phnum = 5

number of program headers

§

Pagesz = 6

system page size

§

Base = 7

The base address of the program interpreter (usually, the dynamic linker).

§

Flags = 8

Flags that apply on the whole auxiliary vector. See crate::AuxVarFlags.

§

Entry = 9

entry point of program

§

NotElf = 10

program is not ELF

§

Uid = 11

real uid

§

EUid = 12

effective uid

§

Gid = 13

real gid

§

EGid = 14

effective gid

§

Platform = 15

string identifying CPU for optimizations

§

HwCap = 16

Arch dependent hints at CPU capabilities. On x86_64 these are the CPUID features.

§

Clktck = 17

frequency at which times() increments

§

Secure = 23

secure mode boolean

§

BasePlatform = 24

string identifying real platform, may differ from AtPlatform.

§

Random = 25

address of 16 random bytes

§

HwCap2 = 26

extension of AtHwcap

§

ExecFn = 31

filename of program, for example “./my_executable\0”

§

Sysinfo = 32

The entry point to the system call function in the vDSO. Not present/needed on all architectures (e.g., absent on x86-64).

§

SysinfoEhdr = 33

The address of a page containing the virtual Dynamic Shared Object (vDSO) that the kernel creates in order to provide fast implementations of certain system calls.

§

L1iCacheSize = 40

L1 instruction cache size

§

L1iCacheGeometry = 41

L1 instruction cache geometry

§

L1dCacheSize = 42

L1 cache geometry

§

L1dCacheGeometry = 43

L1 cache size

§

L2CacheSize = 44

L2 cache size

§

L2CacheGeometry = 45

L2 cache geometry

§

L3CacheSize = 46

L3 cache size

§

L3CacheGeometry = 47

L3 cache geometry

§

MinSigStkSz = 51

Minimal stack size for signal delivery.

Implementations§

Source§

impl AuxVarType

Source

pub const fn variants() -> &'static [Self]

Returns an array with all variants.

Source

pub const fn val(self) -> usize

Returns the underlying ABI-compatible integer value.

Source

pub const fn value_in_data_area(self) -> bool

If this is true, the value of the key should be interpreted as pointer into the aux vector data area. Otherwise, the value of the key is an immediate value/integer.

Examples found in repository?
examples/linux_print_layout.rs (line 69)
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}
Source

pub fn value_is_cstr(self) -> bool

The payload of entries where this returns true represents a null-terminated C-string.

Source

pub const fn data_area_val_size_hint(self) -> Option<usize>

The payload of some AuxVarType is stored in the aux var data area. Most of these payloads are variable-length and null-terminated. If they have a fixed size, then this function returns it.

Trait Implementations§

Source§

impl Clone for AuxVarType

Source§

fn clone(&self) -> AuxVarType

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for AuxVarType

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<AuxVarType> for usize

Source§

fn from(value: AuxVarType) -> Self

Converts to this type from the input type.
Source§

impl Ord for AuxVarType

Source§

fn cmp(&self, other: &Self) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for AuxVarType

Source§

fn eq(&self, other: &AuxVarType) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for AuxVarType

Source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl TryFrom<usize> for AuxVarType

Source§

type Error = ParseAuxVarTypeError

The type returned in the event of a conversion error.
Source§

fn try_from(value: usize) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl Copy for AuxVarType

Source§

impl Eq for AuxVarType

Source§

impl StructuralPartialEq for AuxVarType

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.