llvm.org GIT mirror llvm / 8a57704
Merge 81311 from mainline. Make sure to make stub region writable before emission, executable after emission. git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_26@81640 91177308-0d34-0410-b5e6-96231b3b80d8 Tanya Lattner 11 years ago
1 changed file(s) with 22 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
141141 void *ARMJITInfo::emitGlobalValueIndirectSym(const GlobalValue *GV, void *Ptr,
142142 JITCodeEmitter &JCE) {
143143 JCE.startGVStub(GV, 4, 4);
144 intptr_t Addr = (intptr_t)JCE.getCurrentPCValue();
145 if (!sys::Memory::setRangeWritable((void*)Addr, 4)) {
146 llvm_unreachable("ERROR: Unable to mark indirect symbol writable");
147 }
144148 JCE.emitWordLE((intptr_t)Ptr);
145149 void *PtrAddr = JCE.finishGVStub(GV);
146150 addIndirectSymAddr(Ptr, (intptr_t)PtrAddr);
168172 }
169173 JCE.startGVStub(F, 16, 4);
170174 intptr_t Addr = (intptr_t)JCE.getCurrentPCValue();
175 if (!sys::Memory::setRangeWritable((void*)Addr, 16)) {
176 llvm_unreachable("ERROR: Unable to mark stub writable");
177 }
171178 JCE.emitWordLE(0xe59fc004); // ldr pc, [pc, #+4]
172179 JCE.emitWordLE(0xe08fc00c); // L_func$scv: add ip, pc, ip
173180 JCE.emitWordLE(0xe59cf000); // ldr pc, [ip]
174181 JCE.emitWordLE(LazyPtr - (Addr+4+8)); // func - (L_func$scv+8)
175182 sys::Memory::InvalidateInstructionCache((void*)Addr, 16);
183 if (!sys::Memory::setRangeExecutable((void*)Addr, 16)) {
184 llvm_unreachable("ERROR: Unable to mark stub executable");
185 }
176186 } else {
177187 // The stub is 8-byte size and 4-aligned.
178188 JCE.startGVStub(F, 8, 4);
179189 intptr_t Addr = (intptr_t)JCE.getCurrentPCValue();
190 if (!sys::Memory::setRangeWritable((void*)Addr, 8)) {
191 llvm_unreachable("ERROR: Unable to mark stub writable");
192 }
180193 JCE.emitWordLE(0xe51ff004); // ldr pc, [pc, #-4]
181194 JCE.emitWordLE((intptr_t)Fn); // addr of function
182195 sys::Memory::InvalidateInstructionCache((void*)Addr, 8);
196 if (!sys::Memory::setRangeExecutable((void*)Addr, 8)) {
197 llvm_unreachable("ERROR: Unable to mark stub executable");
198 }
183199 }
184200 } else {
185201 // The compilation callback will overwrite the first two words of this
191207 // The stub is 16-byte size and 4-byte aligned.
192208 JCE.startGVStub(F, 16, 4);
193209 intptr_t Addr = (intptr_t)JCE.getCurrentPCValue();
210 if (!sys::Memory::setRangeWritable((void*)Addr, 16)) {
211 llvm_unreachable("ERROR: Unable to mark stub writable");
212 }
194213 // Save LR so the callback can determine which stub called it.
195214 // The compilation callback is responsible for popping this prior
196215 // to returning.
202221 // The address of the compilation callback.
203222 JCE.emitWordLE((intptr_t)ARMCompilationCallback);
204223 sys::Memory::InvalidateInstructionCache((void*)Addr, 16);
224 if (!sys::Memory::setRangeExecutable((void*)Addr, 16)) {
225 llvm_unreachable("ERROR: Unable to mark stub executable");
226 }
205227 }
206228
207229 return JCE.finishGVStub(F);