Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if self.flags & self.PF_R:
str += 'R'
else:
str += ' '
if self.flags & self.PF_W:
str += 'W'
else:
str += ' '
if self.flags & self.PF_X:
str += 'X'
else:
str += ' '
return str
class ESPCoreDumpSection(esptool.ELFSection):
""" Wrapper class for a section in core ELF file, has a section
flags as well as the common properties of an esptool.ELFSection.
"""
# section flags
SHF_WRITE = 0x1
SHF_ALLOC = 0x2
SHF_EXECINSTR = 0x4
def __init__(self, name, addr, data, flags):
"""Constructor for section
"""
super(ESPCoreDumpSection, self).__init__(name, addr, data)
self.flags = flags
def __repr__(self):
"""Returns string representation of section
if self.flags & self.PF_R:
str += 'R'
else:
str += ' '
if self.flags & self.PF_W:
str += 'W'
else:
str += ' '
if self.flags & self.PF_X:
str += 'X'
else:
str += ' '
return str
class ESPCoreDumpSection(esptool.ELFSection):
""" Wrapper class for a section in core ELF file, has a section
flags as well as the common properties of an esptool.ELFSection.
"""
# section flags
SHF_WRITE = 0x1
SHF_ALLOC = 0x2
SHF_EXECINSTR = 0x4
def __init__(self, name, addr, data, flags):
"""Constructor for section
"""
super(ESPCoreDumpSection, self).__init__(name, addr, data)
self.flags = flags
def __repr__(self):
"""Returns string representation of section
if sec_type != ELFFile.SEC_TYPE_STRTAB:
print('WARNING: ELF file has incorrect STRTAB section type 0x%02x' % sec_type)
f.seek(sec_offs)
string_table = f.read(sec_size)
# build the real list of ELFSections by reading the actual section names from the
# string table section, and actual data for each section from the ELF file itself
def lookup_string(offs):
raw = string_table[offs:]
return raw[:raw.index(b'\x00')]
def read_data(offs,size):
f.seek(offs)
return f.read(size)
prog_sections = [ELFSection(lookup_string(n_offs), lma, read_data(offs, size)) for (n_offs, _type, lma, size, offs) in prog_sections
if lma != 0 and size > 0]
self.sections = prog_sections
if sec_type != ELFFile.SEC_TYPE_STRTAB:
print('WARNING: ELF file has incorrect STRTAB section type 0x%02x' % sec_type)
f.seek(sec_offs)
string_table = f.read(sec_size)
# build the real list of ELFSections by reading the actual section names from the
# string table section, and actual data for each section from the ELF file itself
def lookup_string(offs):
raw = string_table[offs:]
return raw[:raw.index(b'\x00')]
def read_data(offs,size):
f.seek(offs)
return f.read(size)
prog_sections = [ELFSection(lookup_string(n_offs), lma, read_data(offs, size)) for (n_offs, _type, lma, size, offs) in prog_sections
if lma != 0]
self.sections = prog_sections
def __repr__(self):
return "%s %s" % (self.name, super(ELFSection, self).__repr__())
def __repr__(self):
return "%s %s" % (self.name, super(ELFSection, self).__repr__())