pub struct AuxVarFlags { /* private fields */ }Expand description
Flags for the auxiliary vector. See https://elixir.bootlin.com/linux/v5.15.5/source/include/uapi/linux/binfmts.h#L23.
Implementations§
Source§impl AuxVarFlags
impl AuxVarFlags
Sourcepub const NOT_PRESERVE_ARGV0: Self
pub const NOT_PRESERVE_ARGV0: Self
Opposite of Self::PRESERVE_ARGV0.
Sourcepub const PRESERVE_ARGV0: Self
pub const PRESERVE_ARGV0: Self
Preserve argv0 for the interpreter.
Sourcepub const fn empty() -> Self
pub const fn empty() -> Self
Returns an empty set of flags.
Examples found in repository?
29fn main() {
30 let builder = InitialLinuxLibcStackLayoutBuilder::new()
31 // can contain terminating zero; not mandatory in the builder
32 .add_arg_v("./first_arg\0")
33 .add_arg_v("./second_arg")
34 .add_env_v("FOO=BAR\0")
35 .add_env_v("PATH=/bin")
36 .add_aux_v(AuxVar::Sysinfo(0x7ffd000 as *const _))
37 .add_aux_v(AuxVar::HwCap(0x1000))
38 .add_aux_v(AuxVar::Clktck(100))
39 .add_aux_v(AuxVar::Phdr(0x5627e17 as *const _))
40 .add_aux_v(AuxVar::Phent(56))
41 .add_aux_v(AuxVar::Phnum(13))
42 .add_aux_v(AuxVar::Base(0x7f51000 as *const _))
43 .add_aux_v(AuxVar::Flags(AuxVarFlags::empty()))
44 .add_aux_v(AuxVar::Entry(0x5627e17 as *const _))
45 .add_aux_v(AuxVar::Uid(1001))
46 .add_aux_v(AuxVar::EUid(1001))
47 .add_aux_v(AuxVar::Gid(1001))
48 .add_aux_v(AuxVar::EGid(1001))
49 .add_aux_v(AuxVar::Secure(false))
50 .add_aux_v(AuxVar::Random([
51 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
52 ]))
53 .add_aux_v(AuxVar::HwCap2(0x2))
54 .add_aux_v(AuxVar::ExecFn("/usr/bin/foo"))
55 .add_aux_v(AuxVar::Platform("x86_64"));
56
57 // memory where we serialize the data structure into
58 let mut buf = vec![0; builder.total_size()];
59
60 // User base addr is the initial stack pointer in the user address space.
61 // In this example: same as write address => enables us to parse the data structure
62 // let user_base_addr = buf.as_ptr() as u64;
63 let user_base_addr = 0x1000;
64 unsafe {
65 builder.serialize_into_buf(buf.as_mut_slice(), user_base_addr);
66 }
67
68 // So far, this is memory safe, as long as the slice is valid memory. No pointers are
69 // dereferenced yet.
70 let parsed = InitialLinuxLibcStackLayout::from(buf.as_slice());
71
72 println!("There are {} arguments.", parsed.argc());
73 println!(
74 "There are {} environment variables.",
75 parsed.envv_ptr_iter().count()
76 );
77 println!(
78 "There are {} auxiliary vector entries/AT variables.",
79 parsed.aux_serialized_iter().count()
80 );
81
82 println!("===== 1/2: only pointers");
83 parse_memory_safe(&parsed);
84
85 if user_base_addr == buf.as_ptr() as u64 {
86 println!("===== 2/2: dereferenced data");
87 // this will not work, if you change the "user_base_addr" above to another address
88 unsafe {
89 parse_memory_unsafe(&parsed);
90 }
91 }
92}Sourcepub const fn from_bits(bits: usize) -> Option<Self>
pub const fn from_bits(bits: usize) -> Option<Self>
Convert from underlying bit representation, unless that representation contains bits that do not correspond to a flag.
Sourcepub const fn from_bits_truncate(bits: usize) -> Self
pub const fn from_bits_truncate(bits: usize) -> Self
Convert from underlying bit representation, dropping any bits that do not correspond to flags.
Sourcepub const unsafe fn from_bits_unchecked(bits: usize) -> Self
pub const unsafe fn from_bits_unchecked(bits: usize) -> Self
Convert from underlying bit representation, preserving all bits (even those not corresponding to a defined flag).
§Safety
The caller of the bitflags! macro can chose to allow or
disallow extra bits for their bitflags type.
The caller of from_bits_unchecked() has to ensure that
all bits correspond to a defined flag or that extra bits
are valid for this bitflags type.
Sourcepub const fn intersects(&self, other: Self) -> bool
pub const fn intersects(&self, other: Self) -> bool
Returns true if there are flags common to both self and other.
Sourcepub const fn contains(&self, other: Self) -> bool
pub const fn contains(&self, other: Self) -> bool
Returns true if all of the flags in other are contained within self.
Sourcepub fn set(&mut self, other: Self, value: bool)
pub fn set(&mut self, other: Self, value: bool)
Inserts or removes the specified flags depending on the passed value.
Sourcepub const fn intersection(self, other: Self) -> Self
pub const fn intersection(self, other: Self) -> Self
Returns the intersection between the flags in self and
other.
Specifically, the returned set contains only the flags which are
present in both self and other.
This is equivalent to using the & operator (e.g.
ops::BitAnd), as in flags & other.
Sourcepub const fn union(self, other: Self) -> Self
pub const fn union(self, other: Self) -> Self
Returns the union of between the flags in self and other.
Specifically, the returned set contains all flags which are
present in either self or other, including any which are
present in both (see Self::symmetric_difference if that
is undesirable).
This is equivalent to using the | operator (e.g.
ops::BitOr), as in flags | other.
Sourcepub const fn difference(self, other: Self) -> Self
pub const fn difference(self, other: Self) -> Self
Returns the difference between the flags in self and other.
Specifically, the returned set contains all flags present in
self, except for the ones present in other.
It is also conceptually equivalent to the “bit-clear” operation:
flags & !other (and this syntax is also supported).
This is equivalent to using the - operator (e.g.
ops::Sub), as in flags - other.
Sourcepub const fn symmetric_difference(self, other: Self) -> Self
pub const fn symmetric_difference(self, other: Self) -> Self
Returns the symmetric difference between the flags
in self and other.
Specifically, the returned set contains the flags present which
are present in self or other, but that are not present in
both. Equivalently, it contains the flags present in exactly
one of the sets self and other.
This is equivalent to using the ^ operator (e.g.
ops::BitXor), as in flags ^ other.
Sourcepub const fn complement(self) -> Self
pub const fn complement(self) -> Self
Returns the complement of this set of flags.
Specifically, the returned set contains all the flags which are
not set in self, but which are allowed for this type.
Alternatively, it can be thought of as the set difference
between Self::all() and self (e.g. Self::all() - self)
This is equivalent to using the ! operator (e.g.
ops::Not), as in !flags.
Trait Implementations§
Source§impl Binary for AuxVarFlags
impl Binary for AuxVarFlags
Source§impl BitAnd for AuxVarFlags
impl BitAnd for AuxVarFlags
Source§impl BitAndAssign for AuxVarFlags
impl BitAndAssign for AuxVarFlags
Source§fn bitand_assign(&mut self, other: Self)
fn bitand_assign(&mut self, other: Self)
Disables all flags disabled in the set.
Source§impl BitOr for AuxVarFlags
impl BitOr for AuxVarFlags
Source§fn bitor(self, other: AuxVarFlags) -> Self
fn bitor(self, other: AuxVarFlags) -> Self
Returns the union of the two sets of flags.
Source§type Output = AuxVarFlags
type Output = AuxVarFlags
| operator.Source§impl BitOrAssign for AuxVarFlags
impl BitOrAssign for AuxVarFlags
Source§fn bitor_assign(&mut self, other: Self)
fn bitor_assign(&mut self, other: Self)
Adds the set of flags.
Source§impl BitXor for AuxVarFlags
impl BitXor for AuxVarFlags
Source§impl BitXorAssign for AuxVarFlags
impl BitXorAssign for AuxVarFlags
Source§fn bitxor_assign(&mut self, other: Self)
fn bitxor_assign(&mut self, other: Self)
Toggles the set of flags.
Source§impl Clone for AuxVarFlags
impl Clone for AuxVarFlags
Source§fn clone(&self) -> AuxVarFlags
fn clone(&self) -> AuxVarFlags
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for AuxVarFlags
impl Debug for AuxVarFlags
Source§impl Extend<AuxVarFlags> for AuxVarFlags
impl Extend<AuxVarFlags> for AuxVarFlags
Source§fn extend<T: IntoIterator<Item = Self>>(&mut self, iterator: T)
fn extend<T: IntoIterator<Item = Self>>(&mut self, iterator: T)
Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one)Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one)Source§impl FromIterator<AuxVarFlags> for AuxVarFlags
impl FromIterator<AuxVarFlags> for AuxVarFlags
Source§fn from_iter<T: IntoIterator<Item = Self>>(iterator: T) -> Self
fn from_iter<T: IntoIterator<Item = Self>>(iterator: T) -> Self
Source§impl Hash for AuxVarFlags
impl Hash for AuxVarFlags
Source§impl LowerHex for AuxVarFlags
impl LowerHex for AuxVarFlags
Source§impl Not for AuxVarFlags
impl Not for AuxVarFlags
Source§impl Octal for AuxVarFlags
impl Octal for AuxVarFlags
Source§impl Ord for AuxVarFlags
impl Ord for AuxVarFlags
Source§fn cmp(&self, other: &AuxVarFlags) -> Ordering
fn cmp(&self, other: &AuxVarFlags) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq for AuxVarFlags
impl PartialEq for AuxVarFlags
Source§impl PartialOrd for AuxVarFlags
impl PartialOrd for AuxVarFlags
Source§impl Sub for AuxVarFlags
impl Sub for AuxVarFlags
Source§impl SubAssign for AuxVarFlags
impl SubAssign for AuxVarFlags
Source§fn sub_assign(&mut self, other: Self)
fn sub_assign(&mut self, other: Self)
Disables all flags enabled in the set.