Beispiel #1
0
    def encode_header(self,
                      encoder,
                      name_index_map,
                      section_index_map,
                      offset,
                      address=None,
                      link_section=None,
                      info=None,
                      content_size=0,
                      entry_size=0):
        import peachpy.encoder
        from peachpy.util import is_uint64, is_uint32
        assert isinstance(encoder, peachpy.encoder.Encoder)
        assert isinstance(name_index_map, dict)
        assert section_index_map is None or isinstance(section_index_map, dict)
        assert offset is None or is_uint64(offset)
        assert address is None or is_uint64(address)
        assert link_section is None or isinstance(link_section, Section)
        assert info is None or is_uint64(info)
        assert is_uint64(content_size)
        assert is_uint32(entry_size)

        assert encoder.bitness in [32, 64]
        if encoder.bitness == 32:
            assert offset is None or is_uint32(offset)
            assert address is None or is_uint32(address)
        assert self.name is None or self.name in name_index_map
        assert section_index_map is not None or link_section is None

        name_index = name_index_map.get(self.name, 0)
        if address is None:
            address = 0
        if offset is None:
            offset = 0
        link = 0
        if link_section is not None:
            link = section_index_map[link_section]
        if info is None:
            info = 0
        return encoder.uint32(name_index) + \
            encoder.uint32(self.type) + \
            encoder.unsigned_offset(self.flags) + \
            encoder.unsigned_offset(address) + \
            encoder.unsigned_offset(offset) + \
            encoder.unsigned_offset(content_size) + \
            encoder.uint32(link) + \
            encoder.uint32(info) + \
            encoder.unsigned_offset(self.alignment) + \
            encoder.unsigned_offset(entry_size)
Beispiel #2
0
    def encode_header(self, encoder, name_index_map, section_index_map, offset,
                      address=None, link_section=None, info=None,
                      content_size=0, entry_size=0):
        import peachpy.encoder
        from peachpy.util import is_uint64, is_uint32
        assert isinstance(encoder, peachpy.encoder.Encoder)
        assert isinstance(name_index_map, dict)
        assert section_index_map is None or isinstance(section_index_map, dict)
        assert offset is None or is_uint64(offset)
        assert address is None or is_uint64(address)
        assert link_section is None or isinstance(link_section, Section)
        assert info is None or is_uint64(info)
        assert is_uint64(content_size)
        assert is_uint32(entry_size)

        assert encoder.bitness in [32, 64]
        if encoder.bitness == 32:
            assert offset is None or is_uint32(offset)
            assert address is None or is_uint32(address)
        assert self.name is None or self.name in name_index_map
        assert section_index_map is not None or link_section is None

        name_index = name_index_map.get(self.name, 0)
        if address is None:
            address = 0
        if offset is None:
            offset = 0
        link = 0
        if link_section is not None:
            link = section_index_map[link_section]
        if info is None:
            info = 0
        return encoder.uint32(name_index) + \
            encoder.uint32(self.type) + \
            encoder.unsigned_offset(self.flags) + \
            encoder.unsigned_offset(address) + \
            encoder.unsigned_offset(offset) + \
            encoder.unsigned_offset(content_size) + \
            encoder.uint32(link) + \
            encoder.uint32(info) + \
            encoder.unsigned_offset(self.alignment) + \
            encoder.unsigned_offset(entry_size)
Beispiel #3
0
    def __init__(self, type, offset, symbol, addend):
        from peachpy.util import is_uint64, is_sint64
        assert isinstance(type, RelocationType)
        assert is_uint64(offset)
        assert isinstance(symbol, Symbol)
        assert is_sint64(addend)

        self.type = type
        self.offset = offset
        self.symbol = symbol
        self.addend = addend
Beispiel #4
0
    def __init__(self, type, offset, symbol, addend):
        from peachpy.util import is_uint64, is_sint64
        assert isinstance(type, RelocationType)
        assert is_uint64(offset)
        assert isinstance(symbol, Symbol)
        assert is_sint64(addend)

        self.type = type
        self.offset = offset
        self.symbol = symbol
        self.addend = addend