Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1 | //===-- ObjectFileMachO.h ---------------------------------------*- C++ -*-===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | #ifndef liblldb_ObjectFileMachO_h_ |
| 11 | #define liblldb_ObjectFileMachO_h_ |
| 12 | |
Greg Clayton | 1674b12 | 2010-07-21 22:12:05 +0000 | [diff] [blame] | 13 | #include "llvm/Support/MachO.h" |
| 14 | |
Jim Ingham | 2877594 | 2011-03-07 23:44:08 +0000 | [diff] [blame] | 15 | #include "lldb/Core/Address.h" |
Greg Clayton | 5f54ac3 | 2011-02-08 05:05:52 +0000 | [diff] [blame] | 16 | #include "lldb/Host/FileSpec.h" |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 17 | #include "lldb/Host/Mutex.h" |
| 18 | #include "lldb/Symbol/ObjectFile.h" |
| 19 | |
| 20 | //---------------------------------------------------------------------- |
| 21 | // This class needs to be hidden as eventually belongs in a plugin that |
| 22 | // will export the ObjectFile protocol |
| 23 | //---------------------------------------------------------------------- |
| 24 | class ObjectFileMachO : |
| 25 | public lldb_private::ObjectFile |
| 26 | { |
| 27 | public: |
| 28 | //------------------------------------------------------------------ |
| 29 | // Static Functions |
| 30 | //------------------------------------------------------------------ |
| 31 | static void |
| 32 | Initialize(); |
| 33 | |
| 34 | static void |
| 35 | Terminate(); |
| 36 | |
| 37 | static const char * |
| 38 | GetPluginNameStatic(); |
| 39 | |
| 40 | static const char * |
| 41 | GetPluginDescriptionStatic(); |
| 42 | |
Greg Clayton | b5a8f14 | 2012-02-05 02:38:54 +0000 | [diff] [blame^] | 43 | static lldb_private::ObjectFile * |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 44 | CreateInstance (lldb_private::Module* module, |
| 45 | lldb::DataBufferSP& dataSP, |
| 46 | const lldb_private::FileSpec* file, |
| 47 | lldb::addr_t offset, |
| 48 | lldb::addr_t length); |
| 49 | |
Greg Clayton | b5a8f14 | 2012-02-05 02:38:54 +0000 | [diff] [blame^] | 50 | static lldb_private::ObjectFile * |
| 51 | CreateMemoryInstance (lldb_private::Module* module, |
| 52 | lldb::DataBufferSP& data_sp, |
| 53 | const lldb::ProcessSP &process_sp, |
| 54 | lldb::addr_t header_addr); |
| 55 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 56 | static bool |
Greg Clayton | db2dc2b | 2012-01-12 05:25:17 +0000 | [diff] [blame] | 57 | MagicBytesMatch (lldb::DataBufferSP& dataSP, |
| 58 | lldb::addr_t offset, |
| 59 | lldb::addr_t length); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 60 | |
| 61 | //------------------------------------------------------------------ |
| 62 | // Member Functions |
| 63 | //------------------------------------------------------------------ |
| 64 | ObjectFileMachO (lldb_private::Module* module, |
| 65 | lldb::DataBufferSP& dataSP, |
| 66 | const lldb_private::FileSpec* file, |
| 67 | lldb::addr_t offset, |
| 68 | lldb::addr_t length); |
| 69 | |
Greg Clayton | b5a8f14 | 2012-02-05 02:38:54 +0000 | [diff] [blame^] | 70 | ObjectFileMachO (lldb_private::Module* module, |
| 71 | lldb::DataBufferSP& dataSP, |
| 72 | const lldb::ProcessSP &process_sp, |
| 73 | lldb::addr_t header_addr); |
| 74 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 75 | virtual |
| 76 | ~ObjectFileMachO(); |
| 77 | |
| 78 | virtual bool |
| 79 | ParseHeader (); |
| 80 | |
| 81 | virtual lldb::ByteOrder |
| 82 | GetByteOrder () const; |
Jim Ingham | 7508e73 | 2010-08-09 23:31:02 +0000 | [diff] [blame] | 83 | |
| 84 | virtual bool |
| 85 | IsExecutable () const; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 86 | |
| 87 | virtual size_t |
| 88 | GetAddressByteSize () const; |
| 89 | |
Greg Clayton | b344843 | 2011-03-24 21:19:54 +0000 | [diff] [blame] | 90 | virtual lldb_private::AddressClass |
Greg Clayton | b1888f2 | 2011-03-19 01:12:21 +0000 | [diff] [blame] | 91 | GetAddressClass (lldb::addr_t file_addr); |
| 92 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 93 | virtual lldb_private::Symtab * |
| 94 | GetSymtab(); |
| 95 | |
| 96 | virtual lldb_private::SectionList * |
| 97 | GetSectionList(); |
| 98 | |
| 99 | virtual void |
| 100 | Dump (lldb_private::Stream *s); |
| 101 | |
| 102 | virtual bool |
Greg Clayton | 395fc33 | 2011-02-15 21:59:32 +0000 | [diff] [blame] | 103 | GetArchitecture (lldb_private::ArchSpec &arch); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 104 | |
| 105 | virtual bool |
| 106 | GetUUID (lldb_private::UUID* uuid); |
| 107 | |
| 108 | virtual uint32_t |
| 109 | GetDependentModules (lldb_private::FileSpecList& files); |
| 110 | |
| 111 | //------------------------------------------------------------------ |
| 112 | // PluginInterface protocol |
| 113 | //------------------------------------------------------------------ |
| 114 | virtual const char * |
| 115 | GetPluginName(); |
| 116 | |
| 117 | virtual const char * |
| 118 | GetShortPluginName(); |
| 119 | |
| 120 | virtual uint32_t |
| 121 | GetPluginVersion(); |
| 122 | |
Jim Ingham | 2877594 | 2011-03-07 23:44:08 +0000 | [diff] [blame] | 123 | virtual lldb_private::Address |
| 124 | GetEntryPointAddress (); |
Greg Clayton | b5a8f14 | 2012-02-05 02:38:54 +0000 | [diff] [blame^] | 125 | |
| 126 | virtual lldb_private::Address |
| 127 | GetHeaderAddress (); |
| 128 | |
Greg Clayton | ca31997 | 2011-07-09 00:41:34 +0000 | [diff] [blame] | 129 | virtual ObjectFile::Type |
| 130 | CalculateType(); |
| 131 | |
| 132 | virtual ObjectFile::Strata |
| 133 | CalculateStrata(); |
| 134 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 135 | protected: |
| 136 | mutable lldb_private::Mutex m_mutex; |
Greg Clayton | 1674b12 | 2010-07-21 22:12:05 +0000 | [diff] [blame] | 137 | llvm::MachO::mach_header m_header; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 138 | mutable std::auto_ptr<lldb_private::SectionList> m_sections_ap; |
| 139 | mutable std::auto_ptr<lldb_private::Symtab> m_symtab_ap; |
Greg Clayton | b5a8f14 | 2012-02-05 02:38:54 +0000 | [diff] [blame^] | 140 | static const lldb_private::ConstString &GetSegmentNameTEXT(); |
| 141 | static const lldb_private::ConstString &GetSegmentNameDATA(); |
| 142 | static const lldb_private::ConstString &GetSegmentNameOBJC(); |
| 143 | static const lldb_private::ConstString &GetSegmentNameLINKEDIT(); |
| 144 | static const lldb_private::ConstString &GetSectionNameEHFrame(); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 145 | |
Greg Clayton | 1674b12 | 2010-07-21 22:12:05 +0000 | [diff] [blame] | 146 | llvm::MachO::dysymtab_command m_dysymtab; |
| 147 | std::vector<llvm::MachO::segment_command_64> m_mach_segments; |
| 148 | std::vector<llvm::MachO::section_64> m_mach_sections; |
Jim Ingham | 2877594 | 2011-03-07 23:44:08 +0000 | [diff] [blame] | 149 | lldb_private::Address m_entry_point_address; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 150 | |
| 151 | size_t |
| 152 | ParseSections (); |
| 153 | |
| 154 | size_t |
| 155 | ParseSymtab (bool minimize); |
| 156 | |
| 157 | }; |
| 158 | |
| 159 | #endif // liblldb_ObjectFileMachO_h_ |