Changeset 3796 in CLRX


Ignore:
Timestamp:
Feb 15, 2018, 12:04:57 AM (14 months ago)
Author:
matszpk
Message:

CLRadeonExtender: ElfBinGen?: Fixed counting region alignment (like in generate routine). Fixed including addrBase in elf header program entry.
ROCm: First working (not fully) version with got symbols. Fixed ROCm binaries for test (program entry).

Location:
CLRadeonExtender/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • CLRadeonExtender/trunk/amdasm/AsmROCmFormat.cpp

    r3795 r3796  
    17831783   
    17841784    bool haveComma = false;
    1785     if (skipComma(asmr, haveComma, linePtr))
     1785    if (!skipComma(asmr, haveComma, linePtr))
    17861786        return;
    17871787   
     
    27322732    dataSymbols.insert(dataSymbols.end(), output.symbols.begin(), output.symbols.end());
    27332733    output.symbols = std::move(dataSymbols);
    2734 }
    2735 
    2736 bool AsmROCmHandler::prepareBinary()
    2737 {
    2738     if (unresolvedGlobals)
    2739     {
    2740         // add and update symbols after section diffs prepping only
    2741         // if we have unresolved globals
    2742         addSymbols(true);
    2743         binGen->updateSymbols();
    2744     }
    27452734   
    27462735    if (gotSymbols.empty())
    2747         return good;
     2736        return;
    27482737   
    27492738    // create map to speedup finding symbol indices
     
    27602749    mapSort(extraSymMap.begin(), extraSymMap.end());
    27612750   
     2751    output.gotSymbols.clear();
    27622752    // prepare GOT symbols
    27632753    const AsmSymbolMap& symbolMap = assembler.getSymbolMap();
     
    27972787        }
    27982788    }
     2789}
     2790
     2791bool AsmROCmHandler::prepareBinary()
     2792{
     2793    if (unresolvedGlobals)
     2794    {
     2795        // add and update symbols after section diffs prepping only
     2796        // if we have unresolved globals
     2797        addSymbols(true);
     2798        binGen->updateSymbols();
     2799    }
    27992800    return good;
    28002801}
  • CLRadeonExtender/trunk/amdbin/ElfBinaries.cpp

    r3759 r3796  
    585585    {
    586586        ElfRegionTemplate<Types>& region = regions[i];
    587         if (region.align > 1)
     587        typename Types::Word ralign = (region.type==ElfRegionType::SECTION) ?
     588                        region.section.align : 0;
     589        ralign = std::max(region.align, ralign);
     590        if (ralign > 1)
    588591        {
    589592            // fix alignment
    590             if ((size&(region.align-1))!=0)
    591                 size += region.align - (size&(region.align-1));
    592             if ((address&(region.align-1))!=0)
    593                 address += region.align - (address&(region.align-1));
     593            if ((size&(ralign-1))!=0)
     594                size += ralign - (size&(ralign-1));
     595            if ((address&(ralign-1))!=0)
     596                address += ralign - (address&(ralign-1));
    594597        }
    595598       
     
    840843            if (regions[header.entryRegion].type == ElfRegionType::SECTION &&
    841844                regions[header.entryRegion].section.addrBase != 0)
    842                 entry += regions[header.entryRegion].section.addrBase;
     845            {
     846                auto addrBase = regions[header.entryRegion].section.addrBase;
     847                entry += addrBase != Types::nobase ? addrBase : 0;
     848            }
    843849            else
    844850                entry += header.vaddrBase;
  • CLRadeonExtender/trunk/amdbin/ROCmBinaries.cpp

    r3794 r3796  
    21102110        eflags = input->eflags;
    21112111   
    2112     elfBinGen64.reset(new ElfBinaryGen64({ 0U, 0U, 0x40, 0, ET_DYN,
    2113             0xe0, EV_CURRENT, UINT_MAX, 0, eflags },
    2114             true, true, true, PHREGION_FILESTART));
    2115    
    21162112    std::fill(mainBuiltinSectTable,
    21172113              mainBuiltinSectTable + ROCMSECTID_MAX-ELFSECTID_START+1, SHN_UNDEF);
     
    21422138    addMainSectionToTable(mainSectionsNum, mainBuiltinSectTable, ELFSECTID_SHSTRTAB);
    21432139    addMainSectionToTable(mainSectionsNum, mainBuiltinSectTable, ELFSECTID_STRTAB);
     2140   
     2141    elfBinGen64.reset(new ElfBinaryGen64({ 0U, 0U, 0x40, 0, ET_DYN, 0xe0, EV_CURRENT,
     2142            cxuint(input->newBinFormat ? execProgHeaderRegionIndex : UINT_MAX), 0, eflags },
     2143            true, true, true, PHREGION_FILESTART));
    21442144   
    21452145    static const int32_t dynTags[] = {
     
    22442244    if (!input->gotSymbols.empty())
    22452245    {
    2246         rocmRelaDynGen = new ROCmRelaDynGen(input);
     2246        ROCmRelaDynGen* sgen = new ROCmRelaDynGen(input);
     2247        rocmRelaDynGen = (void*)sgen;
    22472248        elfBinGen64->addRegion(ElfRegion64(input->gotSymbols.size()*sizeof(Elf64_Rela),
    2248                 (ElfRegionContent*)rocmRelaDynGen, 8, "rela.dyn",
    2249                 SHT_RELA, SHF_ALLOC, 0, 0,
     2249                sgen, 8, ".rela.dyn", SHT_RELA, SHF_ALLOC,
    22502250                mainBuiltinSectTable[ELFSECTID_DYNSYM-ELFSECTID_START], 0,
    22512251                Elf64Types::nobase, sizeof(Elf64_Rela)));
     
    22612261    if (!input->gotSymbols.empty())
    22622262    {
    2263         rocmGotGen = new ROCmGotGen(input);
    2264         elfBinGen64->addRegion(ElfRegion64(input->gotSymbols.size()*8,
    2265                 (ElfRegionContent*)rocmGotGen, 8, ".got", SHT_PROGBITS,
     2263        ROCmGotGen* sgen = new ROCmGotGen(input);
     2264        rocmGotGen = (void*)sgen;
     2265        elfBinGen64->addRegion(ElfRegion64(input->gotSymbols.size()*8, sgen,
     2266                8, ".got", SHT_PROGBITS,
    22662267                SHF_ALLOC|SHF_WRITE, 0, 0, Elf64Types::nobase));
    22672268    }
Note: See TracChangeset for help on using the changeset viewer.