Example #1
0
        public void SimpleCodeSectionAndSymbolSection()
        {
            var elf = new ElfObjectFile();

            var codeStream = new MemoryStream();

            codeStream.Write(Encoding.UTF8.GetBytes("This is a text"));
            codeStream.Position = 0;

            var codeSection = new ElfCustomSection(codeStream).ConfigureAs(ElfSectionSpecialType.Text);

            elf.AddSection(codeSection);

            var stringSection = new ElfStringTable();

            elf.AddSection(stringSection);

            var symbolSection = new ElfSymbolTable()
            {
                Link = stringSection,

                Entries =
                {
                    new ElfSymbol()
                    {
                        Name       = "local_symbol",
                        Bind       = ElfSymbolBind.Local,
                        Section    = codeSection,
                        Size       = 16,
                        Type       = ElfSymbolType.Function,
                        Visibility = ElfSymbolVisibility.Protected,
                        Value      = 0x7896
                    },
                    new ElfSymbol()
                    {
                        Name    = "GlobalSymbol",
                        Bind    = ElfSymbolBind.Global,
                        Section = codeSection,
                        Size    = 4,
                        Type    = ElfSymbolType.Function,
                        Value   = 0x12345
                    }
                }
            };

            elf.AddSection(symbolSection);
            elf.AddSection(new ElfSectionHeaderStringTable());

            AssertReadElf(elf, "test2.elf");
        }
Example #2
0
        public void SimpleCodeSection()
        {
            var elf = new ElfObjectFile();

            var codeStream = new MemoryStream();

            codeStream.Write(Encoding.UTF8.GetBytes("This is a text"));
            codeStream.Position = 0;

            var codeSection = new ElfCustomSection(codeStream).ConfigureAs(ElfSectionSpecialType.Text);

            elf.AddSection(codeSection);
            elf.AddSection(new ElfSectionHeaderStringTable());

            AssertReadElf(elf, "test.elf");
        }