]> CyberLeo.Net >> Repos - FreeBSD/releng/10.2.git/blob - contrib/llvm/tools/lldb/include/lldb/Symbol/ObjectFile.h
- Copy stable/10@285827 to releng/10.2 in preparation for 10.2-RC1
[FreeBSD/releng/10.2.git] / contrib / llvm / tools / lldb / include / lldb / Symbol / ObjectFile.h
1 //===-- ObjectFile.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_ObjectFile_h_
11 #define liblldb_ObjectFile_h_
12
13 #include "lldb/lldb-private.h"
14 #include "lldb/Core/DataExtractor.h"
15 #include "lldb/Host/FileSpec.h"
16 #include "lldb/Core/FileSpecList.h"
17 #include "lldb/Core/ModuleChild.h"
18 #include "lldb/Core/PluginInterface.h"
19 #include "lldb/Host/Endian.h"
20 #include "lldb/Symbol/Symtab.h"
21 #include "lldb/Symbol/UnwindTable.h"
22
23 namespace lldb_private {
24
25 //----------------------------------------------------------------------
26 /// @class ObjectFile ObjectFile.h "lldb/Symbol/ObjectFile.h"
27 /// @brief A plug-in interface definition class for object file parsers.
28 ///
29 /// Object files belong to Module objects and know how to extract
30 /// information from executable, shared library, and object (.o) files
31 /// used by operating system runtime. The symbol table and section list
32 /// for an object file.
33 ///
34 /// Object files can be represented by the entire file, or by part of a
35 /// file. Examples of object files that are part of a file include
36 /// object files that contain information for multiple architectures in
37 /// the same file, or archive files that contain multiple objects
38 /// (ranlib archives) (possibly for multiple architectures as well).
39 ///
40 /// Object archive files (e.g. ranlib archives) can contain 
41 /// multiple .o (object) files that must be selected by index or by name. 
42 /// The number of objects that an ObjectFile contains can be determined 
43 /// using the ObjectFile::GetNumObjects() const
44 /// function, and followed by a call to
45 /// ObjectFile::SelectObjectAtIndex (uint32_t) to change the currently
46 /// selected object. Objects can also be selected by name using the
47 /// ObjectFile::SelectObject(const char *) function.
48 ///
49 /// Once an architecture is selected (and an object is selected for
50 /// for archives), the object file information can be extracted from
51 /// this abstract class.
52 //----------------------------------------------------------------------
53 class ObjectFile:
54     public std::enable_shared_from_this<ObjectFile>,
55     public PluginInterface,
56     public ModuleChild
57 {
58 friend class lldb_private::Module;
59
60 public:
61     typedef enum 
62     {
63         eTypeInvalid = 0,
64         eTypeCoreFile,      /// A core file that has a checkpoint of a program's execution state
65         eTypeExecutable,    /// A normal executable
66         eTypeDebugInfo,     /// An object file that contains only debug information
67         eTypeDynamicLinker, /// The platform's dynamic linker executable
68         eTypeObjectFile,    /// An intermediate object file
69         eTypeSharedLibrary, /// A shared library that can be used during execution
70         eTypeStubLibrary,   /// A library that can be linked against but not used for execution
71         eTypeUnknown
72     } Type;
73
74     typedef enum 
75     {
76         eStrataInvalid = 0,
77         eStrataUnknown,
78         eStrataUser,
79         eStrataKernel,
80         eStrataRawImage
81     } Strata;
82
83     //------------------------------------------------------------------
84     /// Construct with a parent module, offset, and header data.
85     ///
86     /// Object files belong to modules and a valid module must be
87     /// supplied upon construction. The at an offset within a file for
88     /// objects that contain more than one architecture or object.
89     //------------------------------------------------------------------
90     ObjectFile (const lldb::ModuleSP &module_sp, 
91                 const FileSpec *file_spec_ptr, 
92                 lldb::offset_t file_offset,
93                 lldb::offset_t length,
94                 lldb::DataBufferSP& data_sp,
95                 lldb::offset_t data_offset);
96
97     ObjectFile (const lldb::ModuleSP &module_sp, 
98                 const lldb::ProcessSP &process_sp,
99                 lldb::addr_t header_addr, 
100                 lldb::DataBufferSP& data_sp);
101
102     //------------------------------------------------------------------
103     /// Destructor.
104     ///
105     /// The destructor is virtual since this class is designed to be
106     /// inherited from by the plug-in instance.
107     //------------------------------------------------------------------
108     virtual
109     ~ObjectFile();
110     
111     //------------------------------------------------------------------
112     /// Dump a description of this object to a Stream.
113     ///
114     /// Dump a description of the current contents of this object
115     /// to the supplied stream \a s. The dumping should include the
116     /// section list if it has been parsed, and the symbol table
117     /// if it has been parsed.
118     ///
119     /// @param[in] s
120     ///     The stream to which to dump the object descripton.
121     //------------------------------------------------------------------
122     virtual void
123     Dump (Stream *s) = 0;
124
125     //------------------------------------------------------------------
126     /// Find a ObjectFile plug-in that can parse \a file_spec.
127     ///
128     /// Scans all loaded plug-in interfaces that implement versions of
129     /// the ObjectFile plug-in interface and returns the first
130     /// instance that can parse the file.
131     ///
132     /// @param[in] module
133     ///     The parent module that owns this object file.
134     ///
135     /// @param[in] file_spec
136     ///     A file specification that indicates which file to use as the
137     ///     object file.
138     ///
139     /// @param[in] file_offset
140     ///     The offset into the file at which to start parsing the
141     ///     object. This is for files that contain multiple
142     ///     architectures or objects.
143     ///
144     /// @param[in] file_size
145     ///     The size of the current object file if it can be determined
146     ///     or if it is known. This can be zero.
147     ///
148     /// @see ObjectFile::ParseHeader()
149     //------------------------------------------------------------------
150     static lldb::ObjectFileSP
151     FindPlugin (const lldb::ModuleSP &module_sp,
152                 const FileSpec* file_spec,
153                 lldb::offset_t file_offset,
154                 lldb::offset_t file_size,
155                 lldb::DataBufferSP &data_sp,
156                 lldb::offset_t &data_offset);
157
158     //------------------------------------------------------------------
159     /// Find a ObjectFile plug-in that can parse a file in memory.
160     ///
161     /// Scans all loaded plug-in interfaces that implement versions of
162     /// the ObjectFile plug-in interface and returns the first
163     /// instance that can parse the file.
164     ///
165     /// @param[in] module
166     ///     The parent module that owns this object file.
167     ///
168     /// @param[in] process_sp
169     ///     A shared pointer to the process whose memory space contains
170     ///     an object file. This will be stored as a std::weak_ptr.
171     ///
172     /// @param[in] header_addr
173     ///     The address of the header for the object file in memory.
174     //------------------------------------------------------------------
175     static lldb::ObjectFileSP
176     FindPlugin (const lldb::ModuleSP &module_sp, 
177                 const lldb::ProcessSP &process_sp,
178                 lldb::addr_t header_addr,
179                 lldb::DataBufferSP &file_data_sp);
180
181     
182     static size_t
183     GetModuleSpecifications (const FileSpec &file,
184                              lldb::offset_t file_offset,
185                              lldb::offset_t file_size,
186                              ModuleSpecList &specs);
187     
188     static size_t
189     GetModuleSpecifications (const lldb_private::FileSpec& file,
190                              lldb::DataBufferSP& data_sp,
191                              lldb::offset_t data_offset,
192                              lldb::offset_t file_offset,
193                              lldb::offset_t file_size,
194                              lldb_private::ModuleSpecList &specs);
195     //------------------------------------------------------------------
196     /// Split a path into a file path with object name.
197     ///
198     /// For paths like "/tmp/foo.a(bar.o)" we often need to split a path
199     /// up into the actual path name and into the object name so we can
200     /// make a valid object file from it.
201     ///
202     /// @param[in] path_with_object
203     ///     A path that might contain an archive path with a .o file
204     ///     specified in parens in the basename of the path.
205     ///
206     /// @param[out] archive_file
207     ///     If \b true is returned, \a file_spec will be filled in with
208     ///     the path to the archive.
209     ///
210     /// @param[out] archive_object
211     ///     If \b true is returned, \a object will be filled in with
212     ///     the name of the object inside the archive.
213     ///
214     /// @return
215     ///     \b true if the path matches the pattern of archive + object
216     ///     and \a archive_file and \a archive_object are modified,
217     ///     \b false otherwise and \a archive_file and \a archive_object
218     ///     are guaranteed to be remain unchanged.
219     //------------------------------------------------------------------
220     static bool
221     SplitArchivePathWithObject (const char *path_with_object,
222                                 lldb_private::FileSpec &archive_file,
223                                 lldb_private::ConstString &archive_object,
224                                 bool must_exist);
225
226     //------------------------------------------------------------------
227     /// Gets the address size in bytes for the current object file.
228     ///
229     /// @return
230     ///     The size of an address in bytes for the currently selected
231     ///     architecture (and object for archives). Returns zero if no
232     ///     architecture or object has been selected.
233     //------------------------------------------------------------------
234     virtual uint32_t
235     GetAddressByteSize ()  const = 0;
236
237     //------------------------------------------------------------------
238     /// Get the address type given a file address in an object file.
239     ///
240     /// Many binary file formats know what kinds
241     /// This is primarily for ARM binaries, though it can be applied to
242     /// any executable file format that supports different opcode types
243     /// within the same binary. ARM binaries support having both ARM and
244     /// Thumb within the same executable container. We need to be able
245     /// to get
246     /// @return
247     ///     The size of an address in bytes for the currently selected
248     ///     architecture (and object for archives). Returns zero if no
249     ///     architecture or object has been selected.
250     //------------------------------------------------------------------
251     virtual lldb::AddressClass
252     GetAddressClass (lldb::addr_t file_addr);
253
254     //------------------------------------------------------------------
255     /// Extract the dependent modules from an object file.
256     ///
257     /// If an object file has information about which other images it
258     /// depends on (such as shared libraries), this function will
259     /// provide the list. Since many executables or shared libraries
260     /// may depend on the same files,
261     /// FileSpecList::AppendIfUnique(const FileSpec &) should be
262     /// used to make sure any files that are added are not already in
263     /// the list.
264     ///
265     /// @param[out] file_list
266     ///     A list of file specification objects that gets dependent
267     ///     files appended to.
268     ///
269     /// @return
270     ///     The number of new files that were appended to \a file_list.
271     ///
272     /// @see FileSpecList::AppendIfUnique(const FileSpec &)
273     //------------------------------------------------------------------
274     virtual uint32_t
275     GetDependentModules (FileSpecList& file_list) = 0;
276     
277     //------------------------------------------------------------------
278     /// Tells whether this object file is capable of being the main executable
279     /// for a process.
280     ///
281     /// @return
282     ///     \b true if it is, \b false otherwise.
283     //------------------------------------------------------------------
284     virtual bool
285     IsExecutable () const = 0;
286
287     //------------------------------------------------------------------
288     /// Returns the offset into a file at which this object resides.
289     ///
290     /// Some files contain many object files, and this function allows
291     /// access to an object's offset within the file.
292     ///
293     /// @return
294     ///     The offset in bytes into the file. Defaults to zero for
295     ///     simple object files that a represented by an entire file.
296     //------------------------------------------------------------------
297     virtual lldb::addr_t
298     GetFileOffset () const
299     { return m_file_offset; }
300
301     virtual lldb::addr_t
302     GetByteSize () const
303     { return m_length; }
304
305     //------------------------------------------------------------------
306     /// Get accessor to the object file specification.
307     ///
308     /// @return
309     ///     The file specification object pointer if there is one, or
310     ///     NULL if this object is only from memory.
311     //------------------------------------------------------------------
312     virtual FileSpec&
313     GetFileSpec() { return m_file; }
314
315     //------------------------------------------------------------------
316     /// Get const accessor to the object file specification.
317     ///
318     /// @return
319     ///     The const file specification object pointer if there is one,
320     ///     or NULL if this object is only from memory.
321     //------------------------------------------------------------------
322     virtual const FileSpec&
323     GetFileSpec() const { return m_file; }
324
325     //------------------------------------------------------------------
326     /// Get the name of the cpu, vendor and OS for this object file.
327     ///
328     /// This value is a string that represents the target triple where
329     /// the cpu type, the vendor and the OS are encoded into a string.
330     ///
331     /// @param[out] target_triple
332     ///     The string value of the target triple.
333     ///
334     /// @return
335     ///     \b True if the target triple was able to be computed, \b
336     ///     false otherwise.
337     //------------------------------------------------------------------
338     virtual bool
339     GetArchitecture (ArchSpec &arch) = 0;
340
341     //------------------------------------------------------------------
342     /// Gets the section list for the currently selected architecture
343     /// (and object for archives).
344     ///
345     /// Section list parsing can be deferred by ObjectFile instances
346     /// until this accessor is called the first time.
347     ///
348     /// @return
349     ///     The list of sections contained in this object file.
350     //------------------------------------------------------------------
351     virtual SectionList *
352     GetSectionList ();
353
354     virtual void
355     CreateSections (SectionList &unified_section_list) = 0;
356
357     //------------------------------------------------------------------
358     /// Gets the symbol table for the currently selected architecture
359     /// (and object for archives).
360     ///
361     /// Symbol table parsing can be deferred by ObjectFile instances
362     /// until this accessor is called the first time.
363     ///
364     /// @return
365     ///     The symbol table for this object file.
366     //------------------------------------------------------------------
367     virtual Symtab *
368     GetSymtab () = 0;
369
370     //------------------------------------------------------------------
371     /// Appends a Symbol for the specified so_addr to the symbol table.
372     ///
373     /// If verify_unique is false, the symbol table is not searched
374     /// to determine if a Symbol found at this address has already been
375     /// added to the symbol table.  When verify_unique is true, this
376     /// method resolves the Symbol as the first match in the SymbolTable
377     /// and appends a Symbol only if required/found.
378     ///
379     /// @return
380     ///     The resolved symbol or nullptr.  Returns nullptr if a
381     ///     a Symbol could not be found for the specified so_addr.
382     //------------------------------------------------------------------
383     virtual Symbol *
384     ResolveSymbolForAddress(const Address &so_addr, bool verify_unique)
385     {
386         // Typically overridden to lazily add stripped symbols recoverable from
387         // the exception handling unwind information (i.e. without parsing
388         // the entire eh_frame section.
389         //
390         // The availability of LC_FUNCTION_STARTS allows ObjectFileMachO
391         // to efficiently add stripped symbols when the symbol table is
392         // first constructed.  Poorer cousins are PECoff and ELF.
393         return nullptr;
394     }
395
396     //------------------------------------------------------------------
397     /// Detect if this object file has been stripped of local symbols.
398     //------------------------------------------------------------------
399     /// Detect if this object file has been stripped of local symbols.
400     ///
401     /// @return
402     ///     Return \b true if the object file has been stripped of local
403     ///     symbols.
404     //------------------------------------------------------------------
405     virtual bool
406     IsStripped () = 0;
407
408     //------------------------------------------------------------------
409     /// Frees the symbol table.
410     ///
411     /// This function should only be used when an object file is
412     ///
413     /// @param[in] flags
414     ///     eSymtabFromUnifiedSectionList: Whether to clear symbol table
415     ///     for unified module section list, or object file.
416     ///
417     /// @return
418     ///     The symbol table for this object file.
419     //------------------------------------------------------------------
420     virtual void
421     ClearSymtab ();
422     
423     //------------------------------------------------------------------
424     /// Gets the UUID for this object file.
425     ///
426     /// If the object file format contains a UUID, the value should be
427     /// returned. Else ObjectFile instances should return the MD5
428     /// checksum of all of the bytes for the object file (or memory for
429     /// memory based object files).
430     ///
431     /// @return
432     ///     Returns \b true if a UUID was successfully extracted into
433     ///     \a uuid, \b false otherwise.
434     //------------------------------------------------------------------
435     virtual bool
436     GetUUID (lldb_private::UUID* uuid) = 0;
437
438     //------------------------------------------------------------------
439     /// Gets the symbol file spec list for this object file.
440     ///
441     /// If the object file format contains a debug symbol file link,
442     /// the values will be return in the FileSpecList.
443     ///
444     /// @return
445     ///     Returns filespeclist.
446     //------------------------------------------------------------------
447     virtual lldb_private::FileSpecList
448     GetDebugSymbolFilePaths()
449     {
450         return FileSpecList();
451     }
452
453     //------------------------------------------------------------------
454     /// Sets the load address for an entire module, assuming a rigid
455     /// slide of sections, if possible in the implementation.
456     ///
457     /// @return
458     ///     Returns true iff any section's load address changed.
459     //------------------------------------------------------------------
460     virtual bool
461     SetLoadAddress(Target &target,
462                    lldb::addr_t value,
463                    bool value_is_offset)
464     {
465         return false;
466     }
467
468     //------------------------------------------------------------------
469     /// Gets whether endian swapping should occur when extracting data
470     /// from this object file.
471     ///
472     /// @return
473     ///     Returns \b true if endian swapping is needed, \b false
474     ///     otherwise.
475     //------------------------------------------------------------------
476     virtual lldb::ByteOrder
477     GetByteOrder () const = 0;
478
479     //------------------------------------------------------------------
480     /// Attempts to parse the object header.
481     ///
482     /// This function is used as a test to see if a given plug-in
483     /// instance can parse the header data already contained in
484     /// ObjectFile::m_data. If an object file parser does not
485     /// recognize that magic bytes in a header, false should be returned
486     /// and the next plug-in can attempt to parse an object file.
487     ///
488     /// @return
489     ///     Returns \b true if the header was parsed succesfully, \b
490     ///     false otherwise.
491     //------------------------------------------------------------------
492     virtual bool
493     ParseHeader () = 0;
494
495     //------------------------------------------------------------------
496     /// Returns a reference to the UnwindTable for this ObjectFile
497     ///
498     /// The UnwindTable contains FuncUnwinders objects for any function in
499     /// this ObjectFile.  If a FuncUnwinders object hasn't been created yet
500     /// (i.e. the function has yet to be unwound in a stack walk), it
501     /// will be created when requested.  Specifically, we do not create
502     /// FuncUnwinders objects for functions until they are needed.
503     ///
504     /// @return
505     ///     Returns the unwind table for this object file.
506     //------------------------------------------------------------------
507     virtual lldb_private::UnwindTable&
508     GetUnwindTable () { return m_unwind_table; }
509
510     //------------------------------------------------------------------
511     /// Similar to Process::GetImageInfoAddress().
512     ///
513     /// Some platforms embed auxiliary structures useful to debuggers in the
514     /// address space of the inferior process.  This method returns the address
515     /// of such a structure if the information can be resolved via entries in
516     /// the object file.  ELF, for example, provides a means to hook into the
517     /// runtime linker so that a debugger may monitor the loading and unloading
518     /// of shared libraries.
519     ///
520     /// @return 
521     ///     The address of any auxiliary tables, or an invalid address if this
522     ///     object file format does not support or contain such information.
523     virtual lldb_private::Address
524     GetImageInfoAddress (Target *target) { return Address(); }
525     
526     //------------------------------------------------------------------
527     /// Returns the address of the Entry Point in this object file - if
528     /// the object file doesn't have an entry point (because it is not an
529     /// executable file) then an invalid address is returned.
530     ///
531     /// @return
532     ///     Returns the entry address for this module.
533     //------------------------------------------------------------------
534     virtual lldb_private::Address
535     GetEntryPointAddress () { return Address();}
536
537     //------------------------------------------------------------------
538     /// Returns the address that represents the header of this object
539     /// file.
540     ///
541     /// The header address is defined as where the header for the object
542     /// file is that describes the content of the file. If the header
543     /// doesn't appear in a section that is defined in the object file,
544     /// an address with no section is returned that has the file offset
545     /// set in the m_file_offset member of the lldb_private::Address object.
546     ///
547     /// @return
548     ///     Returns the entry address for this module.
549     //------------------------------------------------------------------
550     virtual lldb_private::Address
551     GetHeaderAddress () { return Address(m_memory_addr);}
552
553     
554     virtual uint32_t
555     GetNumThreadContexts ()
556     {
557         return 0;
558     }
559
560     virtual lldb::RegisterContextSP
561     GetThreadContextAtIndex (uint32_t idx, lldb_private::Thread &thread)
562     {
563         return lldb::RegisterContextSP();
564     }
565
566     //------------------------------------------------------------------
567     /// The object file should be able to calculate its type by looking
568     /// at its file header and possibly the sections or other data in
569     /// the object file. The file type is used in the debugger to help
570     /// select the correct plug-ins for the job at hand, so this is 
571     /// important to get right. If any eTypeXXX definitions do not match
572     /// up with the type of file you are loading, please feel free to
573     /// add a new enumeration value.
574     ///
575     /// @return
576     ///     The calculated file type for the current object file.
577     //------------------------------------------------------------------
578     virtual Type
579     CalculateType() = 0;
580
581     //------------------------------------------------------------------
582     /// In cases where the type can't be calculated (elf files), this
583     /// routine allows someone to explicitly set it. As an example,
584     /// SymbolVendorELF uses this routine to set eTypeDebugInfo when
585     /// loading debug link files.
586     virtual void
587     SetType (Type type)
588     {
589         m_type = type;
590     }
591
592     //------------------------------------------------------------------
593     /// The object file should be able to calculate the strata of the
594     /// object file.
595     ///
596     /// Many object files for platforms might be for either user space
597     /// debugging or for kernel debugging. If your object file subclass
598     /// can figure this out, it will help with debugger plug-in selection
599     /// when it comes time to debug.
600     ///
601     /// @return
602     ///     The calculated object file strata for the current object 
603     ///     file.
604     //------------------------------------------------------------------
605     virtual Strata
606     CalculateStrata() = 0;
607     
608     //------------------------------------------------------------------
609     /// Get the object file version numbers.
610     ///
611     /// Many object files have a set of version numbers that describe
612     /// the version of the executable or shared library. Typically there
613     /// are major, minor and build, but there may be more. This function
614     /// will extract the versions from object files if they are available.
615     ///
616     /// If \a versions is NULL, or if \a num_versions is 0, the return
617     /// value will indicate how many version numbers are available in
618     /// this object file. Then a subsequent call can be made to this 
619     /// function with a value of \a versions and \a num_versions that
620     /// has enough storage to store some or all version numbers.
621     ///
622     /// @param[out] versions
623     ///     A pointer to an array of uint32_t types that is \a num_versions
624     ///     long. If this value is NULL, the return value will indicate
625     ///     how many version numbers are required for a subsequent call
626     ///     to this function so that all versions can be retrieved. If
627     ///     the value is non-NULL, then at most \a num_versions of the
628     ///     existing versions numbers will be filled into \a versions.
629     ///     If there is no version information available, \a versions
630     ///     will be filled with \a num_versions UINT32_MAX values
631     ///     and zero will be returned.
632     ///
633     /// @param[in] num_versions
634     ///     The maximum number of entries to fill into \a versions. If
635     ///     this value is zero, then the return value will indicate
636     ///     how many version numbers there are in total so another call
637     ///     to this function can be make with adequate storage in
638     ///     \a versions to get all of the version numbers. If \a
639     ///     num_versions is less than the actual number of version 
640     ///     numbers in this object file, only \a num_versions will be
641     ///     filled into \a versions (if \a versions is non-NULL).
642     ///
643     /// @return
644     ///     This function always returns the number of version numbers
645     ///     that this object file has regardless of the number of
646     ///     version numbers that were copied into \a versions. 
647     //------------------------------------------------------------------
648     virtual uint32_t
649     GetVersion (uint32_t *versions, uint32_t num_versions)
650     {
651         if (versions && num_versions)
652         {
653             for (uint32_t i=0; i<num_versions; ++i)
654                 versions[i] = UINT32_MAX;
655         }
656         return 0;
657     }
658     
659     //------------------------------------------------------------------
660     /// Get the minimum OS version this object file can run on.
661     ///
662     /// Some object files have information that specifies the minimum OS
663     /// version that they can be used on.
664     ///
665     /// If \a versions is NULL, or if \a num_versions is 0, the return
666     /// value will indicate how many version numbers are available in
667     /// this object file. Then a subsequent call can be made to this
668     /// function with a value of \a versions and \a num_versions that
669     /// has enough storage to store some or all version numbers.
670     ///
671     /// @param[out] versions
672     ///     A pointer to an array of uint32_t types that is \a num_versions
673     ///     long. If this value is NULL, the return value will indicate
674     ///     how many version numbers are required for a subsequent call
675     ///     to this function so that all versions can be retrieved. If
676     ///     the value is non-NULL, then at most \a num_versions of the
677     ///     existing versions numbers will be filled into \a versions.
678     ///     If there is no version information available, \a versions
679     ///     will be filled with \a num_versions UINT32_MAX values
680     ///     and zero will be returned.
681     ///
682     /// @param[in] num_versions
683     ///     The maximum number of entries to fill into \a versions. If
684     ///     this value is zero, then the return value will indicate
685     ///     how many version numbers there are in total so another call
686     ///     to this function can be make with adequate storage in
687     ///     \a versions to get all of the version numbers. If \a
688     ///     num_versions is less than the actual number of version
689     ///     numbers in this object file, only \a num_versions will be
690     ///     filled into \a versions (if \a versions is non-NULL).
691     ///
692     /// @return
693     ///     This function always returns the number of version numbers
694     ///     that this object file has regardless of the number of
695     ///     version numbers that were copied into \a versions.
696     //------------------------------------------------------------------
697     virtual uint32_t
698     GetMinimumOSVersion (uint32_t *versions, uint32_t num_versions)
699     {
700         if (versions && num_versions)
701         {
702             for (uint32_t i=0; i<num_versions; ++i)
703                 versions[i] = UINT32_MAX;
704         }
705         return 0;
706     }
707
708     //------------------------------------------------------------------
709     /// Get the SDK OS version this object file was built with.
710     ///
711     /// The versions arguments and returns values are the same as the
712     /// GetMinimumOSVersion()
713     //------------------------------------------------------------------
714     virtual uint32_t
715     GetSDKVersion (uint32_t *versions, uint32_t num_versions)
716     {
717         if (versions && num_versions)
718         {
719             for (uint32_t i=0; i<num_versions; ++i)
720                 versions[i] = UINT32_MAX;
721         }
722         return 0;
723     }
724
725     //------------------------------------------------------------------
726     // Member Functions
727     //------------------------------------------------------------------
728     Type
729     GetType ()
730     {
731         if (m_type == eTypeInvalid)
732             m_type = CalculateType();
733         return m_type;
734     }
735     
736     Strata
737     GetStrata ()
738     {
739         if (m_strata == eStrataInvalid)
740             m_strata = CalculateStrata();
741         return m_strata;
742     }
743     
744     // When an object file is in memory, subclasses should try and lock
745     // the process weak pointer. If the process weak pointer produces a
746     // valid ProcessSP, then subclasses can call this function to read
747     // memory.
748     static lldb::DataBufferSP
749     ReadMemory (const lldb::ProcessSP &process_sp, 
750                 lldb::addr_t addr, 
751                 size_t byte_size);
752
753     size_t
754     GetData (off_t offset, size_t length, DataExtractor &data) const;
755     
756     size_t
757     CopyData (off_t offset, size_t length, void *dst) const;
758     
759     size_t
760     ReadSectionData (const Section *section, 
761                      off_t section_offset, 
762                      void *dst, 
763                      size_t dst_len) const;
764     size_t
765     ReadSectionData (const Section *section, 
766                      DataExtractor& section_data) const;
767     
768     size_t
769     MemoryMapSectionData (const Section *section, 
770                           DataExtractor& section_data) const;
771     
772     bool
773     IsInMemory () const
774     {
775         return m_memory_addr != LLDB_INVALID_ADDRESS;
776     }
777     
778 protected:
779     //------------------------------------------------------------------
780     // Member variables.
781     //------------------------------------------------------------------
782     FileSpec m_file;
783     Type m_type;
784     Strata m_strata;
785     lldb::addr_t m_file_offset; ///< The offset in bytes into the file, or the address in memory
786     lldb::addr_t m_length; ///< The length of this object file if it is known (can be zero if length is unknown or can't be determined).
787     DataExtractor m_data; ///< The data for this object file so things can be parsed lazily.
788     lldb_private::UnwindTable m_unwind_table; /// < Table of FuncUnwinders objects created for this ObjectFile's functions
789     lldb::ProcessWP m_process_wp;
790     const lldb::addr_t m_memory_addr;
791     std::unique_ptr<lldb_private::SectionList> m_sections_ap;
792     std::unique_ptr<lldb_private::Symtab> m_symtab_ap;
793     
794     //------------------------------------------------------------------
795     /// Sets the architecture for a module.  At present the architecture
796     /// can only be set if it is invalid.  It is not allowed to switch from
797     /// one concrete architecture to another.
798     /// 
799     /// @param[in] new_arch
800     ///     The architecture this module will be set to.
801     ///
802     /// @return
803     ///     Returns \b true if the architecture was changed, \b
804     ///     false otherwise.
805     //------------------------------------------------------------------
806     bool SetModulesArchitecture (const ArchSpec &new_arch);
807
808 private:
809     DISALLOW_COPY_AND_ASSIGN (ObjectFile);
810 };
811
812 } // namespace lldb_private
813
814 #endif  // liblldb_ObjectFile_h_
815