@@ -115,11 +115,10 @@ class ImageSegment(object):
115
115
"""Wrapper class for a segment in an ESP image
116
116
(very similar to a section in an ELFImage also)"""
117
117
118
- def __init__ (self , addr , data , file_offs = None , flags = 0 ):
118
+ def __init__ (self , addr , data , file_offs = None ):
119
119
self .addr = addr
120
120
self .data = data
121
121
self .file_offs = file_offs
122
- self .flags = flags
123
122
self .include_in_checksum = True
124
123
if self .addr != 0 :
125
124
self .pad_to_alignment (
@@ -168,8 +167,8 @@ class ELFSection(ImageSegment):
168
167
"""Wrapper class for a section in an ELF image, has a section
169
168
name as well as the common properties of an ImageSegment."""
170
169
171
- def __init__ (self , name , addr , data , flags ):
172
- super (ELFSection , self ).__init__ (addr , data , flags = flags )
170
+ def __init__ (self , name , addr , data ):
171
+ super (ELFSection , self ).__init__ (addr , data )
173
172
self .name = name .decode ("utf-8" )
174
173
175
174
def __repr__ (self ):
@@ -179,9 +178,6 @@ def __repr__(self):
179
178
class BaseFirmwareImage (object ):
180
179
SEG_HEADER_LEN = 8
181
180
SHA256_DIGEST_LEN = 32
182
- ELF_FLAG_WRITE = 0x1
183
- ELF_FLAG_READ = 0x2
184
- ELF_FLAG_EXEC = 0x4
185
181
186
182
""" Base class with common firmware image functions """
187
183
@@ -377,8 +373,6 @@ def merge_adjacent_segments(self):
377
373
elem .get_memory_type (self ) == next_elem .get_memory_type (self ),
378
374
elem .include_in_checksum == next_elem .include_in_checksum ,
379
375
next_elem .addr == elem .addr + len (elem .data ),
380
- next_elem .flags & self .ELF_FLAG_EXEC
381
- == elem .flags & self .ELF_FLAG_EXEC ,
382
376
)
383
377
):
384
378
# Merge any segment that ends where the next one starts,
@@ -1285,7 +1279,7 @@ def read_section_header(offs):
1285
1279
name_offs , sec_type , _flags , lma , sec_offs , size = struct .unpack_from (
1286
1280
"<LLLLLL" , section_header [offs :]
1287
1281
)
1288
- return (name_offs , sec_type , lma , size , sec_offs , _flags )
1282
+ return (name_offs , sec_type , lma , size , sec_offs )
1289
1283
1290
1284
all_sections = [read_section_header (offs ) for offs in section_header_offsets ]
1291
1285
prog_sections = [s for s in all_sections if s [1 ] in ELFFile .PROG_SEC_TYPES ]
@@ -1294,7 +1288,7 @@ def read_section_header(offs):
1294
1288
# search for the string table section
1295
1289
if (shstrndx * self .LEN_SEC_HEADER ) not in section_header_offsets :
1296
1290
raise FatalError ("ELF file has no STRTAB section at shstrndx %d" % shstrndx )
1297
- _ , sec_type , _ , sec_size , sec_offs , _ = read_section_header (
1291
+ _ , sec_type , _ , sec_size , sec_offs = read_section_header (
1298
1292
shstrndx * self .LEN_SEC_HEADER
1299
1293
)
1300
1294
if sec_type != ELFFile .SEC_TYPE_STRTAB :
@@ -1316,14 +1310,14 @@ def read_data(offs, size):
1316
1310
return f .read (size )
1317
1311
1318
1312
prog_sections = [
1319
- ELFSection (lookup_string (n_offs ), lma , read_data (offs , size ), flags = _flags )
1320
- for (n_offs , _type , lma , size , offs , _flags ) in prog_sections
1313
+ ELFSection (lookup_string (n_offs ), lma , read_data (offs , size ))
1314
+ for (n_offs , _type , lma , size , offs ) in prog_sections
1321
1315
if lma != 0 and size > 0
1322
1316
]
1323
1317
self .sections = prog_sections
1324
1318
self .nobits_sections = [
1325
- ELFSection (lookup_string (n_offs ), lma , b"" , flags = _flags )
1326
- for (n_offs , _type , lma , size , offs , _flags ) in nobits_secitons
1319
+ ELFSection (lookup_string (n_offs ), lma , b"" )
1320
+ for (n_offs , _type , lma , size , offs ) in nobits_secitons
1327
1321
if lma != 0 and size > 0
1328
1322
]
1329
1323
@@ -1356,7 +1350,7 @@ def read_segment_header(offs):
1356
1350
_flags ,
1357
1351
_align ,
1358
1352
) = struct .unpack_from ("<LLLLLLLL" , segment_header [offs :])
1359
- return (seg_type , lma , size , seg_offs , _flags )
1353
+ return (seg_type , lma , size , seg_offs )
1360
1354
1361
1355
all_segments = [read_segment_header (offs ) for offs in segment_header_offsets ]
1362
1356
prog_segments = [s for s in all_segments if s [0 ] == ELFFile .SEG_TYPE_LOAD ]
@@ -1366,8 +1360,8 @@ def read_data(offs, size):
1366
1360
return f .read (size )
1367
1361
1368
1362
prog_segments = [
1369
- ELFSection (b"PHDR" , lma , read_data (offs , size ), flags = _flags )
1370
- for (_type , lma , size , offs , _flags ) in prog_segments
1363
+ ELFSection (b"PHDR" , lma , read_data (offs , size ))
1364
+ for (_type , lma , size , offs ) in prog_segments
1371
1365
if lma != 0 and size > 0
1372
1366
]
1373
1367
self .segments = prog_segments
0 commit comments