Changeset 2506 in CLRX


Ignore:
Timestamp:
Oct 30, 2016, 8:45:50 AM (4 years ago)
Author:
matszpk
Message:

CLRadeonExtender: ROCm: fixed ROCm loading (wrong treatment of symbol's values).

File:
1 edited

Legend:

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

    r2504 r2506  
    4242    catch(const Exception& ex)
    4343    { } // ignore failed
     44    uint64_t codeOffset = 0;
    4445    if (textIndex!=SHN_UNDEF)
    4546    {
    4647        code = getSectionContent(textIndex);
    47         codeSize = ULEV(getSectionHeader(textIndex).sh_size);
     48        const Elf64_Shdr& textShdr = getSectionHeader(textIndex);
     49        codeSize = ULEV(textShdr.sh_size);
     50        codeOffset = ULEV(textShdr.sh_offset);
    4851    }
    4952   
     
    6972            continue;
    7073        const size_t value = ULEV(sym.st_value);
     74        if (value < codeOffset)
     75            throw Exception("Kernel offset is too small!");
    7176        const size_t size = ULEV(sym.st_size);
    72         if (value+0x100 > codeSize)
     77        if (value+0x100 > codeOffset+codeSize)
    7378            throw Exception("Kernel offset is too big!");
    7479        kernelOffsets[j] = std::make_pair(value, j);
    75         kernels[j++] = { getSymbolName(i), code+value, size, code+value+0x100 };
     80        kernels[j++] = { getSymbolName(i), binaryCode+value, size,
     81            binaryCode+value+0x100 };
    7682    }
    7783    std::sort(kernelOffsets.get(), kernelOffsets.get()+kernelsNum,
     
    9197    }
    9298    {   // last kernel in position
    93         if (kernelOffsets[kernelsNum-1].first+0x100 > codeSize)
     99        if (kernelOffsets[kernelsNum-1].first+0x100 > codeOffset+codeSize)
    94100            throw Exception("Kernel size is too small!");
    95101        ROCmKernel& kernel = kernels[kernelOffsets[kernelsNum-1].second];
Note: See TracChangeset for help on using the changeset viewer.