21
21
22
22
23
23
class Elf32File :
24
- def __init__ (self , array_of_bytes : bytearray ):
24
+ def __init__ (self , array_of_bytes : bytes ):
25
25
self .header = Elf32Header .fromBytearray (array_of_bytes )
26
26
# print(self.header)
27
27
@@ -140,10 +140,10 @@ def handleFlags(self) -> None:
140
140
common .GlobalConfig .ARCHLEVEL = common .ArchLevel .MIPS64R2
141
141
142
142
143
- def _processSection_NULL (self , array_of_bytes : bytearray , entry : Elf32SectionHeaderEntry , sectionEntryName : str ) -> None :
143
+ def _processSection_NULL (self , array_of_bytes : bytes , entry : Elf32SectionHeaderEntry , sectionEntryName : str ) -> None :
144
144
pass
145
145
146
- def _processSection_PROGBITS (self , array_of_bytes : bytearray , entry : Elf32SectionHeaderEntry , sectionEntryName : str ) -> None :
146
+ def _processSection_PROGBITS (self , array_of_bytes : bytes , entry : Elf32SectionHeaderEntry , sectionEntryName : str ) -> None :
147
147
fileSecType = common .FileSectionType .fromStr (sectionEntryName )
148
148
smallFileSecType = common .FileSectionType .fromSmallStr (sectionEntryName )
149
149
@@ -159,23 +159,23 @@ def _processSection_PROGBITS(self, array_of_bytes: bytearray, entry: Elf32Sectio
159
159
self .got = Elf32GlobalOffsetTable (array_of_bytes , entry .offset , entry .size )
160
160
elif sectionEntryName == ".interp" :
161
161
# strings with names of dynamic libraries
162
- common .Utils .printVerbose (f"Unhandled SYMTAB found: '{ sectionEntryName } '" )
162
+ common .Utils .printVerbose (f"Unhandled PROGBITS found: '{ sectionEntryName } '" )
163
163
elif sectionEntryName == ".MIPS.stubs" :
164
164
# ?
165
- common .Utils .printVerbose (f"Unhandled SYMTAB found: '{ sectionEntryName } '" )
165
+ common .Utils .printVerbose (f"Unhandled PROGBITS found: '{ sectionEntryName } '" )
166
166
elif sectionEntryName == ".init" :
167
167
# ?
168
- common .Utils .printVerbose (f"Unhandled SYMTAB found: '{ sectionEntryName } '" )
168
+ common .Utils .printVerbose (f"Unhandled PROGBITS found: '{ sectionEntryName } '" )
169
169
elif common .GlobalConfig .VERBOSE :
170
170
common .Utils .eprint (f"Unhandled PROGBITS found: '{ sectionEntryName } '" , entry , "\n " )
171
171
172
- def _processSection_SYMTAB (self , array_of_bytes : bytearray , entry : Elf32SectionHeaderEntry , sectionEntryName : str ) -> None :
172
+ def _processSection_SYMTAB (self , array_of_bytes : bytes , entry : Elf32SectionHeaderEntry , sectionEntryName : str ) -> None :
173
173
if sectionEntryName == ".symtab" :
174
174
self .symtab = Elf32Syms (array_of_bytes , entry .offset , entry .size )
175
175
elif common .GlobalConfig .VERBOSE :
176
176
common .Utils .eprint ("Unhandled SYMTAB found: " , sectionEntryName , entry , "\n " )
177
177
178
- def _processSection_STRTAB (self , array_of_bytes : bytearray , entry : Elf32SectionHeaderEntry , sectionEntryName : str ) -> None :
178
+ def _processSection_STRTAB (self , array_of_bytes : bytes , entry : Elf32SectionHeaderEntry , sectionEntryName : str ) -> None :
179
179
if sectionEntryName == ".strtab" :
180
180
self .strtab = Elf32StringTable (array_of_bytes , entry .offset , entry .size )
181
181
elif sectionEntryName == ".dynstr" :
@@ -185,33 +185,33 @@ def _processSection_STRTAB(self, array_of_bytes: bytearray, entry: Elf32SectionH
185
185
elif common .GlobalConfig .VERBOSE :
186
186
common .Utils .eprint ("Unhandled STRTAB found: " , sectionEntryName , entry , "\n " )
187
187
188
- def _processSection_RELA (self , array_of_bytes : bytearray , entry : Elf32SectionHeaderEntry , sectionEntryName : str ) -> None :
188
+ def _processSection_RELA (self , array_of_bytes : bytes , entry : Elf32SectionHeaderEntry , sectionEntryName : str ) -> None :
189
189
# ?
190
190
pass
191
191
192
- def _processSection_HASH (self , array_of_bytes : bytearray , entry : Elf32SectionHeaderEntry , sectionEntryName : str ) -> None :
192
+ def _processSection_HASH (self , array_of_bytes : bytes , entry : Elf32SectionHeaderEntry , sectionEntryName : str ) -> None :
193
193
# ?
194
194
pass
195
195
196
- def _processSection_DYNAMIC (self , array_of_bytes : bytearray , entry : Elf32SectionHeaderEntry , sectionEntryName : str ) -> None :
196
+ def _processSection_DYNAMIC (self , array_of_bytes : bytes , entry : Elf32SectionHeaderEntry , sectionEntryName : str ) -> None :
197
197
if sectionEntryName == ".dynamic" :
198
198
self .dynamic = Elf32Dyns (array_of_bytes , entry .offset , entry .size )
199
199
elif common .GlobalConfig .VERBOSE :
200
200
common .Utils .eprint ("Unhandled DYNAMIC found: " , sectionEntryName , entry , "\n " )
201
201
202
- def _processSection_NOTE (self , array_of_bytes : bytearray , entry : Elf32SectionHeaderEntry , sectionEntryName : str ) -> None :
202
+ def _processSection_NOTE (self , array_of_bytes : bytes , entry : Elf32SectionHeaderEntry , sectionEntryName : str ) -> None :
203
203
# ?
204
204
pass
205
205
206
- def _processSection_NOBITS (self , array_of_bytes : bytearray , entry : Elf32SectionHeaderEntry , sectionEntryName : str ) -> None :
206
+ def _processSection_NOBITS (self , array_of_bytes : bytes , entry : Elf32SectionHeaderEntry , sectionEntryName : str ) -> None :
207
207
if sectionEntryName == ".bss" :
208
208
self .nobits = entry
209
209
if sectionEntryName == ".sbss" :
210
210
self .nobitsSmall = entry
211
211
elif common .GlobalConfig .VERBOSE :
212
212
common .Utils .eprint ("Unhandled NOBITS found: " , sectionEntryName , entry , "\n " )
213
213
214
- def _processSection_REL (self , array_of_bytes : bytearray , entry : Elf32SectionHeaderEntry , sectionEntryName : str ) -> None :
214
+ def _processSection_REL (self , array_of_bytes : bytes , entry : Elf32SectionHeaderEntry , sectionEntryName : str ) -> None :
215
215
if sectionEntryName .startswith (".rel." ):
216
216
fileSecType = common .FileSectionType .fromStr (sectionEntryName [4 :])
217
217
if fileSecType != common .FileSectionType .Invalid :
@@ -221,53 +221,53 @@ def _processSection_REL(self, array_of_bytes: bytearray, entry: Elf32SectionHead
221
221
elif common .GlobalConfig .VERBOSE :
222
222
common .Utils .eprint ("Unhandled REL found: " , sectionEntryName , entry , "\n " )
223
223
224
- def _processSection_DYNSYM (self , array_of_bytes : bytearray , entry : Elf32SectionHeaderEntry , sectionEntryName : str ) -> None :
224
+ def _processSection_DYNSYM (self , array_of_bytes : bytes , entry : Elf32SectionHeaderEntry , sectionEntryName : str ) -> None :
225
225
if sectionEntryName == ".dynsym" :
226
226
self .dynsym = Elf32Syms (array_of_bytes , entry .offset , entry .size )
227
227
elif common .GlobalConfig .VERBOSE :
228
228
common .Utils .eprint ("Unhandled DYNSYM found: " , sectionEntryName , entry , "\n " )
229
229
230
230
231
- def _processSection_MIPS_LIBLIST (self , array_of_bytes : bytearray , entry : Elf32SectionHeaderEntry , sectionEntryName : str ) -> None :
231
+ def _processSection_MIPS_LIBLIST (self , array_of_bytes : bytes , entry : Elf32SectionHeaderEntry , sectionEntryName : str ) -> None :
232
232
# ?
233
233
pass
234
234
235
- def _processSection_MIPS_MSYM (self , array_of_bytes : bytearray , entry : Elf32SectionHeaderEntry , sectionEntryName : str ) -> None :
235
+ def _processSection_MIPS_MSYM (self , array_of_bytes : bytes , entry : Elf32SectionHeaderEntry , sectionEntryName : str ) -> None :
236
236
# ?
237
237
pass
238
238
239
- def _processSection_MIPS_CONFLICT (self , array_of_bytes : bytearray , entry : Elf32SectionHeaderEntry , sectionEntryName : str ) -> None :
239
+ def _processSection_MIPS_CONFLICT (self , array_of_bytes : bytes , entry : Elf32SectionHeaderEntry , sectionEntryName : str ) -> None :
240
240
# ?
241
241
pass
242
242
243
- def _processSection_MIPS_GPTAB (self , array_of_bytes : bytearray , entry : Elf32SectionHeaderEntry , sectionEntryName : str ) -> None :
243
+ def _processSection_MIPS_GPTAB (self , array_of_bytes : bytes , entry : Elf32SectionHeaderEntry , sectionEntryName : str ) -> None :
244
244
# ?
245
245
pass
246
246
247
- def _processSection_MIPS_DEBUG (self , array_of_bytes : bytearray , entry : Elf32SectionHeaderEntry , sectionEntryName : str ) -> None :
247
+ def _processSection_MIPS_DEBUG (self , array_of_bytes : bytes , entry : Elf32SectionHeaderEntry , sectionEntryName : str ) -> None :
248
248
# ?
249
249
pass
250
250
251
- def _processSection_MIPS_REGINFO (self , array_of_bytes : bytearray , entry : Elf32SectionHeaderEntry , sectionEntryName : str ) -> None :
251
+ def _processSection_MIPS_REGINFO (self , array_of_bytes : bytes , entry : Elf32SectionHeaderEntry , sectionEntryName : str ) -> None :
252
252
if sectionEntryName == ".reginfo" :
253
253
self .reginfo = Elf32RegInfo .fromBytearray (array_of_bytes , entry .offset )
254
254
elif common .GlobalConfig .VERBOSE :
255
255
common .Utils .eprint ("Unhandled MIPS_REGINFO found: " , sectionEntryName , entry , "\n " )
256
256
257
- def _processSection_MIPS_OPTIONS (self , array_of_bytes : bytearray , entry : Elf32SectionHeaderEntry , sectionEntryName : str ) -> None :
257
+ def _processSection_MIPS_OPTIONS (self , array_of_bytes : bytes , entry : Elf32SectionHeaderEntry , sectionEntryName : str ) -> None :
258
258
# ?
259
259
pass
260
260
261
- def _processSection_MIPS_SYMBOL_LIB (self , array_of_bytes : bytearray , entry : Elf32SectionHeaderEntry , sectionEntryName : str ) -> None :
261
+ def _processSection_MIPS_SYMBOL_LIB (self , array_of_bytes : bytes , entry : Elf32SectionHeaderEntry , sectionEntryName : str ) -> None :
262
262
# ?
263
263
pass
264
264
265
- def _processSection_MIPS_ABIFLAGS (self , array_of_bytes : bytearray , entry : Elf32SectionHeaderEntry , sectionEntryName : str ) -> None :
265
+ def _processSection_MIPS_ABIFLAGS (self , array_of_bytes : bytes , entry : Elf32SectionHeaderEntry , sectionEntryName : str ) -> None :
266
266
# ?
267
267
pass
268
268
269
269
270
- _sectionProcessorCallbacks : dict [int , Callable [[Elf32File , bytearray , Elf32SectionHeaderEntry , str ], None ]] = {
270
+ _sectionProcessorCallbacks : dict [int , Callable [[Elf32File , bytes , Elf32SectionHeaderEntry , str ], None ]] = {
271
271
Elf32SectionHeaderType .NULL .value : _processSection_NULL ,
272
272
Elf32SectionHeaderType .PROGBITS .value : _processSection_PROGBITS ,
273
273
Elf32SectionHeaderType .SYMTAB .value : _processSection_SYMTAB ,
0 commit comments