1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140
#![allow(clippy::single_match)]
#[doc = " vDSO for `x86_64`"]
#[derive(Debug, Copy, Clone)]
pub struct Vdso {
pub clock_gettime: *const ::core::ffi::c_void,
pub getcpu: *const ::core::ffi::c_void,
pub gettimeofday: *const ::core::ffi::c_void,
pub time: *const ::core::ffi::c_void,
}
impl Vdso {
fn from_reader(reader: crate::VdsoReader) -> ::core::option::Option<Self> {
unsafe {
let mut version_mandatory_0 = 0u16;
let mut vdso_inst = Self {
clock_gettime: ::core::ptr::null(),
getcpu: ::core::ptr::null(),
gettimeofday: ::core::ptr::null(),
time: ::core::ptr::null(),
};
{
let mut mandatory_count = 0usize;
for version in reader.versions() {
match version.hash() {
61765110 => {
if crate::util::streq(
version.name(),
[76, 73, 78, 85, 88, 95, 50, 46, 54, 0u8][..].as_ptr(),
) {
if version_mandatory_0 == 0 {
mandatory_count += 1;
version_mandatory_0 = version.id();
} else {
return ::core::option::Option::None;
}
}
}
_ => (),
}
if mandatory_count == 1 {
break;
}
}
if mandatory_count != 1 {
return ::core::option::Option::None;
}
}
{
let mut mandatory_count = 0usize;
for symbol in reader.symbols() {
match crate::util::elf_hash(symbol.name()) {
11538501 => {
if crate::util::streq(
symbol.name(),
[
95, 95, 118, 100, 115, 111, 95, 103, 101, 116, 99, 112, 117,
0u8,
][..]
.as_ptr(),
) && Some(version_mandatory_0) == symbol.version_id()
{
if vdso_inst.getcpu.is_null() {
mandatory_count += 1;
vdso_inst.getcpu = symbol.ptr();
} else {
return ::core::option::Option::None;
}
}
}
51759705 => {
if crate::util::streq(
symbol.name(),
[
95, 95, 118, 100, 115, 111, 95, 103, 101, 116, 116, 105, 109,
101, 111, 102, 100, 97, 121, 0u8,
][..]
.as_ptr(),
) && Some(version_mandatory_0) == symbol.version_id()
{
if vdso_inst.gettimeofday.is_null() {
mandatory_count += 1;
vdso_inst.gettimeofday = symbol.ptr();
} else {
return ::core::option::Option::None;
}
}
}
171164805 => {
if crate::util::streq(
symbol.name(),
[95, 95, 118, 100, 115, 111, 95, 116, 105, 109, 101, 0u8][..]
.as_ptr(),
) && Some(version_mandatory_0) == symbol.version_id()
{
if vdso_inst.time.is_null() {
mandatory_count += 1;
vdso_inst.time = symbol.ptr();
} else {
return ::core::option::Option::None;
}
}
}
221637749 => {
if crate::util::streq(
symbol.name(),
[
95, 95, 118, 100, 115, 111, 95, 99, 108, 111, 99, 107, 95, 103,
101, 116, 116, 105, 109, 101, 0u8,
][..]
.as_ptr(),
) && Some(version_mandatory_0) == symbol.version_id()
{
if vdso_inst.clock_gettime.is_null() {
mandatory_count += 1;
vdso_inst.clock_gettime = symbol.ptr();
} else {
return ::core::option::Option::None;
}
}
}
_ => (),
}
if mandatory_count == 4 {
break;
}
}
if mandatory_count != 4 {
return ::core::option::Option::None;
}
}
Some(vdso_inst)
}
}
#[doc = r" Parse vDSO from memory"]
#[doc = r" # Safety"]
#[doc = r" This is unsafe because we can't validate the given pointer so"]
#[doc = r" use it carefully"]
pub unsafe fn from_ptr(ptr: *const ::core::ffi::c_void) -> ::core::option::Option<Self> {
Self::from_reader(crate::VdsoReader::from_ptr(ptr)?)
}
}