本文整理汇总了C++中MCStreamer::EmitBundleUnlock方法的典型用法代码示例。如果您正苦于以下问题:C++ MCStreamer::EmitBundleUnlock方法的具体用法?C++ MCStreamer::EmitBundleUnlock怎么用?C++ MCStreamer::EmitBundleUnlock使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MCStreamer
的用法示例。
在下文中一共展示了MCStreamer::EmitBundleUnlock方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: switch
void X86::X86MCNaClExpander::expandIndirectBranch(const MCInst &Inst,
MCStreamer &Out,
const MCSubtargetInfo &STI) {
bool ThroughMemory = false, isCall = false;
switch (Inst.getOpcode()) {
case X86::CALL16m:
case X86::CALL32m:
ThroughMemory = true;
case X86::CALL16r:
case X86::CALL32r:
isCall = true;
break;
case X86::JMP16m:
case X86::JMP32m:
ThroughMemory = true;
case X86::JMP16r:
case X86::JMP32r:
break;
default:
llvm_unreachable("invalid indirect jmp/call");
}
MCOperand Target;
if (ThroughMemory) {
if (numScratchRegs() == 0) {
Error(Inst, "No scratch registers specified");
exit(1);
}
Target = MCOperand::CreateReg(getReg32(getScratchReg(0)));
MCInst Mov;
Mov.setOpcode(X86::MOV32rm);
Mov.addOperand(Target);
Mov.addOperand(Inst.getOperand(0)); // Base
Mov.addOperand(Inst.getOperand(1)); // Scale
Mov.addOperand(Inst.getOperand(2)); // Index
Mov.addOperand(Inst.getOperand(3)); // Offset
Mov.addOperand(Inst.getOperand(4)); // Segment
Out.EmitInstruction(Mov, STI);
} else {
Target = MCOperand::CreateReg(getReg32(Inst.getOperand(0).getReg()));
}
Out.EmitBundleLock(isCall);
MCInst And;
And.setOpcode(X86::AND32ri8);
And.addOperand(Target);
And.addOperand(Target);
And.addOperand(MCOperand::CreateImm(-kBundleSize));
Out.EmitInstruction(And, STI);
MCInst Branch;
Branch.setOpcode(isCall ? X86::CALL32r : X86::JMP32r);
Branch.addOperand(Target);
Out.EmitInstruction(Branch, STI);
Out.EmitBundleUnlock();
}
示例2: EmitREST
static void EmitREST(const MCInst &Inst, unsigned Reg32,
bool IsMem, MCStreamer &Out) {
unsigned Reg64 = getX86SubSuperRegister_(Reg32, MVT::i64);
Out.EmitBundleLock(false);
if (!IsMem) {
EmitMoveRegReg(false, Reg32, Inst.getOperand(0).getReg(), Out);
} else {
unsigned IndexOpPosition;
MCInst SandboxedInst = Inst;
if (SandboxMemoryRef(&SandboxedInst, &IndexOpPosition)) {
HandleMemoryRefTruncation(&SandboxedInst, IndexOpPosition, Out);
ShortenMemoryRef(&SandboxedInst, IndexOpPosition);
}
EmitLoad(false,
Reg32,
SandboxedInst.getOperand(0).getReg(), // BaseReg
SandboxedInst.getOperand(1).getImm(), // Scale
SandboxedInst.getOperand(2).getReg(), // IndexReg
SandboxedInst.getOperand(3).getImm(), // Offset
SandboxedInst.getOperand(4).getReg(), // SegmentReg
Out);
}
EmitRegFix(Reg64, Out);
Out.EmitBundleUnlock();
}
示例3: EmitDirectGuardCall
static void EmitDirectGuardCall(int I, MCInst Saved[],
MCStreamer &Out) {
// sfi_call_preamble cond=
// sfi_nops_to_force_slot3
assert(I == 2 && (ARM::SFI_GUARD_CALL == Saved[0].getOpcode()) &&
"Unexpected SFI Pseudo while lowering SFI_GUARD_CALL");
Out.EmitBundleLock(true);
Out.EmitInstruction(Saved[1]);
Out.EmitBundleUnlock();
}
示例4: EmitDirectCall
static void EmitDirectCall(const MCOperand &Op, bool Is64Bit,
MCStreamer &Out) {
Out.EmitBundleLock(true);
MCInst CALLInst;
CALLInst.setOpcode(Is64Bit ? X86::CALL64pcrel32 : X86::CALLpcrel32);
CALLInst.addOperand(Op);
Out.EmitInstruction(CALLInst);
Out.EmitBundleUnlock();
}
示例5: EmitGuardLoadOrStoreTst
static void EmitGuardLoadOrStoreTst(int I, MCInst Saved[], MCStreamer &Out) {
// sfi_cstore_preamble reg -->
// sfi_nop_if_at_bundle_end
// sfi_data_tst \reg
assert(I == 2 && (ARM::SFI_GUARD_LOADSTORE_TST == Saved[0].getOpcode()) &&
"Unexpected SFI Pseudo while lowering");
unsigned Reg = Saved[0].getOperand(0).getReg();
Out.EmitBundleLock(false);
EmitTST(Out, Reg);
Out.EmitInstruction(Saved[1]);
Out.EmitBundleUnlock();
}
示例6: EmitGuardReturn
static void EmitGuardReturn(int I, MCInst Saved[], MCStreamer &Out) {
// sfi_return_preamble reg cond=
// sfi_nop_if_at_bundle_end
// sfi_code_mask \reg \cond
assert(I == 2 && (ARM::SFI_GUARD_RETURN == Saved[0].getOpcode()) &&
"Unexpected SFI Pseudo while lowering SFI_GUARD_RETURN");
int64_t Pred = Saved[0].getOperand(0).getImm();
Out.EmitBundleLock(false);
EmitBICMask(Out, ARM::LR, Pred, 0xC000000F);
Out.EmitInstruction(Saved[1]);
Out.EmitBundleUnlock();
}
示例7: EmitGuardLoadOrStore
static void EmitGuardLoadOrStore(int I, MCInst Saved[], MCStreamer &Out) {
// sfi_store_preamble reg cond ---->
// sfi_nop_if_at_bundle_end
// sfi_data_mask \reg, \cond
assert(I == 2 && (ARM::SFI_GUARD_LOADSTORE == Saved[0].getOpcode()) &&
"Unexpected SFI Pseudo while lowering SFI_GUARD_RETURN");
unsigned Reg = Saved[0].getOperand(0).getReg();
int64_t Pred = Saved[0].getOperand(2).getImm();
Out.EmitBundleLock(false);
EmitBICMask(Out, Reg, Pred, 0xC0000000);
Out.EmitInstruction(Saved[1]);
Out.EmitBundleUnlock();
}
示例8: EmitIndirectGuardCall
static void EmitIndirectGuardCall(int I, MCInst Saved[],
MCStreamer &Out) {
// sfi_indirect_call_preamble link cond=
// sfi_nops_to_force_slot2
// sfi_code_mask \link \cond
assert(I == 2 && (ARM::SFI_GUARD_INDIRECT_CALL == Saved[0].getOpcode()) &&
"Unexpected SFI Pseudo while lowering SFI_GUARD_CALL");
unsigned Reg = Saved[0].getOperand(0).getReg();
int64_t Pred = Saved[0].getOperand(2).getImm();
Out.EmitBundleLock(true);
EmitBICMask(Out, Reg, Pred, 0xC000000F);
Out.EmitInstruction(Saved[1]);
Out.EmitBundleUnlock();
}
示例9: EmitIndirectGuardJmp
static void EmitIndirectGuardJmp(int I, MCInst Saved[], MCStreamer &Out) {
// sfi_indirect_jump_preamble link --->
// sfi_nop_if_at_bundle_end
// sfi_code_mask \link \link \maskreg
assert(I == 2 && (Mips::SFI_GUARD_INDIRECT_JMP == Saved[0].getOpcode()) &&
"Unexpected SFI Pseudo while lowering SFI_GUARD_INDIRECT_JMP");
unsigned Addr = Saved[0].getOperand(0).getReg();
unsigned Mask = Saved[0].getOperand(2).getReg();
Out.EmitBundleLock(false);
EmitMask(Out, Addr, Mask);
Out.EmitInstruction(Saved[1]);
Out.EmitBundleUnlock();
}
示例10: EmitSPArith
static void EmitSPArith(unsigned Opc, const MCOperand &ImmOp,
MCStreamer &Out) {
Out.EmitBundleLock(false);
MCInst Tmp;
Tmp.setOpcode(Opc);
Tmp.addOperand(MCOperand::CreateReg(X86::RSP));
Tmp.addOperand(MCOperand::CreateReg(X86::RSP));
Tmp.addOperand(ImmOp);
Out.EmitInstruction(Tmp);
EmitRegFix(X86::RSP, Out);
Out.EmitBundleUnlock();
}
示例11: EmitGuardLoadOrStore
static void EmitGuardLoadOrStore(int I, MCInst Saved[], MCStreamer &Out) {
// sfi_load_store_preamble reg --->
// sfi_nop_if_at_bundle_end
// sfi_data_mask \reg \reg \maskreg
assert(I == 2 && (Mips::SFI_GUARD_LOADSTORE == Saved[0].getOpcode()) &&
"Unexpected SFI Pseudo while lowering SFI_GUARD_LOADSTORE");
unsigned Reg = Saved[0].getOperand(0).getReg();
unsigned Mask = Saved[0].getOperand(2).getReg();
Out.EmitBundleLock(false);
EmitMask(Out, Reg, Mask);
Out.EmitInstruction(Saved[1]);
Out.EmitBundleUnlock();
}
示例12: EmitDataMask
// This is ONLY used for sandboxing stack changes.
// The reason why SFI_NOP_IF_AT_BUNDLE_END gets handled here is that
// it must ensure that the two instructions are in the same bundle.
// It just so happens that the SFI_NOP_IF_AT_BUNDLE_END is always
// emitted in conjunction with a SFI_DATA_MASK
//
static void EmitDataMask(int I, MCInst Saved[], MCStreamer &Out) {
assert(I == 3 &&
(Mips::SFI_NOP_IF_AT_BUNDLE_END == Saved[0].getOpcode()) &&
(Mips::SFI_DATA_MASK == Saved[2].getOpcode()) &&
"Unexpected SFI Pseudo while lowering");
unsigned Addr = Saved[2].getOperand(0).getReg();
unsigned Mask = Saved[2].getOperand(2).getReg();
assert((Mips::SP == Addr) && "Unexpected register at stack guard");
Out.EmitBundleLock(false);
Out.EmitInstruction(Saved[1]);
EmitMask(Out, Addr, Mask);
Out.EmitBundleUnlock();
}
示例13: EmitSPAdj
static void EmitSPAdj(const MCOperand &ImmOp, MCStreamer &Out) {
Out.EmitBundleLock(false);
MCInst Tmp;
Tmp.setOpcode(X86::LEA64_32r);
Tmp.addOperand(MCOperand::CreateReg(X86::RSP)); // DestReg
Tmp.addOperand(MCOperand::CreateReg(X86::RBP)); // BaseReg
Tmp.addOperand(MCOperand::CreateImm(1)); // Scale
Tmp.addOperand(MCOperand::CreateReg(0)); // IndexReg
Tmp.addOperand(ImmOp); // Offset
Tmp.addOperand(MCOperand::CreateReg(0)); // SegmentReg
Out.EmitInstruction(Tmp);
EmitRegFix(X86::RSP, Out);
Out.EmitBundleUnlock();
}
示例14: EmitIndirectGuardCall
static void EmitIndirectGuardCall(int I, MCInst Saved[],
MCStreamer &Out) {
// sfi_indirect_call_preamble link --->
// sfi_nops_to_force_slot1
// sfi_code_mask \link \link \maskreg
assert(I == 3 && (Mips::SFI_GUARD_INDIRECT_CALL == Saved[0].getOpcode()) &&
"Unexpected SFI Pseudo while lowering SFI_GUARD_INDIRECT_CALL");
unsigned Addr = Saved[0].getOperand(0).getReg();
unsigned Mask = Saved[0].getOperand(2).getReg();
Out.EmitBundleLock(true);
EmitMask(Out, Addr, Mask);
Out.EmitInstruction(Saved[1]);
Out.EmitInstruction(Saved[2]);
Out.EmitBundleUnlock();
}
示例15: EmitDirectCall
static void EmitDirectCall(const MCOperand &Op, bool Is64Bit,
MCStreamer &Out) {
const bool HideSandboxBase = (FlagHideSandboxBase &&
Is64Bit && !FlagUseZeroBasedSandbox);
if (HideSandboxBase) {
// For NaCl64, the sequence
// call target
// return_addr:
// is changed to
// push return_addr
// jmp target
// .align 32
// return_addr:
// This avoids exposing the sandbox base address via the return
// address on the stack.
MCContext &Context = Out.getContext();
// Generate a label for the return address.
MCSymbol *RetTarget = CreateTempLabel(Context, "DirectCallRetAddr");
const MCExpr *RetTargetExpr = MCSymbolRefExpr::Create(RetTarget, Context);
// push return_addr
MCInst PUSHInst;
PUSHInst.setOpcode(X86::PUSH64i32);
PUSHInst.addOperand(MCOperand::CreateExpr(RetTargetExpr));
Out.EmitInstruction(PUSHInst);
// jmp target
MCInst JMPInst;
JMPInst.setOpcode(X86::JMP_4);
JMPInst.addOperand(Op);
Out.EmitInstruction(JMPInst);
Out.EmitCodeAlignment(kNaClX86InstructionBundleSize);
Out.EmitLabel(RetTarget);
} else {
Out.EmitBundleLock(true);
MCInst CALLInst;
CALLInst.setOpcode(Is64Bit ? X86::CALL64pcrel32 : X86::CALLpcrel32);
CALLInst.addOperand(Op);
Out.EmitInstruction(CALLInst);
Out.EmitBundleUnlock();
}
}