Ejemplo n.º 1
0
        private void LoadImportReferencesFromRelaPlt()
        {
            var rela_plt = loader.GetSectionInfoByName(".rela.plt");
            var plt      = loader.GetSectionInfoByName(".plt");
            var relaRdr  = loader.CreateReader(rela_plt.FileOffset);

            for (ulong i = 0; i < rela_plt.EntryCount(); ++i)
            {
                // Read the .rela.plt entry
                ulong offset;
                if (!relaRdr.TryReadUInt64(out offset))
                {
                    return;
                }
                ulong info;
                if (!relaRdr.TryReadUInt64(out info))
                {
                    return;
                }
                long addend;
                if (!relaRdr.TryReadInt64(out addend))
                {
                    return;
                }

                ulong  sym    = info >> 32;
                string symStr = loader.GetSymbol64(rela_plt.LinkedSection, sym);

                var addr = plt.Address + (uint)(i + 1) * plt.EntrySize;
                importReferences.Add(
                    addr,
                    new NamedImportReference(addr, null, symStr));
            }
        }