Esempio n. 1
0
        private const ushort IMAGE_REL_ARM_SECREL   = 0x000F; // Offset within section

        public override RelocationResults Relocate(Program program, Address addrLoad)
        {
            relocator = CreateRelocator(machine, program);
            var     relocations = imgLoaded.Relocations;
            Section relocSection;

            if ((relocSection = sectionList.Find(section => this.rvaBaseRelocationTable >= section.VirtualAddress && this.rvaBaseRelocationTable < section.VirtualAddress + section.VirtualSize)) != null)
            {
                ApplyRelocations(relocSection.OffsetRawData, relocSection.SizeRawData, addrLoad, relocations);
            }
            var addrEp   = platform.AdjustProcedureAddress(addrLoad + rvaStartAddress);
            var entrySym = CreateMainEntryPoint(
                (this.fileFlags & ImageFileDll) != 0,
                addrEp,
                platform);

            ImageSymbols[entrySym.Address] = entrySym;
            var entryPoints = new List <ImageSymbol> {
                entrySym
            };

            ReadExceptionRecords(addrLoad, rvaExceptionTable, sizeExceptionTable, ImageSymbols);
            AddExportedEntryPoints(addrLoad, SegmentMap, entryPoints);
            ReadImportDescriptors(addrLoad);
            ReadDeferredLoadDescriptors(addrLoad);
            return(new RelocationResults(entryPoints, ImageSymbols));
        }
Esempio n. 2
0
        private const ushort IMAGE_REL_ARM_SECREL   = 0x000F; // Offset within section

        public override RelocationResults Relocate(Program program, Address addrLoad)
        {
            relocator = CreateRelocator(machine, program);
            var     relocations = imgLoaded.Relocations;
            Section relocSection;

            if (sectionMap.TryGetValue(".reloc", out relocSection))
            {
                ApplyRelocations(relocSection.OffsetRawData, relocSection.SizeRawData, (uint)addrLoad.ToLinear(), relocations);
            }
            var addrEp      = platform.AdjustProcedureAddress(addrLoad + rvaStartAddress);
            var entryPoints = new List <EntryPoint> {
                CreateMainEntryPoint(
                    (this.fileFlags & ImageFileDll) != 0,
                    addrEp,
                    platform)
            };
            var functions = ReadExceptionRecords(addrLoad, rvaExceptionTable, sizeExceptionTable);

            AddExportedEntryPoints(addrLoad, ImageMap, entryPoints);
            ReadImportDescriptors(addrLoad);
            ReadDeferredLoadDescriptors(addrLoad);
            return(new RelocationResults(entryPoints, functions));
        }