12
12
13
13
const METADATA_SIZE : usize = size_of :: < TagTypeId > ( ) + 4 * size_of :: < u32 > ( ) ;
14
14
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.
18
18
#[ derive( ptr_meta:: Pointee , PartialEq , Eq ) ]
19
19
#[ repr( C ) ]
20
20
pub struct ElfSectionsTag {
@@ -41,7 +41,7 @@ impl ElfSectionsTag {
41
41
}
42
42
43
43
/// Get an iterator of loaded ELF sections.
44
- pub ( crate ) fn sections ( & self , offset : usize ) -> ElfSectionIter {
44
+ pub ( crate ) fn sections ( & self ) -> ElfSectionIter {
45
45
let string_section_offset = ( self . shndx * self . entry_size ) as isize ;
46
46
let string_section_ptr =
47
47
unsafe { self . first_section ( ) . offset ( string_section_offset) as * const _ } ;
@@ -50,7 +50,6 @@ impl ElfSectionsTag {
50
50
remaining_sections : self . number_of_sections ,
51
51
entry_size : self . entry_size ,
52
52
string_section : string_section_ptr,
53
- offset,
54
53
}
55
54
}
56
55
@@ -81,7 +80,7 @@ impl Debug for ElfSectionsTag {
81
80
. field ( "number_of_sections" , & { self . number_of_sections } )
82
81
. field ( "entry_size" , & { self . entry_size } )
83
82
. field ( "shndx" , & { self . shndx } )
84
- . field ( "sections" , & self . sections ( 0 ) )
83
+ . field ( "sections" , & self . sections ( ) )
85
84
. finish ( )
86
85
}
87
86
}
@@ -93,7 +92,6 @@ pub struct ElfSectionIter {
93
92
remaining_sections : u32 ,
94
93
entry_size : u32 ,
95
94
string_section : * const u8 ,
96
- offset : usize ,
97
95
}
98
96
99
97
impl Iterator for ElfSectionIter {
@@ -105,7 +103,6 @@ impl Iterator for ElfSectionIter {
105
103
inner : self . current_section ,
106
104
string_section : self . string_section ,
107
105
entry_size : self . entry_size ,
108
- offset : self . offset ,
109
106
} ;
110
107
111
108
self . current_section = unsafe { self . current_section . offset ( self . entry_size as isize ) } ;
@@ -136,7 +133,6 @@ impl Default for ElfSectionIter {
136
133
remaining_sections : 0 ,
137
134
entry_size : 0 ,
138
135
string_section : core:: ptr:: null ( ) ,
139
- offset : 0 ,
140
136
}
141
137
}
142
138
}
@@ -147,7 +143,6 @@ pub struct ElfSection {
147
143
inner : * const u8 ,
148
144
string_section : * const u8 ,
149
145
entry_size : u32 ,
150
- offset : usize ,
151
146
}
152
147
153
148
#[ derive( Clone , Copy , Debug ) ]
@@ -282,7 +277,7 @@ impl ElfSection {
282
277
64 => ( * ( self . string_section as * const ElfSectionInner64 ) ) . addr as usize ,
283
278
s => panic ! ( "Unexpected entry size: {}" , s) ,
284
279
} ;
285
- ( addr + self . offset ) as * const _
280
+ addr as * const _
286
281
}
287
282
}
288
283
0 commit comments