mirror of
https://github.com/RPCSX/llvm.git
synced 2025-01-27 07:12:06 +00:00
Proper support of non-lazy indirect symbols.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@81422 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
43e484fbcf
commit
08669746d0
@ -60,6 +60,7 @@ namespace {
|
|||||||
ARMJITInfo *JTI;
|
ARMJITInfo *JTI;
|
||||||
const ARMInstrInfo *II;
|
const ARMInstrInfo *II;
|
||||||
const TargetData *TD;
|
const TargetData *TD;
|
||||||
|
const ARMSubtarget *Subtarget;
|
||||||
TargetMachine &TM;
|
TargetMachine &TM;
|
||||||
CodeEmitter &MCE;
|
CodeEmitter &MCE;
|
||||||
const std::vector<MachineConstantPoolEntry> *MCPEs;
|
const std::vector<MachineConstantPoolEntry> *MCPEs;
|
||||||
@ -163,7 +164,7 @@ namespace {
|
|||||||
/// Routines that handle operands which add machine relocations which are
|
/// Routines that handle operands which add machine relocations which are
|
||||||
/// fixed up by the relocation stage.
|
/// fixed up by the relocation stage.
|
||||||
void emitGlobalAddress(GlobalValue *GV, unsigned Reloc,
|
void emitGlobalAddress(GlobalValue *GV, unsigned Reloc,
|
||||||
bool NeedStub, intptr_t ACPV = 0);
|
bool NeedStub, bool Indirect, intptr_t ACPV = 0);
|
||||||
void emitExternalSymbolAddress(const char *ES, unsigned Reloc);
|
void emitExternalSymbolAddress(const char *ES, unsigned Reloc);
|
||||||
void emitConstPoolAddress(unsigned CPI, unsigned Reloc);
|
void emitConstPoolAddress(unsigned CPI, unsigned Reloc);
|
||||||
void emitJumpTableAddress(unsigned JTIndex, unsigned Reloc);
|
void emitJumpTableAddress(unsigned JTIndex, unsigned Reloc);
|
||||||
@ -195,9 +196,10 @@ bool Emitter<CodeEmitter>::runOnMachineFunction(MachineFunction &MF) {
|
|||||||
assert((MF.getTarget().getRelocationModel() != Reloc::Default ||
|
assert((MF.getTarget().getRelocationModel() != Reloc::Default ||
|
||||||
MF.getTarget().getRelocationModel() != Reloc::Static) &&
|
MF.getTarget().getRelocationModel() != Reloc::Static) &&
|
||||||
"JIT relocation model must be set to static or default!");
|
"JIT relocation model must be set to static or default!");
|
||||||
|
JTI = ((ARMTargetMachine&)MF.getTarget()).getJITInfo();
|
||||||
II = ((ARMTargetMachine&)MF.getTarget()).getInstrInfo();
|
II = ((ARMTargetMachine&)MF.getTarget()).getInstrInfo();
|
||||||
TD = ((ARMTargetMachine&)MF.getTarget()).getTargetData();
|
TD = ((ARMTargetMachine&)MF.getTarget()).getTargetData();
|
||||||
JTI = ((ARMTargetMachine&)MF.getTarget()).getJITInfo();
|
Subtarget = &TM.getSubtarget<ARMSubtarget>();
|
||||||
MCPEs = &MF.getConstantPool()->getConstants();
|
MCPEs = &MF.getConstantPool()->getConstants();
|
||||||
MJTEs = &MF.getJumpTableInfo()->getJumpTables();
|
MJTEs = &MF.getJumpTableInfo()->getJumpTables();
|
||||||
IsPIC = TM.getRelocationModel() == Reloc::PIC_;
|
IsPIC = TM.getRelocationModel() == Reloc::PIC_;
|
||||||
@ -244,7 +246,7 @@ unsigned Emitter<CodeEmitter>::getMachineOpValue(const MachineInstr &MI,
|
|||||||
else if (MO.isImm())
|
else if (MO.isImm())
|
||||||
return static_cast<unsigned>(MO.getImm());
|
return static_cast<unsigned>(MO.getImm());
|
||||||
else if (MO.isGlobal())
|
else if (MO.isGlobal())
|
||||||
emitGlobalAddress(MO.getGlobal(), ARM::reloc_arm_branch, true);
|
emitGlobalAddress(MO.getGlobal(), ARM::reloc_arm_branch, true, false);
|
||||||
else if (MO.isSymbol())
|
else if (MO.isSymbol())
|
||||||
emitExternalSymbolAddress(MO.getSymbolName(), ARM::reloc_arm_branch);
|
emitExternalSymbolAddress(MO.getSymbolName(), ARM::reloc_arm_branch);
|
||||||
else if (MO.isCPI()) {
|
else if (MO.isCPI()) {
|
||||||
@ -270,9 +272,14 @@ unsigned Emitter<CodeEmitter>::getMachineOpValue(const MachineInstr &MI,
|
|||||||
///
|
///
|
||||||
template<class CodeEmitter>
|
template<class CodeEmitter>
|
||||||
void Emitter<CodeEmitter>::emitGlobalAddress(GlobalValue *GV, unsigned Reloc,
|
void Emitter<CodeEmitter>::emitGlobalAddress(GlobalValue *GV, unsigned Reloc,
|
||||||
bool NeedStub, intptr_t ACPV) {
|
bool NeedStub, bool Indirect,
|
||||||
MCE.addRelocation(MachineRelocation::getGV(MCE.getCurrentPCOffset(), Reloc,
|
intptr_t ACPV) {
|
||||||
GV, ACPV, NeedStub));
|
MachineRelocation MR = Indirect
|
||||||
|
? MachineRelocation::getIndirectSymbol(MCE.getCurrentPCOffset(), Reloc,
|
||||||
|
GV, ACPV, NeedStub)
|
||||||
|
: MachineRelocation::getGV(MCE.getCurrentPCOffset(), Reloc,
|
||||||
|
GV, ACPV, NeedStub);
|
||||||
|
MCE.addRelocation(MR);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// emitExternalSymbolAddress - Arrange for the address of an external symbol to
|
/// emitExternalSymbolAddress - Arrange for the address of an external symbol to
|
||||||
@ -417,8 +424,11 @@ void Emitter<CodeEmitter>::emitConstPoolInstruction(const MachineInstr &MI) {
|
|||||||
|
|
||||||
GlobalValue *GV = ACPV->getGV();
|
GlobalValue *GV = ACPV->getGV();
|
||||||
if (GV) {
|
if (GV) {
|
||||||
|
Reloc::Model RelocM = TM.getRelocationModel();
|
||||||
emitGlobalAddress(GV, ARM::reloc_arm_machine_cp_entry,
|
emitGlobalAddress(GV, ARM::reloc_arm_machine_cp_entry,
|
||||||
isa<Function>(GV), (intptr_t)ACPV);
|
isa<Function>(GV),
|
||||||
|
Subtarget->GVIsIndirectSymbol(GV, RelocM),
|
||||||
|
(intptr_t)ACPV);
|
||||||
} else {
|
} else {
|
||||||
emitExternalSymbolAddress(ACPV->getSymbol(), ARM::reloc_arm_absolute);
|
emitExternalSymbolAddress(ACPV->getSymbol(), ARM::reloc_arm_absolute);
|
||||||
}
|
}
|
||||||
@ -437,7 +447,7 @@ void Emitter<CodeEmitter>::emitConstPoolInstruction(const MachineInstr &MI) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (GlobalValue *GV = dyn_cast<GlobalValue>(CV)) {
|
if (GlobalValue *GV = dyn_cast<GlobalValue>(CV)) {
|
||||||
emitGlobalAddress(GV, ARM::reloc_arm_absolute, isa<Function>(GV));
|
emitGlobalAddress(GV, ARM::reloc_arm_absolute, isa<Function>(GV), false);
|
||||||
emitWordLE(0);
|
emitWordLE(0);
|
||||||
} else if (const ConstantInt *CI = dyn_cast<ConstantInt>(CV)) {
|
} else if (const ConstantInt *CI = dyn_cast<ConstantInt>(CV)) {
|
||||||
uint32_t Val = *(uint32_t*)CI->getValue().getRawData();
|
uint32_t Val = *(uint32_t*)CI->getValue().getRawData();
|
||||||
|
@ -145,6 +145,9 @@ void *ARMJITInfo::emitGlobalValueIndirectSym(const GlobalValue *GV, void *Ptr,
|
|||||||
llvm_unreachable("ERROR: Unable to mark indirect symbol writable");
|
llvm_unreachable("ERROR: Unable to mark indirect symbol writable");
|
||||||
}
|
}
|
||||||
JCE.emitWordLE((intptr_t)Ptr);
|
JCE.emitWordLE((intptr_t)Ptr);
|
||||||
|
if (!sys::Memory::setRangeExecutable((void*)Addr, 4)) {
|
||||||
|
llvm_unreachable("ERROR: Unable to mark indirect symbol executable");
|
||||||
|
}
|
||||||
void *PtrAddr = JCE.finishGVStub(GV);
|
void *PtrAddr = JCE.finishGVStub(GV);
|
||||||
addIndirectSymAddr(Ptr, (intptr_t)PtrAddr);
|
addIndirectSymAddr(Ptr, (intptr_t)PtrAddr);
|
||||||
return PtrAddr;
|
return PtrAddr;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user