Ignore:
Timestamp:
Oct 29, 2016, 10:56:44 PM (3 years ago)
Author:
matszpk
Message:

CLRadeonExtender: Tentative ROCmBinary constructor.

File:
1 edited

Legend:

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

    r2501 r2502  
    3434
    3535ROCmBinary::ROCmBinary(size_t binaryCodeSize, cxbyte* binaryCode, Flags creationFlags)
    36         : ElfBinary64(binaryCodeSize, binaryCode, creationFlags)
     36        : ElfBinary64(binaryCodeSize, binaryCode, creationFlags),
     37          kernelsNum(0), codeSize(0), code(nullptr)
    3738{
     39    cxuint textIndex = SHN_UNDEF;
     40    try
     41    { textIndex = getSectionIndex(".text"); }
     42    catch(const Exception& ex)
     43    { } // ignore failed
     44    if (textIndex!=SHN_UNDEF)
     45    {
     46        code = getSectionContent(textIndex);
     47        codeSize = ULEV(getSectionHeader(textIndex).sh_size);
     48    }
     49   
     50    kernelsNum = 0;
     51    const size_t symbolsNum = getSymbolsNum();
     52    for (size_t i = 0; i < symbolsNum; i++)
     53    {
     54        const Elf64_Sym& sym = getSymbol(i);
     55        if (sym.st_shndx==textIndex)
     56            kernelsNum++;
     57    }
     58    if (code==nullptr && kernelsNum!=0)
     59        throw Exception("No code if kernels number is not zero");
     60    kernels.reset(new ROCmKernel[kernelsNum]);
     61    size_t j = 0;
     62    for (size_t i = 0; i < symbolsNum; i++)
     63    {
     64        const Elf64_Sym& sym = getSymbol(i);
     65        if (sym.st_shndx!=textIndex)
     66            continue;
     67        const size_t value = ULEV(sym.st_value);
     68        kernels[j++] = { getSymbolName(i), code+value, code+value+0x100 };
     69    }
     70    if (hasKernelMap())
     71    {   // create kernels map
     72        kernelsMap.resize(kernelsNum);
     73        for (size_t i = 0; i < kernelsNum; i++)
     74            kernelsMap[i] = std::make_pair(kernels[i].kernelName, i);
     75        mapSort(kernelsMap.begin(), kernelsMap.end());
     76    }
    3877}
    3978
     
    5190    if (!isElfBinary(binarySize, binary))
    5291        return false;
     92        return false;
    5393    if (binary[EI_CLASS] != ELFCLASS64)
    5494        return false;
Note: See TracChangeset for help on using the changeset viewer.