blob: f4f8ce9f574dfe0fddc09062f1963e5caf1d0c82 [file] [log] [blame]
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001//===-- 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 Claytone1a916a2010-07-21 22:12:05 +000013#include "llvm/Support/MachO.h"
14
Jim Ingham672e6f52011-03-07 23:44:08 +000015#include "lldb/Core/Address.h"
Greg Clayton53239f02011-02-08 05:05:52 +000016#include "lldb/Host/FileSpec.h"
Chris Lattner30fdc8d2010-06-08 16:52:24 +000017#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//----------------------------------------------------------------------
24class ObjectFileMachO :
25 public lldb_private::ObjectFile
26{
27public:
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
43 static ObjectFile *
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
50 static bool
Greg Clayton44435ed2012-01-12 05:25:17 +000051 MagicBytesMatch (lldb::DataBufferSP& dataSP,
52 lldb::addr_t offset,
53 lldb::addr_t length);
Chris Lattner30fdc8d2010-06-08 16:52:24 +000054
55 //------------------------------------------------------------------
56 // Member Functions
57 //------------------------------------------------------------------
58 ObjectFileMachO (lldb_private::Module* module,
59 lldb::DataBufferSP& dataSP,
60 const lldb_private::FileSpec* file,
61 lldb::addr_t offset,
62 lldb::addr_t length);
63
64 virtual
65 ~ObjectFileMachO();
66
67 virtual bool
68 ParseHeader ();
69
70 virtual lldb::ByteOrder
71 GetByteOrder () const;
Jim Ingham5aee1622010-08-09 23:31:02 +000072
73 virtual bool
74 IsExecutable () const;
Chris Lattner30fdc8d2010-06-08 16:52:24 +000075
76 virtual size_t
77 GetAddressByteSize () const;
78
Greg Claytone0d378b2011-03-24 21:19:54 +000079 virtual lldb_private::AddressClass
Greg Claytonded470d2011-03-19 01:12:21 +000080 GetAddressClass (lldb::addr_t file_addr);
81
Chris Lattner30fdc8d2010-06-08 16:52:24 +000082 virtual lldb_private::Symtab *
83 GetSymtab();
84
85 virtual lldb_private::SectionList *
86 GetSectionList();
87
88 virtual void
89 Dump (lldb_private::Stream *s);
90
91 virtual bool
Greg Clayton514487e2011-02-15 21:59:32 +000092 GetArchitecture (lldb_private::ArchSpec &arch);
Chris Lattner30fdc8d2010-06-08 16:52:24 +000093
94 virtual bool
95 GetUUID (lldb_private::UUID* uuid);
96
97 virtual uint32_t
98 GetDependentModules (lldb_private::FileSpecList& files);
99
100 //------------------------------------------------------------------
101 // PluginInterface protocol
102 //------------------------------------------------------------------
103 virtual const char *
104 GetPluginName();
105
106 virtual const char *
107 GetShortPluginName();
108
109 virtual uint32_t
110 GetPluginVersion();
111
Jim Ingham672e6f52011-03-07 23:44:08 +0000112 virtual lldb_private::Address
113 GetEntryPointAddress ();
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000114
Greg Clayton9e00b6a652011-07-09 00:41:34 +0000115 virtual ObjectFile::Type
116 CalculateType();
117
118 virtual ObjectFile::Strata
119 CalculateStrata();
120
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000121protected:
122 mutable lldb_private::Mutex m_mutex;
Greg Claytone1a916a2010-07-21 22:12:05 +0000123 llvm::MachO::mach_header m_header;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000124 mutable std::auto_ptr<lldb_private::SectionList> m_sections_ap;
125 mutable std::auto_ptr<lldb_private::Symtab> m_symtab_ap;
126
Greg Claytone1a916a2010-07-21 22:12:05 +0000127 llvm::MachO::dysymtab_command m_dysymtab;
128 std::vector<llvm::MachO::segment_command_64> m_mach_segments;
129 std::vector<llvm::MachO::section_64> m_mach_sections;
Jim Ingham672e6f52011-03-07 23:44:08 +0000130 lldb_private::Address m_entry_point_address;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000131
132 size_t
133 ParseSections ();
134
135 size_t
136 ParseSymtab (bool minimize);
137
138};
139
140#endif // liblldb_ObjectFileMachO_h_