def __init__(self, data):
    (magic, fourcc, arch, ver, timestamp, old_def_ver, old_imp_ver, cur_ver, sec_count, inst_sec_count, reserv) = struct.unpack_from(self.CONT_HEAD_FMT, data)
    sec_earliest = len(data)
    sec_latest = 0
    self.sections = []
    self.sectypes = []
    self.headeroffsets = []
    self.code = None
    for i in range(sec_count):
        sh_offset = (self.CONT_HEAD_LEN + (self.SEC_HED_LEN * i))
        (sectionName, sectionAddress, execSize, initSize, rawSize, containerOffset, regionKind, shareKind, alignment, reserved) = struct.unpack_from(self.SEC_HEAD_FMT, data, sh_offset)
        the_sec = data[containerOffset:(containerOffset + rawSize)]
        if ((regionKind == 0) and (execSize == initSize == rawSize)):
            the_sec = bytearray(the_sec)
            self.code = the_sec
        self.sections.append(the_sec)
        self.sectypes.append(regionKind)
        self.headeroffsets.append(sh_offset)
        sec_earliest = min(sec_earliest, containerOffset)
        sec_latest = max(sec_latest, (containerOffset + rawSize))
    if any(data[sec_latest:]):
        print('nonzero trailing data from', hex(sec_latest), 'to', hex(len(data)), ' ... will cause incorrect output')
    self.padmult = 1
    while ((len(data) % (self.padmult * 2)) == 0):
        self.padmult *= 2
    self.header = data[:sec_earliest]
def __init__(self, data):
    (magic, fourcc, arch, ver, timestamp, old_def_ver, old_imp_ver, cur_ver, sec_count, inst_sec_count, reserv) = struct.unpack_from(self.CONT_HEAD_FMT, data)
    sec_earliest = len(data)
    sec_latest = 0
    self.sections = []
    self.sectypes = []
    self.headeroffsets = []
    self.code = None
    for i in range(sec_count):
        sh_offset = (self.CONT_HEAD_LEN + (self.SEC_HED_LEN * i))
        (sectionName, sectionAddress, execSize, initSize, rawSize, containerOffset, regionKind, shareKind, alignment, reserved) = struct.unpack_from(self.SEC_HEAD_FMT, data, sh_offset)
        the_sec = data[containerOffset:(containerOffset + rawSize)]
        if ((regionKind == 0) and (execSize == initSize == rawSize)):
            the_sec = bytearray(the_sec)
            self.code = the_sec
        self.sections.append(the_sec)
        self.sectypes.append(regionKind)
        self.headeroffsets.append(sh_offset)
        sec_earliest = min(sec_earliest, containerOffset)
        sec_latest = max(sec_latest, (containerOffset + rawSize))
    if any(data[sec_latest:]):
        print('nonzero trailing data from', hex(sec_latest), 'to', hex(len(data)), ' ... will cause incorrect output')
    self.padmult = 1
    while ((len(data) % (self.padmult * 2)) == 0):
        self.padmult *= 2
    self.header = data[:sec_earliest]