Ignore:
Timestamp:
Oct 30, 2016, 6:22:17 AM (4 years ago)
Author:
matszpk
Message:

CLRadeonExtender: Add sanity checking for kernel's offsets (ROCm).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • CLRadeonExtender/trunk/amdbin/ROCmBinaries.cpp

    r2502 r2503  
    6060    kernels.reset(new ROCmKernel[kernelsNum]);
    6161    size_t j = 0;
     62    std::unique_ptr<uint64_t[]> kernelOffsets(new uint64_t[kernelsNum]);
    6263    for (size_t i = 0; i < symbolsNum; i++)
    6364    {
     
    6667            continue;
    6768        const size_t value = ULEV(sym.st_value);
     69        if (value+0x100 > codeSize)
     70            throw Exception("Kernel offset is too big!");
     71        kernelOffsets[j] = value;
    6872        kernels[j++] = { getSymbolName(i), code+value, code+value+0x100 };
    6973    }
     74    std::sort(kernelOffsets.get(), kernelOffsets.get()+kernelsNum);
     75    // checking distance between kernels
     76    for (size_t i = 1; i < kernelsNum; i++)
     77        if (kernelOffsets[i-1]+0x100 > kernelOffsets[i])
     78            throw Exception("Kernel size is too small!");
     79   
    7080    if (hasKernelMap())
    7181    {   // create kernels map
Note: See TracChangeset for help on using the changeset viewer.