@@ -69,9 +69,9 @@ impl<'data, Elf: FileHeader, R: ReadRef<'data>> SymbolTable<'data, Elf, R> {
69
69
70
70
let mut shndx_section = SectionIndex ( 0 ) ;
71
71
let mut shndx = & [ ] [ ..] ;
72
- for ( i, s) in sections. iter ( ) . enumerate ( ) {
72
+ for ( i, s) in sections. enumerate ( ) {
73
73
if s. sh_type ( endian) == elf:: SHT_SYMTAB_SHNDX && s. link ( endian) == section_index {
74
- shndx_section = SectionIndex ( i ) ;
74
+ shndx_section = i ;
75
75
shndx = s
76
76
. data_as_array ( endian, data)
77
77
. read_error ( "Invalid ELF symtab_shndx data" ) ?;
@@ -431,7 +431,7 @@ impl<'data, 'file, Elf: FileHeader, R: ReadRef<'data>> ObjectSymbol<'data>
431
431
432
432
#[ inline]
433
433
fn is_undefined ( & self ) -> bool {
434
- self . symbol . st_shndx ( self . endian ) == elf :: SHN_UNDEF
434
+ self . symbol . is_undefined ( self . endian )
435
435
}
436
436
437
437
#[ inline]
@@ -441,12 +441,12 @@ impl<'data, 'file, Elf: FileHeader, R: ReadRef<'data>> ObjectSymbol<'data>
441
441
442
442
#[ inline]
443
443
fn is_common ( & self ) -> bool {
444
- self . symbol . st_shndx ( self . endian ) == elf :: SHN_COMMON
444
+ self . symbol . is_common ( self . endian )
445
445
}
446
446
447
447
#[ inline]
448
448
fn is_weak ( & self ) -> bool {
449
- self . symbol . st_bind ( ) == elf :: STB_WEAK
449
+ self . symbol . is_weak ( )
450
450
}
451
451
452
452
fn scope ( & self ) -> SymbolScope {
@@ -469,12 +469,12 @@ impl<'data, 'file, Elf: FileHeader, R: ReadRef<'data>> ObjectSymbol<'data>
469
469
470
470
#[ inline]
471
471
fn is_global ( & self ) -> bool {
472
- self . symbol . st_bind ( ) != elf :: STB_LOCAL
472
+ ! self . symbol . is_local ( )
473
473
}
474
474
475
475
#[ inline]
476
476
fn is_local ( & self ) -> bool {
477
- self . symbol . st_bind ( ) == elf :: STB_LOCAL
477
+ self . symbol . is_local ( )
478
478
}
479
479
480
480
#[ inline]
@@ -513,7 +513,7 @@ pub trait Sym: Debug + Pod {
513
513
. read_error ( "Invalid ELF symbol name offset" )
514
514
}
515
515
516
- /// Return true if the symbol is undefined .
516
+ /// Return true if the symbol section is `SHN_UNDEF` .
517
517
#[ inline]
518
518
fn is_undefined ( & self , endian : Self :: Endian ) -> bool {
519
519
self . st_shndx ( endian) == elf:: SHN_UNDEF
@@ -531,6 +531,26 @@ pub trait Sym: Debug + Pod {
531
531
_ => false ,
532
532
}
533
533
}
534
+
535
+ /// Return true if the symbol section is `SHN_COMMON`.
536
+ fn is_common ( & self , endian : Self :: Endian ) -> bool {
537
+ self . st_shndx ( endian) == elf:: SHN_COMMON
538
+ }
539
+
540
+ /// Return true if the symbol section is `SHN_ABS`.
541
+ fn is_absolute ( & self , endian : Self :: Endian ) -> bool {
542
+ self . st_shndx ( endian) == elf:: SHN_ABS
543
+ }
544
+
545
+ /// Return true if the symbol binding is `STB_LOCAL`.
546
+ fn is_local ( & self ) -> bool {
547
+ self . st_bind ( ) == elf:: STB_LOCAL
548
+ }
549
+
550
+ /// Return true if the symbol binding is `STB_WEAK`.
551
+ fn is_weak ( & self ) -> bool {
552
+ self . st_bind ( ) == elf:: STB_WEAK
553
+ }
534
554
}
535
555
536
556
impl < Endian : endian:: Endian > Sym for elf:: Sym32 < Endian > {
0 commit comments