Пример #1
0
        //00 00 00 01 00 00 00 01   needed      ........
        //00 00 00 01 00 00 02 DE   "
        //00 00 00 01 00 00 02 EE   "
        //00 00 00 01 00 00 03 06   "
        //00 00 00 01 00 00 03 10   "
        //00 00 00 01 00 00 03 6B   "
        //00 00 00 01 00 00 03 91   "
        //00 00 00 0C 10 00 29 CC   Init
        //00 00 00 0D 10 03 81 B0   Fini
        //00 00 00 04 10 00 01 A8   Hash
        //6F FF FE F5 10 00 07 E0   ?
        //00 00 00 05 10 00 14 AC   strtab
        //00 00 00 06 10 00 08 3C   symtab
        //00 00 00 0A 00 00 09 90   strsz
        //00 00 00 0B 00 00 00 10   syment
        //00 00 00 15 00 00 00 00   debug
        //00 00 00 03 10 06 60 00   pltgot   -> first byte in linkage table
        //00 00 00 02 00 00 08 D0   pltretsz
        //00 00 00 14 00 00 00 07   pltrel
        //00 00 00 17 10 00 20 FC   jmprel
        //70 00 00 00 10 06 5F F4   loproc
        //00 00 00 07 10 00 20 CC   rela
        //00 00 00 08 00 00 09 00   relasz
        //00 00 00 09 00 00 00 0C   relaent
        //6F FF FF FE 10 00 1F CC  ?
        //6F FF FF FF 00 00 00 04   ?
        //6F FF FF F0 10 00 1E 3C  ?


        protected virtual void RenderEntry(string name, DtFormat format, Elf64_Dyn entry, Formatter formatter)
        {
            formatter.Write("{0,-15} ", name);
            switch (format)
            {
            default:
            case DtFormat.Hexadecimal:
                formatter.Write("{0:X16}", entry.d_val);
                break;

            case DtFormat.Decimal:
                formatter.Write("{0,16}", entry.d_val);
                break;

            case DtFormat.Address:
                formatter.WriteHyperlink(string.Format("{0:X16}", entry.d_ptr), Address.Ptr64(entry.d_ptr));
                break;

            case DtFormat.String:
                formatter.Write(loader.ReadAsciiString(strtabSection.FileOffset + entry.d_ptr));
                break;
            }
        }
Пример #2
0
        public const int DT_FINI_ARRAYSZ = 28;      // d_val    O   O

        public override void Render(ImageSegment segment, Program program, Formatter formatter)
        {
            // Get the entry that has the segment# for the string table.
            var dynStrtab = loader.GetDynEntries64(shdr.FileOffset).Where(d => d.d_tag == DT_STRTAB).FirstOrDefault();

            if (dynStrtab == null)
            {
                return;
            }
            var strtabSection = loader.GetSectionInfoByAddr64(dynStrtab.d_ptr);

            foreach (var entry in loader.GetDynEntries64(shdr.FileOffset))
            {
                switch (entry.d_tag)
                {
                default:
                    formatter.Write("{0,-12} {1:X16}", entry.d_tag, entry.d_val);
                    break;

                case DT_DEBUG:
                    formatter.Write("{0,-12} {1:X16}", "DT_DEBUG", entry.d_val);
                    break;

                case DT_FINI:
                    formatter.Write("{0,-12} ", "DT_FINI");
                    formatter.WriteHyperlink(string.Format("{0:X16}", entry.d_ptr), Address.Ptr64(entry.d_ptr));
                    break;

                case DT_HASH:
                    formatter.Write("{0,-12} ", "DT_HASH");
                    formatter.WriteHyperlink(string.Format("{0:X16}", entry.d_ptr), Address.Ptr64(entry.d_ptr));
                    break;

                case DT_INIT:
                    formatter.Write("{0,-12} ", "DT_INIT");
                    formatter.WriteHyperlink(string.Format("{0:X16}", entry.d_ptr), Address.Ptr64(entry.d_ptr));
                    break;

                case DT_PLTREL:
                    formatter.Write("{0,-12} {1}", "DT_PLTREL", entry.d_val);
                    break;

                case DT_JMPREL:
                    formatter.Write("{0,-12} ", "DT_JMPREL");
                    formatter.WriteHyperlink(string.Format("{0:X16}", entry.d_ptr), Address.Ptr64(entry.d_ptr));
                    break;

                case DT_NEEDED:
                    formatter.Write("{0,-12} {1}", "DT_NEEDED", loader.ReadAsciiString(strtabSection.FileOffset + entry.d_ptr));
                    break;

                case DT_STRSZ:
                    formatter.Write("{0,-12} {1:X}", "DT_STRSZ", entry.d_val);
                    break;

                case DT_STRTAB:
                    formatter.Write("{0,-12} ", "DT_STRTAB");
                    formatter.WriteHyperlink(string.Format("{0:X16}", entry.d_ptr), Address.Ptr64(entry.d_ptr));
                    break;

                case DT_SYMENT:
                    formatter.Write("{0,-12} {1}", "DT_SYMENTTRTAB", entry.d_val);
                    break;

                case DT_SYMTAB:
                    formatter.Write("{0,-12} ", "DT_SYMTAB");
                    formatter.WriteHyperlink(string.Format("{0:X16}", entry.d_ptr), Address.Ptr64(entry.d_ptr));
                    break;

                case DT_INIT_ARRAY:
                    formatter.Write("{0,-12} ", "DT_INIT_ARRAY");
                    formatter.WriteHyperlink(string.Format("{0:X16}", entry.d_ptr), Address.Ptr64(entry.d_ptr));
                    break;

                case DT_FINI_ARRAY:
                    formatter.Write("{0,-12} ", "DT_FINI_ARRAY");
                    formatter.WriteHyperlink(string.Format("{0:X16}", entry.d_ptr), Address.Ptr64(entry.d_ptr));
                    break;

                case DT_INIT_ARRAYSZ:
                    formatter.Write("{0,-12} {1:X}", "DT_INIT_ARRAYSZ", entry.d_val);
                    break;

                case DT_FINI_ARRAYSZ:
                    formatter.Write("{0,-12} {1:X}", "DT_FINI_ARRAYSZ", entry.d_val);
                    break;
                }
                formatter.WriteLine();
            }
        }