Line data Source code
1 : use lief_ffi as ffi;
2 : use std::marker::PhantomData;
3 :
4 : use super::NoteBase;
5 : use crate::common::FromFFI;
6 :
7 : /// Note representing the QNX stack information
8 : pub struct QNXStack<'a> {
9 : ptr: cxx::UniquePtr<ffi::ELF_QNXStack>,
10 : _owner: PhantomData<&'a ffi::ELF_Binary>,
11 : }
12 :
13 : impl QNXStack<'_> {
14 : /// The stack size
15 0 : pub fn stack_size(&self) -> u32 {
16 0 : self.ptr.stack_size()
17 0 : }
18 :
19 : /// The stack allocated size
20 0 : pub fn stack_allocated(&self) -> u32 {
21 0 : self.ptr.stack_allocated()
22 0 : }
23 :
24 : /// Whether the stack is executable
25 0 : pub fn is_executable(&self) -> bool {
26 0 : self.ptr.is_executable()
27 0 : }
28 : }
29 :
30 : impl NoteBase for QNXStack<'_> {
31 0 : fn get_base(&self) -> &ffi::ELF_Note {
32 0 : self.ptr.as_ref().unwrap().as_ref()
33 0 : }
34 : }
35 :
36 : impl FromFFI<ffi::ELF_QNXStack> for QNXStack<'_> {
37 0 : fn from_ffi(ptr: cxx::UniquePtr<ffi::ELF_QNXStack>) -> Self {
38 0 : Self {
39 0 : ptr,
40 0 : _owner: PhantomData,
41 0 : }
42 0 : }
43 : }
44 :
45 : impl std::fmt::Debug for QNXStack<'_> {
46 0 : fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
47 0 : let base = self as &dyn NoteBase;
48 0 : f.debug_struct("QNXStack")
49 0 : .field("base", &base)
50 0 : .field("stack_size", &self.stack_size())
51 0 : .field("stack_allocated", &self.stack_allocated())
52 0 : .field("is_executable", &self.is_executable())
53 0 : .finish()
54 0 : }
55 : }
|