Changeset 2555 in CLRX


Ignore:
Timestamp:
Nov 10, 2016, 8:43:26 PM (3 years ago)
Author:
matszpk
Message:

CLRadeonExtender: ElfBinGen?: Move resolving of section addresses to separate routine.
Use this routine to calculate addresses for dynamic entries.

File:
1 edited

Legend:

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

    r2553 r2555  
    459459static const size_t dynTableSize = DT_NUM;
    460460
     461
     462template<typename Types>
     463static inline typename Types::Word resolveSectionAddress(
     464        const ElfHeaderTemplate<Types>& header, const ElfRegionTemplate<Types>& region2,
     465        typename Types::Word regionAddr)
     466{   /* addrBase is base address of first section. if not defined
     467     * use address base as virtual address base from elf header */
     468    if (region2.section.addrBase==Types::nobase)
     469        return regionAddr;
     470    else if (region2.section.addrBase != 0)
     471        return region2.section.addrBase+regionAddr;
     472    else if (header.vaddrBase != 0)
     473        return header.vaddrBase+regionAddr;
     474    else
     475        return 0;
     476}
     477
    461478template<typename Types>
    462479void ElfBinaryGenTemplate<Types>::computeSize()
     
    577594                {
    578595                    case SHT_DYNSYM:
    579                         dynValTable[DT_SYMTAB] = regionAddresses[i];
     596                        dynValTable[DT_SYMTAB] = resolveSectionAddress(header, region,
     597                                   regionAddresses[i]);
    580598                        dynValTable[DT_SYMENT] = sizeof(typename Types::Sym);
    581599                        break;
    582600                    case SHT_STRTAB:
    583601                        if (::strcmp(region.section.name, ".dynstr")==0)
    584                             dynValTable[DT_STRTAB] = regionAddresses[i];
     602                            dynValTable[DT_STRTAB] = resolveSectionAddress(header, region,
     603                                   regionAddresses[i]);
    585604                        break;
    586605                    case SHT_HASH:
    587                         dynValTable[DT_HASH] = regionAddresses[i];
     606                        dynValTable[DT_HASH] = resolveSectionAddress(header, region,
     607                                 regionAddresses[i]);
    588608                        break;
    589609                }
     
    907927                    SLEV(shdr.sh_offset, (!region2.section.zeroOffset) ?
    908928                                regionOffsets[j] : 0);
    909                     /* addrBase is base address of first section. if not defined
    910                      * use address base as virtual address base from elf header */
    911                     if (region2.section.addrBase==Types::nobase)
    912                         SLEV(shdr.sh_addr, regionAddresses[j]);
    913                     else if (region2.section.addrBase != 0)
    914                         SLEV(shdr.sh_addr, region2.section.addrBase+regionAddresses[j]);
    915                     else if (header.vaddrBase != 0)
    916                         SLEV(shdr.sh_addr, header.vaddrBase+regionAddresses[j]);
    917                     else
    918                         SLEV(shdr.sh_addr, 0);
     929                    SLEV(shdr.sh_addr, resolveSectionAddress(header, region2,
     930                                     regionAddresses[j]));
    919931                   
    920932                    if (region2.align != 0 || j+1 >= regions.size() ||
Note: See TracChangeset for help on using the changeset viewer.