示例#1
0
        public void Close()
        {
            dynsym.WriteHash();
            dynstr.WriteTo(dynstrRegion);
            mainRegion.WriteNumber(23); // dt_jmprel
            mainRegion.WritePlaceholder(relapltRegion.BaseLocation);
            mainRegion.WriteNumber(2);  // dt_jmprelsz
            mainRegion.WriteNumber(relapltRegion.Length);
            mainRegion.WriteNumber(20); // dt_pltrel
            mainRegion.WriteNumber(7);  // use rela

            mainRegion.WriteNumber(10); // dt_strsz
            mainRegion.WriteNumber(dynstrRegion.Length);
            mainRegion.WriteNumber(0);  //DT_NULL
            mainRegion.WriteNumber(0);
            dynamicTokenSize.SetValue(mainRegion.Length);
        }
示例#2
0
        private void WriteSectionHeaders()
        {
            output.Align(16, 0);
            sectionHeaderTable_fo.SetValue(output.Length);
            WriteSectionHeader("", 0, 0, 0, 0, 0, 0, 0, 0, 0);
            WriteSectionHeader(strtabSection.Name, 3, 2, strtabSection.MemoryAddress, strtabSection.FileOffset, strtabSection.Length, 0, 0, strtabSection.RegionAlignment, 0);
            WriteSectionHeader(codeSection.Name, 1, 6, codeSection.MemoryAddress, codeSection.FileOffset, codeSection.Length, 0, 0, codeSection.RegionAlignment, 0);
            WriteSectionHeader(dataSection.Name, 1, 3, dataSection.MemoryAddress, dataSection.FileOffset, dataSection.Length, 0, 0, dataSection.RegionAlignment, 0);
            WriteSectionHeader(interpSection.Name, 1, 2, interpSection.MemoryAddress, interpSection.FileOffset, interpSection.Length, 0, 0, interpSection.RegionAlignment, 0);
            WriteSectionHeader(rodataSection.Name, 1, 2, rodataSection.MemoryAddress, rodataSection.FileOffset, rodataSection.Length, 0, 0, rodataSection.RegionAlignment, 0);
            WriteSectionHeader(symtabSection.Name, 2, 2, symtabSection.MemoryAddress, symtabSection.FileOffset, symtabSection.Length, 1, 1, symtabSection.RegionAlignment, is64bit ? 24 : 16);

            WriteSectionHeader(hashSection.Name, 5, 2, hashSection.MemoryAddress, hashSection.FileOffset, hashSection.Length, 8, 0, hashSection.RegionAlignment, 4);
            WriteSectionHeader(dynsymSection.Name, 11, 2, dynsymSection.MemoryAddress, dynsymSection.FileOffset, dynsymSection.Length, 9, 1, dynsymSection.RegionAlignment, is64bit ? 24 : 16);
            WriteSectionHeader(dynstrSection.Name, 3, 2, dynstrSection.MemoryAddress, dynstrSection.FileOffset, dynstrSection.Length, 0, 0, dynstrSection.RegionAlignment, 0);
            WriteSectionHeader(dynamicSection.Name, 6, 3, dynamicSection.MemoryAddress, dynamicSection.FileOffset, dynamicSection.Length, 9, 0, dynamicSection.RegionAlignment, is64bit ? 16 : 8);
            WriteSectionHeader(pltSection.Name, 1, 6, pltSection.MemoryAddress, pltSection.FileOffset, pltSection.Length, 0, 0, pltSection.RegionAlignment, is64bit ? 16 : 8);
            WriteSectionHeader(gotpltSection.Name, 1, 3, gotpltSection.MemoryAddress, gotpltSection.FileOffset, gotpltSection.Length, 0, 0, gotpltSection.RegionAlignment, is64bit ? 8 : 4);
            WriteSectionHeader(relapltSection.Name, 4, 2, relapltSection.MemoryAddress, relapltSection.FileOffset, relapltSection.Length, 8, 12, relapltSection.RegionAlignment, is64bit ? 24 : 12);
            WriteSectionHeader(debugInfoSection.Name, 1, 0, 0, debugInfoSection.FileOffset, debugInfoSection.Length, 0, 0, debugInfoSection.RegionAlignment, 0);
            WriteSectionHeader(debugAbbrevSection.Name, 1, 0, 0, debugAbbrevSection.FileOffset, debugAbbrevSection.Length, 0, 0, debugAbbrevSection.RegionAlignment, 0);
            WriteSectionHeader(debugLineSection.Name, 1, 0, 0, debugLineSection.FileOffset, debugLineSection.Length, 0, 0, debugLineSection.RegionAlignment, 0);
        }
示例#3
0
        private void WriteProgramHeaders()
        {
            output.Align(16, 0);
            programHeaderTable_fo.SetValue(output.Length);

            long phdrfo = output.Length;

            //phdr
            WriteProgramHeader(6, 4, phdrfo, phdrma, phdrsz, 16);
            //interp
            WriteProgramHeader(3, 4, interpSection.FileOffset, interpSection.MemoryAddress, interpSection.Length, interpSection.RegionAlignment);

            //readonly
            //            WriteProgramHeader(1, 4, interpSection.FileOffset, interpSection.MemoryAddress, readonlyLength, MaxPageSize);
            //fileimage (readonly + executable)
            WriteProgramHeader(1, 5, 0, imageBase, fileImageLength, MaxPageSize);
            //            //executable
            //            WriteProgramHeader(1, 5, codeSection.FileOffset, codeSection.MemoryAddress, execLength, MaxPageSize);
            //readwrite
            WriteProgramHeader(1, 6, dataSection.FileOffset, dataSection.MemoryAddress, readWriteLength, MaxPageSize);

            //dynamic
            WriteProgramHeader(2, 6, dynamicSection.FileOffset, dynamicSection.MemoryAddress, dynamicSection.Length, dynamicSection.RegionAlignment);
        }