1212
1313const METADATA_SIZE : usize = size_of :: < TagTypeId > ( ) + 4 * size_of :: < u32 > ( ) ;
1414
15- /// This tag contains section header table from an ELF kernel .
16- ///
17- /// The sections iterator is provided via the `sections` method.
15+ /// This tag contains the section header table from an ELF binary .
16+ // The sections iterator is provided via the [`ElfSectionsTag::sections`]
17+ // method.
1818#[ derive( ptr_meta:: Pointee , PartialEq , Eq ) ]
1919#[ repr( C ) ]
2020pub struct ElfSectionsTag {
@@ -41,7 +41,7 @@ impl ElfSectionsTag {
4141 }
4242
4343 /// Get an iterator of loaded ELF sections.
44- pub ( crate ) fn sections ( & self , offset : usize ) -> ElfSectionIter {
44+ pub ( crate ) fn sections ( & self ) -> ElfSectionIter {
4545 let string_section_offset = ( self . shndx * self . entry_size ) as isize ;
4646 let string_section_ptr =
4747 unsafe { self . first_section ( ) . offset ( string_section_offset) as * const _ } ;
@@ -50,7 +50,6 @@ impl ElfSectionsTag {
5050 remaining_sections : self . number_of_sections ,
5151 entry_size : self . entry_size ,
5252 string_section : string_section_ptr,
53- offset,
5453 }
5554 }
5655
@@ -81,7 +80,7 @@ impl Debug for ElfSectionsTag {
8180 . field ( "number_of_sections" , & { self . number_of_sections } )
8281 . field ( "entry_size" , & { self . entry_size } )
8382 . field ( "shndx" , & { self . shndx } )
84- . field ( "sections" , & self . sections ( 0 ) )
83+ . field ( "sections" , & self . sections ( ) )
8584 . finish ( )
8685 }
8786}
@@ -93,7 +92,6 @@ pub struct ElfSectionIter {
9392 remaining_sections : u32 ,
9493 entry_size : u32 ,
9594 string_section : * const u8 ,
96- offset : usize ,
9795}
9896
9997impl Iterator for ElfSectionIter {
@@ -105,7 +103,6 @@ impl Iterator for ElfSectionIter {
105103 inner : self . current_section ,
106104 string_section : self . string_section ,
107105 entry_size : self . entry_size ,
108- offset : self . offset ,
109106 } ;
110107
111108 self . current_section = unsafe { self . current_section . offset ( self . entry_size as isize ) } ;
@@ -136,7 +133,6 @@ impl Default for ElfSectionIter {
136133 remaining_sections : 0 ,
137134 entry_size : 0 ,
138135 string_section : core:: ptr:: null ( ) ,
139- offset : 0 ,
140136 }
141137 }
142138}
@@ -147,7 +143,6 @@ pub struct ElfSection {
147143 inner : * const u8 ,
148144 string_section : * const u8 ,
149145 entry_size : u32 ,
150- offset : usize ,
151146}
152147
153148#[ derive( Clone , Copy , Debug ) ]
@@ -282,7 +277,7 @@ impl ElfSection {
282277 64 => ( * ( self . string_section as * const ElfSectionInner64 ) ) . addr as usize ,
283278 s => panic ! ( "Unexpected entry size: {}" , s) ,
284279 } ;
285- ( addr + self . offset ) as * const _
280+ addr as * const _
286281 }
287282}
288283
0 commit comments