Esempio n. 1
0
        private long ReadEncodedValue(DwarfBinaryReader reader, int encoding)
        {
            long base_addr;
            switch (encoding & 0x70) {
            case 0:
                base_addr = 0;
                break;
            case (byte) DW_EH_PE.pcrel:
                base_addr = vma + reader.Position;
                break;
            default:
                throw new DwarfException (
                    reader.Bfd, "Unknown encoding `{0:x}' in CIE",
                    encoding);
            }

            long value;
            switch (encoding & 0x0f) {
            case (byte) DW_EH_PE.udata4:
                value = reader.ReadUInt32 ();
                break;
            case (byte) DW_EH_PE.sdata4:
                value = reader.ReadInt32 ();
                break;
            default:
                throw new DwarfException (
                    reader.Bfd, "Unknown encoding `{0:x}' in CIE",
                    encoding);
            }

            return base_addr + value;
        }
Esempio n. 2
0
            void read_cie(DwarfBinaryReader reader)
            {
                long length = reader.ReadInitialLength ();
                long end_pos = reader.Position + length;
                int id = reader.ReadInt32 ();

                bool is_cie;
                if (frame.is_ehframe)
                    is_cie = id == 0;
                else
                    is_cie = id == -1;
                if (!is_cie)
                    throw new InvalidOperationException ();

                int version = reader.ReadByte ();
                if (version != 1)
                    throw new DwarfException (
                        reader.Bfd, "Unknown version {0} in CIE",
                        version);

                string augmentation = reader.ReadString ();

                if (augmentation.StartsWith ("eh")) {
                    reader.ReadAddress ();
                    augmentation = augmentation.Substring (2);
                }

                code_alignment = reader.ReadLeb128 ();
                data_alignment = reader.ReadSLeb128 ();
                return_register = reader.ReadByte ();

                for (int pos = 0; pos < augmentation.Length; pos++) {
                    if (augmentation [pos] == 'z') {
                        reader.ReadLeb128 ();
                        // has_z_augmentation = true;
                        continue;
                    }

                    if (augmentation [pos] == 'L')
                        continue;
                    else if (augmentation [pos] == 'R') {
                        encoding = reader.ReadByte ();
                        continue;
                    }
                    else if (augmentation [pos] == 'P') {
                        continue;
                    }

                    throw new DwarfException (
                        reader.Bfd, "Unknown augmentation `{0}' in CIE",
                        augmentation[pos]);
                }

                columns = new Column [return_register + 2];
                for (int i = 0; i < columns.Length; i++)
                    columns [i] = new Column (State.Undefined);

                Entry entry = new Entry (this);
                entry.Read (reader, end_pos);

                reader.Position = end_pos;
            }
Esempio n. 3
0
        Hashtable read_pubtypes()
        {
            if (debug_pubtypes_reader == null)
                return null;

            DwarfBinaryReader reader = new DwarfBinaryReader (
                bfd, (TargetBlob) debug_pubtypes_reader.Data, Is64Bit);

            Hashtable names = Hashtable.Synchronized (new Hashtable ());

            while (!reader.IsEof) {
                long length = reader.ReadInitialLength ();
                long stop = reader.Position + length;
                int version = reader.ReadInt16 ();
                long debug_offset = reader.ReadOffset ();
                reader.ReadOffset ();

                if (version != 2)
                    throw new DwarfException (
                        bfd, "Wrong version in .debug_pubtypes: {0}",
                        version);

                while (reader.Position < stop) {
                    long offset = reader.ReadInt32 ();
                    if (offset == 0)
                        break;

                    string name = reader.ReadString ();
                    if (!names.Contains (name))
                        names.Add (name, new NameEntry (debug_offset, offset));
                }
            }

            return names;
        }