예제 #1
0
def AddIns(unit: elf_unit.Unit, ins: a32.Ins):
    if ins.has_reloc():
        sym = unit.FindOrAddSymbol(ins.reloc_symbol, ins.is_local_sym)
        unit.AddReloc(ins.reloc_kind, unit.sec_text, sym,
                      ins.operands[ins.reloc_pos])
        ins.clear_reloc()
    unit.sec_text.AddData(a32.Assemble(ins).to_bytes(4, byteorder='little'))
예제 #2
0
def InsSymbolize(ins: a32.Ins) -> Tuple[str, List[str]]:
    """Convert all the operands in an arm.Ins to strings including relocs
    """
    ops = []
    for pos, (ok, value) in enumerate(zip(ins.opcode.fields, ins.operands)):
        if ok in _RELOC_OK and ins.has_reloc() and ins.reloc_pos == pos:
            # Note: we essentially store the "addend" here
            ops.append(_EmitReloc(ins, pos))
        else:
            ops.append(_SymbolizeOperand(ok, value))

    return ins.opcode.name, ops