@@ -576,12 +576,44 @@ impl std::fmt::Debug for NoCopyOnProtected<'_> {
576576 }
577577}
578578
579- /// Needed property
579+ #[ allow( non_camel_case_types) ]
580+ #[ derive( Debug , Clone , Copy , PartialEq , Eq , Hash ) ]
581+ /// Flags for the `GNU_PROPERTY_1_NEEDED` property
582+ pub enum NeedFlag {
583+ UNKNOWN ,
584+ /// The object needs indirect external access
585+ INDIRECT_EXTERN_ACCESS ,
586+ }
587+
588+ impl From < u64 > for NeedFlag {
589+ fn from ( value : u64 ) -> Self {
590+ match value {
591+ 0 => NeedFlag :: UNKNOWN ,
592+ 1 => NeedFlag :: INDIRECT_EXTERN_ACCESS ,
593+ _ => NeedFlag :: UNKNOWN ,
594+ }
595+ }
596+ }
597+
598+ /// Needed property (`GNU_PROPERTY_1_NEEDED`)
599+ ///
600+ /// This property conveys information about additional features that the
601+ /// object file needs at runtime (e.g. indirect external access).
580602pub struct Needed < ' a > {
581603 ptr : cxx:: UniquePtr < ffi:: ELF_NoteGnuProperty_Needed > ,
582604 _owner : PhantomData < & ' a ffi:: ELF_NoteGnuProperty > ,
583605}
584606
607+ impl Needed < ' _ > {
608+ /// Return the list of needed features
609+ pub fn needs ( & self ) -> Vec < NeedFlag > {
610+ Vec :: from ( self . ptr . needs ( ) . as_slice ( ) )
611+ . into_iter ( )
612+ . map ( NeedFlag :: from)
613+ . collect ( )
614+ }
615+ }
616+
585617impl NoteProperty for Needed < ' _ > {
586618 fn get_base ( & self ) -> & ffi:: ELF_NoteGnuProperty_Property {
587619 self . ptr . as_ref ( ) . unwrap ( ) . as_ref ( )
@@ -601,6 +633,7 @@ impl std::fmt::Debug for Needed<'_> {
601633 fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
602634 f. debug_struct ( "Needed" )
603635 . field ( "type" , & self . property_type ( ) )
636+ . field ( "needs" , & self . needs ( ) )
604637 . finish ( )
605638 }
606639}
0 commit comments