llvm.org GIT mirror llvm / bf25604
Merge 81422 from mainline. Proper support of non-lazy indirect symbols. git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_26@81648 91177308-0d34-0410-b5e6-96231b3b80d8 Tanya Lattner 10 years ago
2 changed file(s) with 21 addition(s) and 8 deletion(s). Raw diff Collapse all Expand all
5959 ARMJITInfo *JTI;
6060 const ARMInstrInfo *II;
6161 const TargetData *TD;
62 const ARMSubtarget *Subtarget;
6263 TargetMachine &TM;
6364 CodeEmitter &MCE;
6465 const std::vector *MCPEs;
162163 /// Routines that handle operands which add machine relocations which are
163164 /// fixed up by the relocation stage.
164165 void emitGlobalAddress(GlobalValue *GV, unsigned Reloc,
165 bool NeedStub, intptr_t ACPV = 0);
166 bool NeedStub, bool Indirect, intptr_t ACPV = 0);
166167 void emitExternalSymbolAddress(const char *ES, unsigned Reloc);
167168 void emitConstPoolAddress(unsigned CPI, unsigned Reloc);
168169 void emitJumpTableAddress(unsigned JTIndex, unsigned Reloc);
194195 assert((MF.getTarget().getRelocationModel() != Reloc::Default ||
195196 MF.getTarget().getRelocationModel() != Reloc::Static) &&
196197 "JIT relocation model must be set to static or default!");
198 JTI = ((ARMTargetMachine&)MF.getTarget()).getJITInfo();
197199 II = ((ARMTargetMachine&)MF.getTarget()).getInstrInfo();
198200 TD = ((ARMTargetMachine&)MF.getTarget()).getTargetData();
199 JTI = ((ARMTargetMachine&)MF.getTarget()).getJITInfo();
201 Subtarget = &TM.getSubtarget();
200202 MCPEs = &MF.getConstantPool()->getConstants();
201203 MJTEs = &MF.getJumpTableInfo()->getJumpTables();
202204 IsPIC = TM.getRelocationModel() == Reloc::PIC_;
243245 else if (MO.isImm())
244246 return static_cast(MO.getImm());
245247 else if (MO.isGlobal())
246 emitGlobalAddress(MO.getGlobal(), ARM::reloc_arm_branch, true);
248 emitGlobalAddress(MO.getGlobal(), ARM::reloc_arm_branch, true, false);
247249 else if (MO.isSymbol())
248250 emitExternalSymbolAddress(MO.getSymbolName(), ARM::reloc_arm_branch);
249251 else if (MO.isCPI()) {
269271 ///
270272 template
271273 void Emitter::emitGlobalAddress(GlobalValue *GV, unsigned Reloc,
272 bool NeedStub, intptr_t ACPV) {
273 MCE.addRelocation(MachineRelocation::getGV(MCE.getCurrentPCOffset(), Reloc,
274 GV, ACPV, NeedStub));
274 bool NeedStub, bool Indirect,
275 intptr_t ACPV) {
276 MachineRelocation MR = Indirect
277 ? MachineRelocation::getIndirectSymbol(MCE.getCurrentPCOffset(), Reloc,
278 GV, ACPV, NeedStub)
279 : MachineRelocation::getGV(MCE.getCurrentPCOffset(), Reloc,
280 GV, ACPV, NeedStub);
281 MCE.addRelocation(MR);
275282 }
276283
277284 /// emitExternalSymbolAddress - Arrange for the address of an external symbol to
422429
423430 GlobalValue *GV = ACPV->getGV();
424431 if (GV) {
432 Reloc::Model RelocM = TM.getRelocationModel();
425433 emitGlobalAddress(GV, ARM::reloc_arm_machine_cp_entry,
426 isa(GV), (intptr_t)ACPV);
434 isa(GV),
435 Subtarget->GVIsIndirectSymbol(GV, RelocM),
436 (intptr_t)ACPV);
427437 } else {
428438 emitExternalSymbolAddress(ACPV->getSymbol(), ARM::reloc_arm_absolute);
429439 }
442452 });
443453
444454 if (GlobalValue *GV = dyn_cast(CV)) {
445 emitGlobalAddress(GV, ARM::reloc_arm_absolute, isa(GV));
455 emitGlobalAddress(GV, ARM::reloc_arm_absolute, isa(GV), false);
446456 emitWordLE(0);
447457 } else if (const ConstantInt *CI = dyn_cast(CV)) {
448458 uint32_t Val = *(uint32_t*)CI->getValue().getRawData();
146146 llvm_unreachable("ERROR: Unable to mark indirect symbol writable");
147147 }
148148 JCE.emitWordLE((intptr_t)Ptr);
149 if (!sys::Memory::setRangeExecutable((void*)Addr, 4)) {
150 llvm_unreachable("ERROR: Unable to mark indirect symbol executable");
151 }
149152 void *PtrAddr = JCE.finishGVStub(GV);
150153 addIndirectSymAddr(Ptr, (intptr_t)PtrAddr);
151154 return PtrAddr;