Changeset 2564 in CLRX


Ignore:
Timestamp:
Nov 16, 2016, 4:33:50 PM (4 years ago)
Author:
matszpk
Message:

CLRadeonExtender: ElfBinGen?: Add handling PHREGION_FILESTART to addrRegionStart.
ROCmBinGen: Fixing differences between original file and generated file.

Location:
CLRadeonExtender/trunk/amdbin
Files:
2 edited

Legend:

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

    r2563 r2564  
    534534    sectionRegions[0] = UINT_MAX;
    535535    sectionCount = addNullSection;
    536     typename Types::Word address = 0;
     536    typename Types::Word address = (addrStartRegion==PHREGION_FILESTART) ? size : 0;
     537   
    537538    std::unique_ptr<typename Types::Word[]> dynValTable;
    538539    if (haveDynamic)
     
    579580                    throw Exception("Region end out of range");
    580581            }
     582            if (addrStartRegion==PHREGION_FILESTART)
     583                address = size;
    581584        }
    582585        else if (region.type == ElfRegionType::SHDR_TABLE)
     
    585588            region.size = size-regionOffsets[i];
    586589            shdrTabRegion = i;
     590            if (addrStartRegion==PHREGION_FILESTART)
     591                address = size;
    587592        }
    588593        else if (region.type == ElfRegionType::USER)
     594        {
     595            if (addrStartRegion==PHREGION_FILESTART)
     596                address = size;
    589597            size += region.size;
     598        }
    590599        else if (region.type == ElfRegionType::SECTION)
    591600        {   // if section
     
    680689                    region.size = size-regionOffsets[i];
    681690            }
    682             if (i >= addrStartRegion) // begin counting address from that region
     691            if (addrStartRegion==PHREGION_FILESTART)
     692                address = size;
     693            else if (i >= addrStartRegion) // begin counting address from that region
    683694                address += region.size;
    684695           
     
    958969                        SLEV(shdr.sh_size, regionOffsets[j+1]-regionOffsets[j]);
    959970                    SLEV(shdr.sh_info, region2.section.info);
    960                     SLEV(shdr.sh_addralign, region2.align);
     971                    SLEV(shdr.sh_addralign, (region2.section.align==0) ?
     972                            region2.align : region2.section.align);
    961973                    if (region2.section.link == 0)
    962974                    {
  • CLRadeonExtender/trunk/amdbin/ROCmBinaries.cpp

    r2561 r2564  
    242242    }
    243243   
    244     ElfBinaryGen64 elfBinGen64({ 0U, 0U, 0x40, EV_CURRENT, ET_DYN,
    245         0xe0, EV_CURRENT, 0, 0, 0 });
     244    ElfBinaryGen64 elfBinGen64({ 0U, 0U, 0x40, 0, ET_DYN,
     245        0xe0, EV_CURRENT, UINT_MAX, 0, 0 }, true, true, true, PHREGION_FILESTART);
    246246    // add symbols
    247247    elfBinGen64.addDynSymbol(ElfSymbol64("_DYNAMIC", 5,
     
    273273    elfBinGen64.addProgramHeader({ PT_DYNAMIC, PF_R|PF_W, 5, 1, true, 0, 0, 0, 8 });
    274274    elfBinGen64.addProgramHeader({ PT_GNU_RELRO, PF_R, 5, 1, true, 0, 0, 0, 1 });
    275     elfBinGen64.addProgramHeader({ PT_GNU_STACK, PF_R|PF_W, 0, 0, true, 0, 0, 0 });
     275    elfBinGen64.addProgramHeader({ PT_GNU_STACK, PF_R|PF_W, PHREGION_FILESTART, 0,
     276                    true, 0, 0, 0 });
    276277   
    277278    // elf notes
     
    286287    /// region and sections
    287288    elfBinGen64.addRegion(ElfRegion64::programHeaderTable());
    288     elfBinGen64.addRegion(ElfRegion64::dynsymSection());
    289     elfBinGen64.addRegion(ElfRegion64::hashSection(1));
    290     elfBinGen64.addRegion(ElfRegion64::dynstrSection());
     289    elfBinGen64.addRegion(ElfRegion64(0, (const cxbyte*)nullptr, 8,
     290                ".dynsym", SHT_DYNSYM, SHF_ALLOC, 0, 1, Elf64Types::nobase));
     291    elfBinGen64.addRegion(ElfRegion64(0, (const cxbyte*)nullptr, 4,
     292                ".hash", SHT_HASH, SHF_ALLOC, 1, 0, Elf64Types::nobase));
     293    elfBinGen64.addRegion(ElfRegion64(0, (const cxbyte*)nullptr, 1, ".dynstr", SHT_STRTAB,
     294                SHF_ALLOC, 0, 0, Elf64Types::nobase));
    291295    elfBinGen64.addRegion(ElfRegion64(input->codeSize, (const cxbyte*)input->code,
    292               0x1000, ".text", SHT_PROGBITS, SHF_ALLOC|SHF_EXECINSTR, 0, 0, 0, 0,
    293               false, 256));
    294     elfBinGen64.addRegion(ElfRegion64::dynamicSection(3));
     296              0x1000, ".text", SHT_PROGBITS, SHF_ALLOC|SHF_EXECINSTR, 0, 0,
     297              Elf64Types::nobase, 0, false, 256));
     298    elfBinGen64.addRegion(ElfRegion64(0, (const cxbyte*)nullptr, 0x1000,
     299                ".dynamic", SHT_DYNAMIC, SHF_ALLOC|SHF_WRITE, 3, 0,
     300                Elf64Types::nobase, 0, false, 8));
    295301    elfBinGen64.addRegion(ElfRegion64::noteSection());
    296302    elfBinGen64.addRegion(ElfRegion64(commentSize, (const cxbyte*)comment, 1, ".comment",
    297               SHT_PROGBITS, SHF_MERGE|SHF_STRINGS));
    298     elfBinGen64.addRegion(ElfRegion64::symtabSection());
     303              SHT_PROGBITS, SHF_MERGE|SHF_STRINGS, 0, 0, 0, 1));
     304    elfBinGen64.addRegion(ElfRegion64(0, (const cxbyte*)nullptr, 8,
     305                ".symtab", SHT_SYMTAB, 0, 0, 1));
    299306    elfBinGen64.addRegion(ElfRegion64::shstrtabSection());
    300307    elfBinGen64.addRegion(ElfRegion64::strtabSection());
Note: See TracChangeset for help on using the changeset viewer.