public override NativeExecutableReader LoadExecutable(TargetMemoryInfo memory, string filename, bool load_native_symtabs) { check_disposed (); Bfd bfd = (Bfd) bfd_hash [filename]; if (bfd != null) return bfd; bfd = new Bfd (this, memory, filename, TargetAddress.Null, true); bfd_hash.Add (filename, bfd); main_bfd = bfd; return bfd; }
public TargetBinaryWriter(int size, TargetMemoryInfo target_info) : base(new TargetBlob (size, target_info)) { }
public TargetBinaryWriter(int size, TargetMemoryInfo target_info) : base(new TargetBlob(size, target_info)) { }
public abstract NativeExecutableReader LoadExecutable(TargetMemoryInfo memory, string filename, bool load_native_symtabs);
public TargetBlob(int size, TargetMemoryInfo target_info) { this.Contents = new byte [size]; this.TargetMemoryInfo = target_info; }
public TargetBlob(byte[] contents, TargetMemoryInfo target_info) { this.Contents = contents; this.TargetMemoryInfo = target_info; }
public TargetBinaryReader(byte[] contents, TargetMemoryInfo target_info) : base(new TargetBlob(contents, target_info)) { }
public TargetBinaryReader(byte[] contents, TargetMemoryInfo target_info) : base(new TargetBlob (contents, target_info)) { }
internal MonoSymbolFile(MonoLanguageBackend language, Process process, TargetMemoryAccess memory, TargetAddress address) { this.MonoLanguage = language; this.TargetMemoryInfo = memory.TargetMemoryInfo; this.Architecture = process.Architecture; this.process = process; ThreadManager = process.ThreadManager; int address_size = TargetMemoryInfo.TargetAddressSize; int int_size = TargetMemoryInfo.TargetIntegerSize; ranges = ArrayList.Synchronized (new ArrayList ()); range_hash = Hashtable.Synchronized (new Hashtable ()); type_hash = Hashtable.Synchronized (new Hashtable ()); class_entry_by_token = Hashtable.Synchronized (new Hashtable ()); Index = memory.ReadInteger (address); address += int_size; TargetAddress image_file_addr = memory.ReadAddress (address); address += address_size; ImageFile = memory.ReadString (image_file_addr); MonoImage = memory.ReadAddress (address); address += address_size; TargetAddress type_table_ptr = memory.ReadAddress (address); address += address_size; TypeTable = MonoTypeTable.CreateTypeTable (this, memory, type_table_ptr); string shadow_location = language.GetShadowCopyLocation (ImageFile); if (shadow_location != null) ImageFile = shadow_location; try { Assembly = Cecil.AssemblyDefinition.ReadAssembly (ImageFile); } catch (Exception ex) { throw new SymbolTableException ( "Cannot load symbol file `{0}': {1}", ImageFile, ex); } ModuleDefinition = Assembly.MainModule; Report.Debug (DebugFlags.JitSymtab, "SYMBOL TABLE READER: {0}", ImageFile); string mdb_file = ImageFile + ".mdb"; try { File = C.MonoSymbolFile.ReadSymbolFile (ModuleDefinition, mdb_file); if (File == null) Report.Error ("Cannot load symbol file `{0}'", mdb_file); else if (ModuleDefinition.Mvid != File.Guid) { Report.Error ("Symbol file `{0}' does not match assembly `{1}'", mdb_file, ImageFile); File = null; } } catch (C.MonoSymbolFileException ex) { Report.Error (ex.Message); } catch (Exception ex) { Report.Error ("Cannot load symbol file `{0}': {1}", mdb_file, ex); } symtab = new MonoSymbolTable (this); name = Assembly.Name.FullName; module = process.Session.GetModule (name); if (module == null) { module = process.Session.CreateModule (name, this); } else { module.LoadModule (this); } #if FIXME if ((File != null) && (File.OffsetTable.IsAspxSource)) { Console.WriteLine ("ASPX SOURCE: {0} {1}", this, File); } #endif process.SymbolTableManager.AddSymbolFile (this); }
public Bfd(OperatingSystemBackend os, TargetMemoryInfo info, string filename, TargetAddress base_address, bool is_loaded) { this.os = os; this.info = info; this.filename = filename; this.base_address = base_address; this.is_loaded = is_loaded; this.symfile = new BfdSymbolFile (this); bfd = bfd_glue_openr (filename, null); if (bfd == IntPtr.Zero) throw new SymbolTableException ("Can't read symbol file: {0}", filename); if (bfd_glue_check_format_archive (bfd)) { IntPtr archive = bfd; bfd = IntPtr.Zero; while (true) { bfd = bfd_glue_openr_next_archived_file (archive, bfd); if(bfd == IntPtr.Zero) throw new SymbolTableException ("Can't read symbol file: {0}", filename); if (bfd_glue_check_format_object(bfd)) { /* * At this point, just check for mach-o-le (OS X X86 binary). * When we want to support other architctures in fat binarys, * we need to somehow get the correct target string for the * process, and chech against that. */ if (bfd_glue_get_target_name(bfd) == "mach-o-le") break; } } } if (bfd_glue_check_format_object (bfd)) is_coredump = false; else if (bfd_glue_check_format_core (bfd)) is_coredump = true; else throw new SymbolTableException ("Not an object file: {0}", filename); target = bfd_glue_get_target_name (bfd); if ((target == "elf32-i386") || (target == "elf64-x86-64")) { if (!is_coredump) { Section text = GetSectionByName (".text", false); Section bss = GetSectionByName (".bss", false); if ((text != null) && (bss != null)) { if (!base_address.IsNull) start_address = new TargetAddress ( info.AddressDomain, base_address.Address + text.vma); else start_address = new TargetAddress ( info.AddressDomain, text.vma); if (!base_address.IsNull) end_address = new TargetAddress ( info.AddressDomain, base_address.Address + bss.vma + bss.size); else end_address = new TargetAddress ( info.AddressDomain, bss.vma + bss.size); } } read_bfd_symbols (); if (DwarfReader.IsSupported (this)) has_debugging_info = true; Section plt_section = GetSectionByName (".plt", false); Section got_section = GetSectionByName (".got", false); if ((plt_section != null) && (got_section != null)) { plt_start = new TargetAddress ( info.AddressDomain, base_address.Address + plt_section.vma); plt_end = plt_start + plt_section.size; got_start = new TargetAddress ( info.AddressDomain, base_address.Address + got_section.vma); has_got = true; } } else if (target == "mach-o-le") { if (!is_coredump) { read_sections (); long start = 0xffffffff; long end = 0; foreach (Section section in sections) { long relocated = base_address.Address + section.vma; if (relocated < start) start = relocated; if (relocated + section.size > end) end = relocated + section.size; } start_address = new TargetAddress (info.AddressDomain, start); end_address = new TargetAddress (info.AddressDomain, end); } read_bfd_symbols (); if (DwarfReader.IsSupported (this)) has_debugging_info = true; has_got = false; } else throw new SymbolTableException ( "Symbol file {0} has unknown target architecture {1}", filename, target); long entry_point_addr = bfd_glue_get_start_address (bfd); entry_point = entry_point_addr != 0 ? new TargetAddress (info.AddressDomain, entry_point_addr) : TargetAddress.Null; module = os.Process.Session.GetModule (filename); if (module == null) { module = os.Process.Session.CreateModule (filename, symfile); OnModuleChanged (); } else { module.LoadModule (symfile); } os.Process.SymbolTableManager.AddSymbolFile (symfile); }
public override NativeExecutableReader LoadExecutable(TargetMemoryInfo memory, string filename, bool load_native_symtabs) { throw new NotImplementedException(); }