def read_segment_list_entry(f):
    v = [ None ] * loaderlib.SIZEOF_SI
    v[loaderlib.SI_TYPE] = persistence.read_uint8(f)
    offset_value = persistence.read_uint32(f)
    if offset_value == 0xFFFFFFFF: # Unsigned, special value.
        offset_value = -1
    v[loaderlib.SI_FILE_OFFSET] = offset_value
    v[loaderlib.SI_DATA_LENGTH] = persistence.read_uint32(f)
    v[loaderlib.SI_LENGTH] = persistence.read_uint32(f)
    v[loaderlib.SI_ADDRESS] = persistence.read_uint32(f)
    return v
Exemple #2
0
def read_segment_list_entry(f):
    v = [None] * loaderlib.SIZEOF_SI
    v[loaderlib.SI_TYPE] = persistence.read_uint8(f)
    offset_value = persistence.read_uint32(f)
    if offset_value == 0xFFFFFFFF:  # Unsigned, special value.
        offset_value = -1
    v[loaderlib.SI_FILE_OFFSET] = offset_value
    v[loaderlib.SI_DATA_LENGTH] = persistence.read_uint32(f)
    v[loaderlib.SI_LENGTH] = persistence.read_uint32(f)
    v[loaderlib.SI_ADDRESS] = persistence.read_uint32(f)
    return v
def read_SegmentBlock(f):
    block = SegmentBlock()
    bytes_to_read = struct.calcsize(SEGMENTBLOCK_PACK_FORMAT)
    block.segment_id, block.segment_offset, block.address, block.length, block.flags, block.line_count, line_data_count = struct.unpack(SEGMENTBLOCK_PACK_FORMAT, f.read(bytes_to_read))

    if line_data_count > 0:
        if get_block_data_type(block) == DATA_TYPE_CODE:
            block.line_data = [ None ] * line_data_count
            for i in xrange(line_data_count):
                type_id = persistence.read_uint8(f)
                if type_id == SLD_INSTRUCTION:
                    block_offset = persistence.read_uint16(f)
                    block.line_data[i] = (type_id, block_offset)
                elif type_id == SLD_EQU_LOCATION_RELATIVE:
                    block_offset = persistence.read_uint32(f)
                    block.line_data[i] = (type_id, block_offset)
                elif type_id in (SLD_COMMENT_TRAILING, SLD_COMMENT_FULL_LINE):
                    text = persistence.read_string(f)
                    block.line_data[i] = (type_id, text)
    return block
Exemple #4
0
def read_SegmentBlock(f):
    block = SegmentBlock()
    bytes_to_read = struct.calcsize(SEGMENTBLOCK_PACK_FORMAT)
    block.segment_id, block.segment_offset, block.address, block.length, block.flags, block.line_count, line_data_count = struct.unpack(
        SEGMENTBLOCK_PACK_FORMAT, f.read(bytes_to_read))

    if line_data_count > 0:
        if get_block_data_type(block) == DATA_TYPE_CODE:
            block.line_data = [None] * line_data_count
            for i in range(line_data_count):
                type_id = persistence.read_uint8(f)
                if type_id == SLD_INSTRUCTION:
                    block_offset = persistence.read_uint16(f)
                    block.line_data[i] = (type_id, block_offset)
                elif type_id == SLD_EQU_LOCATION_RELATIVE:
                    block_offset = persistence.read_uint32(f)
                    block.line_data[i] = (type_id, block_offset)
                elif type_id in (SLD_COMMENT_TRAILING, SLD_COMMENT_FULL_LINE):
                    text = persistence.read_string(f)
                    block.line_data[i] = (type_id, text)
    return block