Skip to content

Commit 593e2c8

Browse files
committed
fixup! WIP: switch to ORC v2
1 parent 20acdec commit 593e2c8

File tree

1 file changed

+19
-15
lines changed

1 file changed

+19
-15
lines changed

src/debuginfo.cpp

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,9 @@ class JuliaJITEventListener: public JITEventListener
316316
#endif
317317

318318
#if defined(_OS_WINDOWS_)
319-
uint64_t SectionAddrCheck = 0; // assert that all of the Sections are at the same location
319+
uint64_t SectionAddrCheck = 0;
320+
uint64_t SectionLoadCheck = 0;
321+
uint64_t SectionWriteCheck = 0;
320322
uint8_t *UnwindData = NULL;
321323
#if defined(_CPU_X86_64_)
322324
uint8_t *catchjmp = NULL;
@@ -351,25 +353,26 @@ class JuliaJITEventListener: public JITEventListener
351353
SectionLoadAddr = getLoadAddress(sName);
352354
#endif
353355
assert(SectionLoadAddr);
354-
if (SectionAddrCheck)
355-
assert(SectionAddrCheck == SectionLoadAddr);
356-
else
357-
SectionAddrCheck = SectionLoadAddr;
356+
if (SectionAddrCheck) // assert that all of the Sections are at the same location
357+
assert(SectionAddrCheck == SectionAddr &&
358+
SectionLoadCheck == SectionLoadAddr);
359+
SectionAddrCheck = SectionAddr;
360+
SectionLoadCheck = SectionLoadAddr;
361+
SectionWriteCheck = SectionLoadAddr;
358362
if (memmgr)
359-
Addr +=
360-
(uintptr_t)lookupWriteAddressFor(memmgr,
361-
(void*)SectionLoadAddr)
362-
- SectionLoadAddr;
363+
SectionWriteCheck = (uintptr_t)lookupWriteAddressFor(memmgr,
364+
(void*)SectionLoadAddr);
365+
Addr += SectionWriteCheck - SectionLoadAddr;
363366
*pAddr = (uint8_t*)Addr;
364367
}
365368
}
366369
assert(catchjmp);
367370
assert(UnwindData);
368371
assert(SectionAddrCheck);
372+
assert(SectionLoadCheck);
369373
catchjmp[0] = 0x48;
370374
catchjmp[1] = 0xb8; // mov RAX, QWORD PTR [&__julia_personality]
371-
*(uint64_t*)(&catchjmp[2]) =
372-
(uint64_t)&__julia_personality;
375+
*(uint64_t*)(&catchjmp[2]) = (uint64_t)&__julia_personality;
373376
catchjmp[10] = 0xff;
374377
catchjmp[11] = 0xe0; // jmp RAX
375378
UnwindData[0] = 0x09; // version info, UNW_FLAG_EHANDLER
@@ -380,7 +383,7 @@ class JuliaJITEventListener: public JITEventListener
380383
UnwindData[5] = 0x03; // mov RBP, RSP
381384
UnwindData[6] = 1; // first instruction
382385
UnwindData[7] = 0x50; // push RBP
383-
*(DWORD*)&UnwindData[8] = (DWORD)(catchjmp - (uint8_t*)SectionAddrCheck); // relative location of catchjmp
386+
*(DWORD*)&UnwindData[8] = (DWORD)(catchjmp - (uint8_t*)SectionWriteCheck); // relative location of catchjmp
384387
#endif // defined(_OS_X86_64_)
385388
#endif // defined(_OS_WINDOWS_)
386389

@@ -419,9 +422,10 @@ class JuliaJITEventListener: public JITEventListener
419422
size_t Size = sym_size.second;
420423
#if defined(_OS_WINDOWS_)
421424
if (SectionAddrCheck)
422-
assert(SectionAddrCheck == SectionLoadAddr);
423-
else
424-
SectionAddrCheck = SectionLoadAddr;
425+
assert(SectionAddrCheck == SectionAddr &&
426+
SectionLoadCheck == SectionLoadAddr);
427+
SectionAddrCheck = SectionAddr;
428+
SectionLoadCheck = SectionLoadAddr;
425429
create_PRUNTIME_FUNCTION(
426430
(uint8_t*)(uintptr_t)Addr, (size_t)Size, sName,
427431
(uint8_t*)(uintptr_t)SectionLoadAddr, (size_t)SectionSize, UnwindData);

0 commit comments

Comments
 (0)