@@ -224,16 +224,21 @@ class ClaspAllocator : public JITLinkMemoryManager {
224224 llvm::orc::ExecutorAddr ea ((uintptr_t )execMemory);
225225 OnFinalized (llvm::jitlink::InProcessMemoryManager::FinalizedAlloc (ea));
226226 }
227+
227228 virtual void abandon (OnAbandonedFunction OnAbandoned) {
228- printf (" %s:%d:%s I have no idea what to do here - calling OnAbandoned and continuing\n " , __FILE__, __LINE__, __FUNCTION__);
229- if (getenv (" CLASP_TRAP_ONABANDONED" )!=NULL ) {
230- printf (" !\n !\n !\n !\n You set CLASP_TRAP_ONABANDONED - sleeping for 9999 seconds - connect using debugger to pid %d\n !\n !\n !\n !\n " , getpid ());
231- sleep (9999 );
229+ size_t PageSize = getpagesize ();
230+ for (auto & KV : BL.segments ()) {
231+ auto & Seg = KV.second ;
232+ sys::MemoryBlock MB (Seg.WorkingMem , alignTo (Seg.ContentSize + Seg.ZeroFillSize , PageSize));
233+ auto code = sys::Memory::releaseMappedMemory (MB);
234+ if (code) {
235+ OnAbandoned (std::move (llvm::errorCodeToError (code)));
236+ return ;
237+ }
232238 }
233- printf (" !\n !\n !\n !\n If you want to trap here set CLASP_TRAP_ONABANDONED - restarting for now\n !\n !\n !\n !\n " );
234- exit (1 );
235- // OnAbandoned(std::move(llvm::Error::success()));
239+ OnAbandoned (std::move (llvm::Error::success ()));
236240 }
241+
237242 private:
238243 Error applyProtections () {
239244 JITMemoryReadExecute (BL);
@@ -960,7 +965,8 @@ void ClaspReturnObjectBuffer(std::unique_ptr<llvm::MemoryBuffer> buffer) {
960965
961966 ObjectFile_sp code = lookupObjectFile (buffer->getBufferIdentifier ().str ());
962967 code->_MemoryBuffer = std::move (buffer);
963- // printf("%s:%d:%s loadedObjectFile %p _MemoryBuffer = %p\n", __FILE__, __LINE__, __FUNCTION__, (void*)&*code, (void*)code->_MemoryBuffer.get() );
968+ // printf("%s:%d:%s loadedObjectFile %p _MemoryBuffer = %p\n", __FILE__, __LINE__, __FUNCTION__, (void*)&*code,
969+ // (void*)code->_MemoryBuffer.get() );
964970 auto objf = code->getObjectFile ();
965971 llvm::object::ObjectFile& of = *objf->get ();
966972#if defined(_TARGET_OS_LINUX)
0 commit comments