Repository: dotnet/runtime
File: src/coreclr/jit/ee_il_dll.cpp (C++)

Code before:
        coldCodeChunk->block   = codeChunk.block + (uintptr_t)coldCodeChunk->block;
        coldCodeChunk->blockRW = codeChunk.blockRW + (uintptr_t)coldCodeChunk->blockRW;
    }

#endif // DEBUG

    int curDataChunk = firstDataChunk;

#if defined(TARGET_ARM64) || defined(TARGET_LOONGARCH64) || defined(TARGET_RISCV64)

    // Fix up data section pointers.
    for (unsigned i = 0; i < numDataChunks; i++)
    {
        if ((dataChunks[i].flags & CORJIT_ALLOCMEM_HAS_POINTERS_TO_CODE) != 0)
        {
            // These are always passed to the EE as separate chunks since their relocations need special treatment
            dataChunks[i].block   = chunks.BottomRef(curDataChunk).block;
            dataChunks[i].blockRW = chunks.BottomRef(curDataChunk).blockRW;
            curDataChunk++;
        }
        else
        {
            dataChunks[i].block   = codeChunk.block + (size_t)dataChunks[i].block;
            dataChunks[i].blockRW = codeChunk.blockRW + (size_t)dataChunks[i].blockRW;
        }
    }

#else

    for (unsigned i = 0; i < numDataChunks; i++)
    {
        dataChunks[i].block   = chunks.BottomRef(curDataChunk).block;
        dataChunks[i].blockRW = chunks.BottomRef(curDataChunk).blockRW;
        curDataChunk++;
    }

#endif // defined(TARGET_ARM64) || defined(TARGET_LOONGARCH64) || defined(TARGET_RISCV64)
}

void Compiler::eeReserveUnwindInfo(bool isFunclet, bool isColdCode, ULONG unwindSize)
{
#ifdef DEBUG
    if (verbose)
    {
        printf("reserveUnwindInfo(isFunclet=%s, isColdCode=%s, unwindSize=0x%x)\n", isFunclet ? "true" : "false",
               isColdCode ? "true" : "false", unwindSize);
    }
#endif // DEBUG

    if (info.compMatchedVM)
    {

Review comment (suggestion):
BTW: it seems questionable whether we need this "put into .text" behavior at all. And if we do (due to distance constraints), then presumably we could hit problems for async resumption info too.

If we end up with the optimization to fold common read only data then we will probably want to disable this so that it also kicks in for arm64.

Code after:

    if (coldCodeChunkIndex != -1)
    {
        coldCodeChunk->block   = chunks.BottomRef(coldCodeChunkIndex).block;
        coldCodeChunk->blockRW = chunks.BottomRef(coldCodeChunkIndex).blockRW;
    }

#ifdef DEBUG

    if (JitConfig.JitFakeProcedureSplitting() && (coldCodeChunk != nullptr))
    {
        // Fix up cold code pointers. Cold section is adjacent to hot section.
        assert(coldCodeChunk != nullptr);
        coldCodeChunk->block   = codeChunk.block + (uintptr_t)coldCodeChunk->block;
        coldCodeChunk->blockRW = codeChunk.blockRW + (uintptr_t)coldCodeChunk->blockRW;
    }

#endif // DEBUG

    int curDataChunk = firstDataChunk;

#if defined(TARGET_ARM64) || defined(TARGET_LOONGARCH64) || defined(TARGET_RISCV64)

    // Fix up data section pointers.
    for (unsigned i = 0; i < numDataChunks; i++)
    {
        if (((dataChunks[i].flags & CORJIT_ALLOCMEM_HAS_POINTERS_TO_CODE) != 0) && eeDataWithCodePointersNeedsRelocs())
        {
            // These are always passed to the EE as separate chunks since their relocations need special treatment
            dataChunks[i].block   = chunks.BottomRef(curDataChunk).block;
            dataChunks[i].blockRW = chunks.BottomRef(curDataChunk).blockRW;
            curDataChunk++;
        }
        else
        {
            dataChunks[i].block   = codeChunk.block + (size_t)dataChunks[i].block;
            dataChunks[i].blockRW = codeChunk.blockRW + (size_t)dataChunks[i].blockRW;
        }
    }

#else

    for (unsigned i = 0; i < numDataChunks; i++)
    {
        dataChunks[i].block   = chunks.BottomRef(curDataChunk).block;
        dataChunks[i].blockRW = chunks.BottomRef(curDataChunk).blockRW;
        curDataChunk++;
    }

#endif // defined(TARGET_ARM64) || defined(TARGET_LOONGARCH64) || defined(TARGET_RISCV64)
}