public void TestName()
        {
            var     stream  = new FileStream("Binaries/base32", FileMode.Open, FileAccess.Read);
            var     reader  = new EndianBinaryReader(stream, EndianBitConverter.NativeEndianness);
            ElfFile elfFile = ElfFile.ReadElfFile(reader);

            Assert.IsAssignableFrom <ElfSymbolTable>(elfFile.Sections[5]);

            ElfSymbolTable symbolTable = elfFile.Sections[5] as ElfSymbolTable;

            Assert.Equal(string.Empty, symbolTable[0].Name);
            Assert.Equal("__uflow", symbolTable[1].Name);
            Assert.Equal("getenv", symbolTable[2].Name);
            Assert.Equal("free", symbolTable[3].Name);
            Assert.Equal("abort", symbolTable[4].Name);
            Assert.Equal("__errno_location", symbolTable[5].Name);
            Assert.Equal("__ctype_get_mb_cur_max", symbolTable[14].Name);
            Assert.Equal("__stack_chk_fail", symbolTable[16].Name);
            Assert.Equal("strchr", symbolTable[19].Name);
            Assert.Equal("__assert_fail", symbolTable[23].Name);
            Assert.Equal("__gmon_start__", symbolTable[35].Name);
            Assert.Equal("stdout", symbolTable[60].Name);
            Assert.Equal("program_invocation_short_name", symbolTable[65].Name);
            Assert.Equal("optind", symbolTable[67].Name);
        }
Exemple #2
0
        public void TestFileExists()
        {
            var stream = new FileStream("Binaries/base32", FileMode.Open, FileAccess.Read);
            var reader = new EndianBinaryReader(stream, EndianBitConverter.NativeEndianness);

            _ = ElfFile.ReadElfFile(reader);
        }
        public void TestNameIndex()
        {
            var     stream  = new FileStream("Binaries/base32", FileMode.Open, FileAccess.Read);
            var     reader  = new EndianBinaryReader(stream, EndianBitConverter.NativeEndianness);
            ElfFile elfFile = ElfFile.ReadElfFile(reader);

            Assert.IsAssignableFrom <ElfSymbolTable>(elfFile.Sections[5]);

            ElfSymbolTable symbolTable = elfFile.Sections[5] as ElfSymbolTable;

            Assert.Equal(0x000U, symbolTable[0].NameIndex);
            Assert.Equal(0x15fU, symbolTable[1].NameIndex);
            Assert.Equal(0x181U, symbolTable[2].NameIndex);
            Assert.Equal(0x26dU, symbolTable[3].NameIndex);
            Assert.Equal(0x080U, symbolTable[4].NameIndex);
            Assert.Equal(0x10fU, symbolTable[5].NameIndex);
            Assert.Equal(0x0bfU, symbolTable[14].NameIndex);
            Assert.Equal(0x05eU, symbolTable[16].NameIndex);
            Assert.Equal(0x1cdU, symbolTable[19].NameIndex);
            Assert.Equal(0x0b1U, symbolTable[23].NameIndex);
            Assert.Equal(0x29aU, symbolTable[35].NameIndex);
            Assert.Equal(0x135U, symbolTable[60].NameIndex);
            Assert.Equal(0x1d4U, symbolTable[65].NameIndex);
            Assert.Equal(0x03fU, symbolTable[67].NameIndex);
        }
        public void TestSymbolValue()
        {
            var     stream  = new FileStream("Binaries/base32", FileMode.Open, FileAccess.Read);
            var     reader  = new EndianBinaryReader(stream, EndianBitConverter.NativeEndianness);
            ElfFile elfFile = ElfFile.ReadElfFile(reader);

            Assert.IsAssignableFrom <ElfSymbolTable>(elfFile.Sections[5]);

            ElfSymbolTable symbolTable = elfFile.Sections[5] as ElfSymbolTable;

            Assert.Equal(0x0000000000000000UL, symbolTable[0].Value);
            Assert.Equal(0x0000000000000000UL, symbolTable[1].Value);
            Assert.Equal(0x0000000000000000UL, symbolTable[2].Value);
            Assert.Equal(0x0000000000000000UL, symbolTable[3].Value);
            Assert.Equal(0x0000000000000000UL, symbolTable[4].Value);
            Assert.Equal(0x0000000000000000UL, symbolTable[5].Value);
            Assert.Equal(0x0000000000000000UL, symbolTable[14].Value);
            Assert.Equal(0x0000000000000000UL, symbolTable[16].Value);
            Assert.Equal(0x0000000000000000UL, symbolTable[19].Value);
            Assert.Equal(0x0000000000000000UL, symbolTable[23].Value);
            Assert.Equal(0x0000000000000000UL, symbolTable[35].Value);
            Assert.Equal(0x0000000000609288UL, symbolTable[60].Value);
            Assert.Equal(0x0000000000609280UL, symbolTable[65].Value);
            Assert.Equal(0x0000000000609298UL, symbolTable[67].Value);
        }
        public void TestSymbolValue()
        {
            var     stream  = new FileStream("Binaries/base32", FileMode.Open, FileAccess.Read);
            var     reader  = new EndianBinaryReader(stream, EndianBitConverter.NativeEndianness);
            ElfFile elfFile = ElfFile.ReadElfFile(reader);

            Assert.IsAssignableFrom <ElfRelocationSection>(elfFile.Sections[9]);

            ElfRelocationSection relocationSection9 = elfFile.Sections[9] as ElfRelocationSection;

            Assert.Equal(0x0000000000000000UL, relocationSection9[0].SymbolValue);
            Assert.Equal(0x0000000000609280UL, relocationSection9[1].SymbolValue);
            Assert.Equal(0x0000000000609288UL, relocationSection9[2].SymbolValue);
            Assert.Equal(0x0000000000609290UL, relocationSection9[3].SymbolValue);
            Assert.Equal(0x0000000000609298UL, relocationSection9[4].SymbolValue);
            Assert.Equal(0x00000000006092a0UL, relocationSection9[5].SymbolValue);
            Assert.Equal(0x00000000006092a8UL, relocationSection9[6].SymbolValue);
            Assert.Equal(0x00000000006092c0UL, relocationSection9[7].SymbolValue);

            Assert.IsAssignableFrom <ElfRelocationSection>(elfFile.Sections[10]);

            ElfRelocationSection relocationSection10 = elfFile.Sections[10] as ElfRelocationSection;

            Assert.Equal(0x0UL, relocationSection10[0].SymbolValue);
            Assert.Equal(0x0UL, relocationSection10[1].SymbolValue);
            Assert.Equal(0x0UL, relocationSection10[2].SymbolValue);
            Assert.Equal(0x0UL, relocationSection10[3].SymbolValue);
            Assert.Equal(0x0UL, relocationSection10[4].SymbolValue);
            Assert.Equal(0x0UL, relocationSection10[5].SymbolValue);
            Assert.Equal(0x0UL, relocationSection10[14].SymbolValue);
            Assert.Equal(0x0UL, relocationSection10[16].SymbolValue);
            Assert.Equal(0x0UL, relocationSection10[19].SymbolValue);
            Assert.Equal(0x0UL, relocationSection10[23].SymbolValue);
        }
        public void TestBinding()
        {
            var     stream  = new FileStream("Binaries/base32", FileMode.Open, FileAccess.Read);
            var     reader  = new EndianBinaryReader(stream, EndianBitConverter.NativeEndianness);
            ElfFile elfFile = ElfFile.ReadElfFile(reader);

            Assert.IsAssignableFrom <ElfSymbolTable>(elfFile.Sections[5]);

            ElfSymbolTable symbolTable = elfFile.Sections[5] as ElfSymbolTable;

            Assert.Equal(ElfSymbolBinding.Local, symbolTable[0].Binding);
            Assert.Equal(ElfSymbolBinding.Global, symbolTable[1].Binding);
            Assert.Equal(ElfSymbolBinding.Global, symbolTable[2].Binding);
            Assert.Equal(ElfSymbolBinding.Global, symbolTable[3].Binding);
            Assert.Equal(ElfSymbolBinding.Global, symbolTable[4].Binding);
            Assert.Equal(ElfSymbolBinding.Global, symbolTable[5].Binding);
            Assert.Equal(ElfSymbolBinding.Global, symbolTable[14].Binding);
            Assert.Equal(ElfSymbolBinding.Global, symbolTable[16].Binding);
            Assert.Equal(ElfSymbolBinding.Global, symbolTable[19].Binding);
            Assert.Equal(ElfSymbolBinding.Global, symbolTable[23].Binding);
            Assert.Equal(ElfSymbolBinding.Weak, symbolTable[35].Binding);
            Assert.Equal(ElfSymbolBinding.Global, symbolTable[60].Binding);
            Assert.Equal(ElfSymbolBinding.Weak, symbolTable[65].Binding);
            Assert.Equal(ElfSymbolBinding.Global, symbolTable[67].Binding);
        }
        public void TestMachineI386()
        {
            var     stream  = new FileStream("Binaries/helloworld32le", FileMode.Open, FileAccess.Read);
            var     reader  = new EndianBinaryReader(stream, EndianBitConverter.NativeEndianness);
            ElfFile elfFile = ElfFile.ReadElfFile(reader);

            Assert.Equal(ElfMachine.I386, elfFile.Header.Machine);
        }
        public void TestMachineX8664()
        {
            var     stream  = new FileStream("Binaries/base32", FileMode.Open, FileAccess.Read);
            var     reader  = new EndianBinaryReader(stream, EndianBitConverter.NativeEndianness);
            ElfFile elfFile = ElfFile.ReadElfFile(reader);

            Assert.Equal(ElfMachine.X8664, elfFile.Header.Machine);
        }
        public void TestType()
        {
            var     stream  = new FileStream("Binaries/base32", FileMode.Open, FileAccess.Read);
            var     reader  = new EndianBinaryReader(stream, EndianBitConverter.NativeEndianness);
            ElfFile elfFile = ElfFile.ReadElfFile(reader);

            Assert.Equal(ElfType.Executable, elfFile.Header.Type);
        }
        public void TestOSABIVersion()
        {
            var     stream  = new FileStream("Binaries/base32", FileMode.Open, FileAccess.Read);
            var     reader  = new EndianBinaryReader(stream, EndianBitConverter.NativeEndianness);
            ElfFile elfFile = ElfFile.ReadElfFile(reader);

            Assert.Equal(0, elfFile.Header.OSABIVersion);
        }
        public void TestEndiannessBE()
        {
            var     stream  = new FileStream("Binaries/helloworld64be", FileMode.Open, FileAccess.Read);
            var     reader  = new EndianBinaryReader(stream, EndianBitConverter.NativeEndianness);
            ElfFile elfFile = ElfFile.ReadElfFile(reader);

            Assert.Equal(ElfData.Msb, elfFile.Header.Data);
        }
        public void TestClass64()
        {
            var     stream  = new FileStream("Binaries/helloworld64le", FileMode.Open, FileAccess.Read);
            var     reader  = new EndianBinaryReader(stream, EndianBitConverter.NativeEndianness);
            ElfFile elfFile = ElfFile.ReadElfFile(reader);

            Assert.Equal(ElfClass.Elf64, elfFile.Header.Class);
        }
        public void TestEntryOffset()
        {
            var     stream  = new FileStream("Binaries/base32", FileMode.Open, FileAccess.Read);
            var     reader  = new EndianBinaryReader(stream, EndianBitConverter.NativeEndianness);
            ElfFile elfFile = ElfFile.ReadElfFile(reader);

            Assert.Equal(0x4019e0UL, elfFile.Header.EntryOffset);
        }
Exemple #14
0
        public void TestCount()
        {
            var     stream  = new FileStream("Binaries/base32", FileMode.Open, FileAccess.Read);
            var     reader  = new EndianBinaryReader(stream, EndianBitConverter.NativeEndianness);
            ElfFile elfFile = ElfFile.ReadElfFile(reader);

            Assert.Equal(29, elfFile.Sections.Count);
        }
        public void TestProgramHeaderSize()
        {
            var     stream  = new FileStream("Binaries/base32", FileMode.Open, FileAccess.Read);
            var     reader  = new EndianBinaryReader(stream, EndianBitConverter.NativeEndianness);
            ElfFile elfFile = ElfFile.ReadElfFile(reader);

            Assert.Equal(56, elfFile.Header.ProgramHeaderSize);
        }
        public void TestSectionToSegmentMapping()
        {
            var     stream  = new FileStream("Binaries/base32", FileMode.Open, FileAccess.Read);
            var     reader  = new EndianBinaryReader(stream, EndianBitConverter.NativeEndianness);
            ElfFile elfFile = ElfFile.ReadElfFile(reader);

            Assert.Equal(0, elfFile.Segments[0].Sections.Count);
            Assert.Equal(1, elfFile.Segments[1].Sections.Count);
            Assert.Equal(elfFile.Sections[1], elfFile.Segments[1].Sections[0]);

            Assert.Equal(18, elfFile.Segments[2].Sections.Count);
            Assert.Equal(elfFile.Sections[1], elfFile.Segments[2].Sections[0]);
            Assert.Equal(elfFile.Sections[2], elfFile.Segments[2].Sections[1]);
            Assert.Equal(elfFile.Sections[3], elfFile.Segments[2].Sections[2]);
            Assert.Equal(elfFile.Sections[4], elfFile.Segments[2].Sections[3]);
            Assert.Equal(elfFile.Sections[5], elfFile.Segments[2].Sections[4]);
            Assert.Equal(elfFile.Sections[6], elfFile.Segments[2].Sections[5]);
            Assert.Equal(elfFile.Sections[7], elfFile.Segments[2].Sections[6]);
            Assert.Equal(elfFile.Sections[8], elfFile.Segments[2].Sections[7]);
            Assert.Equal(elfFile.Sections[9], elfFile.Segments[2].Sections[8]);
            Assert.Equal(elfFile.Sections[10], elfFile.Segments[2].Sections[9]);
            Assert.Equal(elfFile.Sections[11], elfFile.Segments[2].Sections[10]);
            Assert.Equal(elfFile.Sections[12], elfFile.Segments[2].Sections[11]);
            Assert.Equal(elfFile.Sections[13], elfFile.Segments[2].Sections[12]);
            Assert.Equal(elfFile.Sections[14], elfFile.Segments[2].Sections[13]);
            Assert.Equal(elfFile.Sections[15], elfFile.Segments[2].Sections[14]);
            Assert.Equal(elfFile.Sections[16], elfFile.Segments[2].Sections[15]);
            Assert.Equal(elfFile.Sections[17], elfFile.Segments[2].Sections[16]);
            Assert.Equal(elfFile.Sections[18], elfFile.Segments[2].Sections[17]);

            Assert.Equal(8, elfFile.Segments[3].Sections.Count);
            Assert.Equal(elfFile.Sections[19], elfFile.Segments[3].Sections[0]);
            Assert.Equal(elfFile.Sections[20], elfFile.Segments[3].Sections[1]);
            Assert.Equal(elfFile.Sections[21], elfFile.Segments[3].Sections[2]);
            Assert.Equal(elfFile.Sections[22], elfFile.Segments[3].Sections[3]);
            Assert.Equal(elfFile.Sections[23], elfFile.Segments[3].Sections[4]);
            Assert.Equal(elfFile.Sections[24], elfFile.Segments[3].Sections[5]);
            Assert.Equal(elfFile.Sections[25], elfFile.Segments[3].Sections[6]);
            Assert.Equal(elfFile.Sections[26], elfFile.Segments[3].Sections[7]);

            Assert.Equal(1, elfFile.Segments[4].Sections.Count);
            Assert.Equal(elfFile.Sections[22], elfFile.Segments[4].Sections[0]);

            Assert.Equal(2, elfFile.Segments[5].Sections.Count);
            Assert.Equal(elfFile.Sections[2], elfFile.Segments[5].Sections[0]);
            Assert.Equal(elfFile.Sections[3], elfFile.Segments[5].Sections[1]);

            Assert.Equal(1, elfFile.Segments[6].Sections.Count);
            Assert.Equal(elfFile.Sections[17], elfFile.Segments[6].Sections[0]);

            Assert.Equal(0, elfFile.Segments[7].Sections.Count);
            Assert.Equal(5, elfFile.Segments[8].Sections.Count);
            Assert.Equal(elfFile.Sections[19], elfFile.Segments[8].Sections[0]);
            Assert.Equal(elfFile.Sections[20], elfFile.Segments[8].Sections[1]);
            Assert.Equal(elfFile.Sections[21], elfFile.Segments[8].Sections[2]);
            Assert.Equal(elfFile.Sections[22], elfFile.Segments[8].Sections[3]);
            Assert.Equal(elfFile.Sections[23], elfFile.Segments[8].Sections[4]);
        }
Exemple #17
0
        public void TestInvalidEndianness()
        {
            var stream = new FileStream("Binaries/invalidendianness", FileMode.Open, FileAccess.Read);
            var reader = new EndianBinaryReader(stream, EndianBitConverter.NativeEndianness);

            void Action() => ElfFile.ReadElfFile(reader);

            Assert.Throws <FileFormatException>(Action);
        }
        public void TestCount()
        {
            var     stream  = new FileStream("Binaries/base32", FileMode.Open, FileAccess.Read);
            var     reader  = new EndianBinaryReader(stream, EndianBitConverter.NativeEndianness);
            ElfFile elfFile = ElfFile.ReadElfFile(reader);

            Assert.IsAssignableFrom <ElfDynamicSection>(elfFile.Sections[22]);

            ElfDynamicSection dynamicSection = elfFile.Sections[22] as ElfDynamicSection;

            Assert.Equal(24, dynamicSection.Count);
        }
        public void TestCount()
        {
            var     stream  = new FileStream("Binaries/base32", FileMode.Open, FileAccess.Read);
            var     reader  = new EndianBinaryReader(stream, EndianBitConverter.NativeEndianness);
            ElfFile elfFile = ElfFile.ReadElfFile(reader);

            Assert.IsAssignableFrom <ElfSymbolTable>(elfFile.Sections[5]);

            ElfSymbolTable symbolTable = elfFile.Sections[5] as ElfSymbolTable;

            Assert.Equal(69, symbolTable.Count);
        }
Exemple #20
0
        public void TestName()
        {
            var     stream  = new FileStream("Binaries/base32", FileMode.Open, FileAccess.Read);
            var     reader  = new EndianBinaryReader(stream, EndianBitConverter.NativeEndianness);
            ElfFile elfFile = ElfFile.ReadElfFile(reader);

            Assert.Equal(string.Empty, elfFile.Sections[0].Name);
            Assert.Equal(".dynsym", elfFile.Sections[5].Name);
            Assert.Equal(".plt.got", elfFile.Sections[13].Name);
            Assert.Equal(".dynamic", elfFile.Sections[22].Name);
            Assert.Equal(".got.plt", elfFile.Sections[24].Name);
        }
        public void TestAlignment()
        {
            var     stream  = new FileStream("Binaries/base32", FileMode.Open, FileAccess.Read);
            var     reader  = new EndianBinaryReader(stream, EndianBitConverter.NativeEndianness);
            ElfFile elfFile = ElfFile.ReadElfFile(reader);

            Assert.Equal(0x8UL, elfFile.Segments[0].Alignment);
            Assert.Equal(0x1UL, elfFile.Segments[1].Alignment);
            Assert.Equal(0x200000UL, elfFile.Segments[2].Alignment);
            Assert.Equal(0x200000UL, elfFile.Segments[3].Alignment);
            Assert.Equal(0x8UL, elfFile.Segments[4].Alignment);
            Assert.Equal(0x4UL, elfFile.Segments[5].Alignment);
        }
        public void TestMemorySize()
        {
            var     stream  = new FileStream("Binaries/base32", FileMode.Open, FileAccess.Read);
            var     reader  = new EndianBinaryReader(stream, EndianBitConverter.NativeEndianness);
            ElfFile elfFile = ElfFile.ReadElfFile(reader);

            Assert.Equal(0x00000000000001F8UL, elfFile.Segments[0].MemorySize);
            Assert.Equal(0x000000000000001CUL, elfFile.Segments[1].MemorySize);
            Assert.Equal(0x0000000000008164UL, elfFile.Segments[2].MemorySize);
            Assert.Equal(0x0000000000000630UL, elfFile.Segments[3].MemorySize);
            Assert.Equal(0x00000000000001D0UL, elfFile.Segments[4].MemorySize);
            Assert.Equal(0x0000000000000044UL, elfFile.Segments[5].MemorySize);
        }
        public void TestPhysicalAddress()
        {
            var     stream  = new FileStream("Binaries/base32", FileMode.Open, FileAccess.Read);
            var     reader  = new EndianBinaryReader(stream, EndianBitConverter.NativeEndianness);
            ElfFile elfFile = ElfFile.ReadElfFile(reader);

            Assert.Equal(0x0000000000400040UL, elfFile.Segments[0].VirtualAddress);
            Assert.Equal(0x0000000000400238UL, elfFile.Segments[1].VirtualAddress);
            Assert.Equal(0x0000000000400000UL, elfFile.Segments[2].VirtualAddress);
            Assert.Equal(0x0000000000608e10UL, elfFile.Segments[3].VirtualAddress);
            Assert.Equal(0x0000000000608e28UL, elfFile.Segments[4].VirtualAddress);
            Assert.Equal(0x0000000000400254UL, elfFile.Segments[5].VirtualAddress);
        }
        public void TestType()
        {
            var     stream  = new FileStream("Binaries/base32", FileMode.Open, FileAccess.Read);
            var     reader  = new EndianBinaryReader(stream, EndianBitConverter.NativeEndianness);
            ElfFile elfFile = ElfFile.ReadElfFile(reader);

            Assert.Equal(ElfSegmentType.PHdr, elfFile.Segments[0].Type);
            Assert.Equal(ElfSegmentType.Interp, elfFile.Segments[1].Type);
            Assert.Equal(ElfSegmentType.Load, elfFile.Segments[2].Type);
            Assert.Equal(ElfSegmentType.Load, elfFile.Segments[3].Type);
            Assert.Equal(ElfSegmentType.Dynamic, elfFile.Segments[4].Type);
            Assert.Equal(ElfSegmentType.Note, elfFile.Segments[5].Type);
        }
        public void TestName()
        {
            var     stream  = new FileStream("Binaries/base32", FileMode.Open, FileAccess.Read);
            var     reader  = new EndianBinaryReader(stream, EndianBitConverter.NativeEndianness);
            ElfFile elfFile = ElfFile.ReadElfFile(reader);

            Assert.IsAssignableFrom <ElfDynamicSection>(elfFile.Sections[22]);

            ElfDynamicSection dynamicSection = elfFile.Sections[22] as ElfDynamicSection;

            Assert.Equal("libc.so.6", dynamicSection[0].Name);
            Assert.Equal(string.Empty, dynamicSection[1].Name);
        }
        public void TestFlags()
        {
            var     stream  = new FileStream("Binaries/base32", FileMode.Open, FileAccess.Read);
            var     reader  = new EndianBinaryReader(stream, EndianBitConverter.NativeEndianness);
            ElfFile elfFile = ElfFile.ReadElfFile(reader);

            Assert.Equal(ElfSegmentFlags.Read | ElfSegmentFlags.Exec, elfFile.Segments[0].Flags);
            Assert.Equal(ElfSegmentFlags.Read, elfFile.Segments[1].Flags);
            Assert.Equal(ElfSegmentFlags.Read | ElfSegmentFlags.Exec, elfFile.Segments[2].Flags);
            Assert.Equal(ElfSegmentFlags.Read | ElfSegmentFlags.Write, elfFile.Segments[3].Flags);
            Assert.Equal(ElfSegmentFlags.Read | ElfSegmentFlags.Write, elfFile.Segments[4].Flags);
            Assert.Equal(ElfSegmentFlags.Read, elfFile.Segments[5].Flags);
        }
        public void TestNameWithoutPresenceOfDynSym()
        {
            var     stream  = new FileStream("Binaries/blinky", FileMode.Open, FileAccess.Read);
            var     reader  = new EndianBinaryReader(stream, EndianBitConverter.NativeEndianness);
            ElfFile elfFile = ElfFile.ReadElfFile(reader);

            Assert.IsAssignableFrom <ElfSymbolTable>(elfFile.Sections[39]);

            ElfSymbolTable symbolTable = elfFile.Sections[39] as ElfSymbolTable;

            Assert.Equal("numb.8344", symbolTable[44].Name);
            Assert.Equal("nrf_gpio_pin_port_decode", symbolTable[82].Name);
            Assert.Equal("HardFault_Handler", symbolTable[124].Name);
            Assert.Equal("__bss_load_end__", symbolTable[266].Name);
        }
Exemple #28
0
        public void TestOffset()
        {
            var     stream  = new FileStream("Binaries/base32", FileMode.Open, FileAccess.Read);
            var     reader  = new EndianBinaryReader(stream, EndianBitConverter.NativeEndianness);
            ElfFile elfFile = ElfFile.ReadElfFile(reader);

            Assert.Equal(0x0000000000000000UL, elfFile.Sections[0].Offset);
            Assert.Equal(0x0000000000000238UL, elfFile.Sections[1].Offset);
            Assert.Equal(0x0000000000000254UL, elfFile.Sections[2].Offset);
            Assert.Equal(0x00000000000002e0UL, elfFile.Sections[5].Offset);
            Assert.Equal(0x0000000000000958UL, elfFile.Sections[6].Offset);
            Assert.Equal(0x0000000000000d28UL, elfFile.Sections[9].Offset);
            Assert.Equal(0x0000000000008e10UL, elfFile.Sections[19].Offset);
            Assert.Equal(0x0000000000008e18UL, elfFile.Sections[20].Offset);
            Assert.Equal(0x0000000000008e28UL, elfFile.Sections[22].Offset);
            Assert.Equal(0x00000000000092a8UL, elfFile.Sections[28].Offset);
        }
Exemple #29
0
        public void TestType()
        {
            var     stream  = new FileStream("Binaries/base32", FileMode.Open, FileAccess.Read);
            var     reader  = new EndianBinaryReader(stream, EndianBitConverter.NativeEndianness);
            ElfFile elfFile = ElfFile.ReadElfFile(reader);

            Assert.Equal(ElfSectionType.Null, elfFile.Sections[0].Type);
            Assert.Equal(ElfSectionType.ProgBits, elfFile.Sections[1].Type);
            Assert.Equal(ElfSectionType.Note, elfFile.Sections[2].Type);
            Assert.Equal(ElfSectionType.DynSym, elfFile.Sections[5].Type);
            Assert.Equal(ElfSectionType.StrTab, elfFile.Sections[6].Type);
            Assert.Equal(ElfSectionType.RelA, elfFile.Sections[9].Type);
            Assert.Equal(ElfSectionType.InitArray, elfFile.Sections[19].Type);
            Assert.Equal(ElfSectionType.FiniArray, elfFile.Sections[20].Type);
            Assert.Equal(ElfSectionType.Dynamic, elfFile.Sections[22].Type);
            Assert.Equal(ElfSectionType.StrTab, elfFile.Sections[28].Type);
        }
Exemple #30
0
        public void TestSize()
        {
            var     stream  = new FileStream("Binaries/base32", FileMode.Open, FileAccess.Read);
            var     reader  = new EndianBinaryReader(stream, EndianBitConverter.NativeEndianness);
            ElfFile elfFile = ElfFile.ReadElfFile(reader);

            Assert.Equal(0x0000000000000000UL, elfFile.Sections[0].Size);
            Assert.Equal(0x000000000000001cUL, elfFile.Sections[1].Size);
            Assert.Equal(0x0000000000000020UL, elfFile.Sections[2].Size);
            Assert.Equal(0x0000000000000678UL, elfFile.Sections[5].Size);
            Assert.Equal(0x00000000000002e0UL, elfFile.Sections[6].Size);
            Assert.Equal(0x00000000000000c0UL, elfFile.Sections[9].Size);
            Assert.Equal(0x0000000000000008UL, elfFile.Sections[19].Size);
            Assert.Equal(0x0000000000000008UL, elfFile.Sections[20].Size);
            Assert.Equal(0x00000000000001d0UL, elfFile.Sections[22].Size);
            Assert.Equal(0x0000000000000102UL, elfFile.Sections[28].Size);
        }