#[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
All types of auxiliary variables that Linux supports for the initial stack. Also called “AT”-variables in Linux source code.
According to some Linux code comments, 0-17 are architecture independent
The ones above and including 32 are for x86_64. Values above 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
L1iCacheGeometry = 41
L1dCacheSize = 42
L1dCacheGeometry = 43
L2CacheSize = 44
L2CacheGeometry = 45
L3CacheSize = 46
L3CacheGeometry = 47
MinSigStkSz = 51
Minimal stack size for signal delivery.
Implementations§
Source§impl AuxVarType
impl AuxVarType
pub const fn val(self) -> usize
Sourcepub const fn value_in_data_area(self) -> bool
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?
27fn main() {
28 let builder = InitialLinuxLibcStackLayoutBuilder::new()
29 // can contain terminating zero; not mandatory in the builder
30 .add_arg_v("./first_arg\0")
31 .add_arg_v("./second_arg")
32 .add_env_v("FOO=BAR\0")
33 .add_env_v("PATH=/bin")
34 .add_aux_v(AuxVar::Clktck(100))
35 .add_aux_v(AuxVar::Random([
36 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
37 ]))
38 .add_aux_v(AuxVar::ExecFn("/usr/bin/foo"))
39 .add_aux_v(AuxVar::Platform("x86_64"));
40
41 // memory where we serialize the data structure into
42 let mut buf = vec![0; builder.total_size()];
43
44 // assume user stack is at 0x7fff0000
45 let user_base_addr = 0x7fff0000;
46 unsafe {
47 builder.serialize_into_buf(buf.as_mut_slice(), user_base_addr);
48 }
49
50 // So far, this is memory safe, as long as the slice is valid memory. No pointers are
51 // dereferenced yet.
52 let parsed = InitialLinuxLibcStackLayout::from(buf.as_slice());
53
54 println!("There are {} arguments.", parsed.argc());
55 println!(
56 "There are {} environment variables.",
57 parsed.envv_ptr_iter().count()
58 );
59 println!(
60 "There are {} auxiliary vector entries/AT variables.",
61 parsed.aux_serialized_iter().count()
62 );
63
64 println!(" argv");
65 // ptr iter is safe for other address spaces; the other only because here user_addr == write_addr
66 for (i, arg) in parsed.argv_ptr_iter().enumerate() {
67 println!(" [{}] @ {:?}", i, arg);
68 }
69
70 println!(" envp");
71 // ptr iter is safe for other address spaces; the other only because here user_addr == write_addr
72 for (i, env) in parsed.envv_ptr_iter().enumerate() {
73 println!(" [{}] @ {:?}", i, env);
74 }
75
76 println!(" aux");
77 // ptr iter is safe for other address spaces; the other only because here user_addr == write_addr
78 for aux in parsed.aux_serialized_iter() {
79 if aux.key().value_in_data_area() {
80 println!(" {:?} => @ {:?}", aux.key(), aux.val() as *const u8);
81 } else {
82 println!(" {:?} => {:?}", aux.key(), aux.val() as *const u8);
83 }
84 }
85}Sourcepub fn value_is_cstr(self) -> bool
pub fn value_is_cstr(self) -> bool
Most of the auxiliary vector entries where Self::value_is_cstr is true,
represent a null-terminated C-string.
Sourcepub const fn data_area_val_size_hint(self) -> Option<usize>
pub const fn data_area_val_size_hint(self) -> Option<usize>
The payload of some AuxVarType is stored in the aux var data area. Some of these
data is null-terminated. Some has a fixed size. This helps to find out if there
is a fixed size.
Trait Implementations§
Source§impl Clone for AuxVarType
impl Clone for AuxVarType
Source§fn clone(&self) -> AuxVarType
fn clone(&self) -> AuxVarType
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more