1 //===-- ObjectFile.h --------------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef liblldb_ObjectFile_h_
11 #define liblldb_ObjectFile_h_
13 #include "lldb/Core/DataExtractor.h"
14 #include "lldb/Core/FileSpecList.h"
15 #include "lldb/Core/ModuleChild.h"
16 #include "lldb/Core/PluginInterface.h"
17 #include "lldb/Host/Endian.h"
18 #include "lldb/Host/FileSpec.h"
19 #include "lldb/Symbol/Symtab.h"
20 #include "lldb/Symbol/UnwindTable.h"
21 #include "lldb/lldb-private.h"
23 namespace lldb_private {
25 class ObjectFileJITDelegate {
27 ObjectFileJITDelegate() {}
29 virtual ~ObjectFileJITDelegate() {}
31 virtual lldb::ByteOrder GetByteOrder() const = 0;
33 virtual uint32_t GetAddressByteSize() const = 0;
35 virtual void PopulateSymtab(lldb_private::ObjectFile *obj_file,
36 lldb_private::Symtab &symtab) = 0;
38 virtual void PopulateSectionList(lldb_private::ObjectFile *obj_file,
39 lldb_private::SectionList §ion_list) = 0;
41 virtual bool GetArchitecture(lldb_private::ArchSpec &arch) = 0;
44 //----------------------------------------------------------------------
45 /// @class ObjectFile ObjectFile.h "lldb/Symbol/ObjectFile.h"
46 /// @brief A plug-in interface definition class for object file parsers.
48 /// Object files belong to Module objects and know how to extract
49 /// information from executable, shared library, and object (.o) files
50 /// used by operating system runtime. The symbol table and section list
51 /// for an object file.
53 /// Object files can be represented by the entire file, or by part of a
54 /// file. An example of a partial file ObjectFile is one that contains
55 /// information for one of multiple architectures in the same file.
57 /// Once an architecture is selected the object file information can be
58 /// extracted from this abstract class.
59 //----------------------------------------------------------------------
60 class ObjectFile : public std::enable_shared_from_this<ObjectFile>,
61 public PluginInterface,
63 friend class lldb_private::Module;
68 eTypeCoreFile, /// A core file that has a checkpoint of a program's
70 eTypeExecutable, /// A normal executable
71 eTypeDebugInfo, /// An object file that contains only debug information
72 eTypeDynamicLinker, /// The platform's dynamic linker executable
73 eTypeObjectFile, /// An intermediate object file
74 eTypeSharedLibrary, /// A shared library that can be used during execution
75 eTypeStubLibrary, /// A library that can be linked against but not used for
77 eTypeJIT, /// JIT code that has symbols, sections and possibly debug info
90 //------------------------------------------------------------------
91 /// Construct with a parent module, offset, and header data.
93 /// Object files belong to modules and a valid module must be
94 /// supplied upon construction. The at an offset within a file for
95 /// objects that contain more than one architecture or object.
96 //------------------------------------------------------------------
97 ObjectFile(const lldb::ModuleSP &module_sp, const FileSpec *file_spec_ptr,
98 lldb::offset_t file_offset, lldb::offset_t length,
99 const lldb::DataBufferSP &data_sp, lldb::offset_t data_offset);
101 ObjectFile(const lldb::ModuleSP &module_sp, const lldb::ProcessSP &process_sp,
102 lldb::addr_t header_addr, lldb::DataBufferSP &data_sp);
104 //------------------------------------------------------------------
107 /// The destructor is virtual since this class is designed to be
108 /// inherited from by the plug-in instance.
109 //------------------------------------------------------------------
110 ~ObjectFile() override;
112 //------------------------------------------------------------------
113 /// Dump a description of this object to a Stream.
115 /// Dump a description of the current contents of this object
116 /// to the supplied stream \a s. The dumping should include the
117 /// section list if it has been parsed, and the symbol table
118 /// if it has been parsed.
121 /// The stream to which to dump the object description.
122 //------------------------------------------------------------------
123 virtual void Dump(Stream *s) = 0;
125 //------------------------------------------------------------------
126 /// Find a ObjectFile plug-in that can parse \a file_spec.
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.
132 /// @param[in] module
133 /// The parent module that owns this object file.
135 /// @param[in] file_spec
136 /// A file specification that indicates which file to use as the
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.
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.
148 /// @see ObjectFile::ParseHeader()
149 //------------------------------------------------------------------
150 static lldb::ObjectFileSP
151 FindPlugin(const lldb::ModuleSP &module_sp, const FileSpec *file_spec,
152 lldb::offset_t file_offset, lldb::offset_t file_size,
153 lldb::DataBufferSP &data_sp, lldb::offset_t &data_offset);
155 //------------------------------------------------------------------
156 /// Find a ObjectFile plug-in that can parse a file in memory.
158 /// Scans all loaded plug-in interfaces that implement versions of
159 /// the ObjectFile plug-in interface and returns the first
160 /// instance that can parse the file.
162 /// @param[in] module
163 /// The parent module that owns this object file.
165 /// @param[in] process_sp
166 /// A shared pointer to the process whose memory space contains
167 /// an object file. This will be stored as a std::weak_ptr.
169 /// @param[in] header_addr
170 /// The address of the header for the object file in memory.
171 //------------------------------------------------------------------
172 static lldb::ObjectFileSP FindPlugin(const lldb::ModuleSP &module_sp,
173 const lldb::ProcessSP &process_sp,
174 lldb::addr_t header_addr,
175 lldb::DataBufferSP &file_data_sp);
177 static size_t GetModuleSpecifications(const FileSpec &file,
178 lldb::offset_t file_offset,
179 lldb::offset_t file_size,
180 ModuleSpecList &specs);
182 static size_t GetModuleSpecifications(const lldb_private::FileSpec &file,
183 lldb::DataBufferSP &data_sp,
184 lldb::offset_t data_offset,
185 lldb::offset_t file_offset,
186 lldb::offset_t file_size,
187 lldb_private::ModuleSpecList &specs);
188 //------------------------------------------------------------------
189 /// Split a path into a file path with object name.
191 /// For paths like "/tmp/foo.a(bar.o)" we often need to split a path
192 /// up into the actual path name and into the object name so we can
193 /// make a valid object file from it.
195 /// @param[in] path_with_object
196 /// A path that might contain an archive path with a .o file
197 /// specified in parens in the basename of the path.
199 /// @param[out] archive_file
200 /// If \b true is returned, \a file_spec will be filled in with
201 /// the path to the archive.
203 /// @param[out] archive_object
204 /// If \b true is returned, \a object will be filled in with
205 /// the name of the object inside the archive.
208 /// \b true if the path matches the pattern of archive + object
209 /// and \a archive_file and \a archive_object are modified,
210 /// \b false otherwise and \a archive_file and \a archive_object
211 /// are guaranteed to be remain unchanged.
212 //------------------------------------------------------------------
213 static bool SplitArchivePathWithObject(
214 const char *path_with_object, lldb_private::FileSpec &archive_file,
215 lldb_private::ConstString &archive_object, bool must_exist);
217 //------------------------------------------------------------------
218 /// Gets the address size in bytes for the current object file.
221 /// The size of an address in bytes for the currently selected
222 /// architecture (and object for archives). Returns zero if no
223 /// architecture or object has been selected.
224 //------------------------------------------------------------------
225 virtual uint32_t GetAddressByteSize() const = 0;
227 //------------------------------------------------------------------
228 /// Get the address type given a file address in an object file.
230 /// Many binary file formats know what kinds
231 /// This is primarily for ARM binaries, though it can be applied to
232 /// any executable file format that supports different opcode types
233 /// within the same binary. ARM binaries support having both ARM and
234 /// Thumb within the same executable container. We need to be able
237 /// The size of an address in bytes for the currently selected
238 /// architecture (and object for archives). Returns zero if no
239 /// architecture or object has been selected.
240 //------------------------------------------------------------------
241 virtual lldb::AddressClass GetAddressClass(lldb::addr_t file_addr);
243 //------------------------------------------------------------------
244 /// Extract the dependent modules from an object file.
246 /// If an object file has information about which other images it
247 /// depends on (such as shared libraries), this function will
248 /// provide the list. Since many executables or shared libraries
249 /// may depend on the same files,
250 /// FileSpecList::AppendIfUnique(const FileSpec &) should be
251 /// used to make sure any files that are added are not already in
254 /// @param[out] file_list
255 /// A list of file specification objects that gets dependent
256 /// files appended to.
259 /// The number of new files that were appended to \a file_list.
261 /// @see FileSpecList::AppendIfUnique(const FileSpec &)
262 //------------------------------------------------------------------
263 virtual uint32_t GetDependentModules(FileSpecList &file_list) = 0;
265 //------------------------------------------------------------------
266 /// Tells whether this object file is capable of being the main executable
270 /// \b true if it is, \b false otherwise.
271 //------------------------------------------------------------------
272 virtual bool IsExecutable() const = 0;
274 //------------------------------------------------------------------
275 /// Returns the offset into a file at which this object resides.
277 /// Some files contain many object files, and this function allows
278 /// access to an object's offset within the file.
281 /// The offset in bytes into the file. Defaults to zero for
282 /// simple object files that a represented by an entire file.
283 //------------------------------------------------------------------
284 virtual lldb::addr_t GetFileOffset() const { return m_file_offset; }
286 virtual lldb::addr_t GetByteSize() const { return m_length; }
288 //------------------------------------------------------------------
289 /// Get accessor to the object file specification.
292 /// The file specification object pointer if there is one, or
293 /// NULL if this object is only from memory.
294 //------------------------------------------------------------------
295 virtual FileSpec &GetFileSpec() { return m_file; }
297 //------------------------------------------------------------------
298 /// Get const accessor to the object file specification.
301 /// The const file specification object pointer if there is one,
302 /// or NULL if this object is only from memory.
303 //------------------------------------------------------------------
304 virtual const FileSpec &GetFileSpec() const { return m_file; }
306 //------------------------------------------------------------------
307 /// Get the name of the cpu, vendor and OS for this object file.
309 /// This value is a string that represents the target triple where
310 /// the cpu type, the vendor and the OS are encoded into a string.
312 /// @param[out] target_triple
313 /// The string value of the target triple.
316 /// \b True if the target triple was able to be computed, \b
318 //------------------------------------------------------------------
319 virtual bool GetArchitecture(ArchSpec &arch) = 0;
321 //------------------------------------------------------------------
322 /// Gets the section list for the currently selected architecture
323 /// (and object for archives).
325 /// Section list parsing can be deferred by ObjectFile instances
326 /// until this accessor is called the first time.
329 /// The list of sections contained in this object file.
330 //------------------------------------------------------------------
331 virtual SectionList *GetSectionList(bool update_module_section_list = true);
333 virtual void CreateSections(SectionList &unified_section_list) = 0;
335 //------------------------------------------------------------------
336 /// Notify the ObjectFile that the file addresses in the Sections
337 /// for this module have been changed.
338 //------------------------------------------------------------------
339 virtual void SectionFileAddressesChanged() {}
341 //------------------------------------------------------------------
342 /// Gets the symbol table for the currently selected architecture
343 /// (and object for archives).
345 /// Symbol table parsing can be deferred by ObjectFile instances
346 /// until this accessor is called the first time.
349 /// The symbol table for this object file.
350 //------------------------------------------------------------------
351 virtual Symtab *GetSymtab() = 0;
353 //------------------------------------------------------------------
354 /// Appends a Symbol for the specified so_addr to the symbol table.
356 /// If verify_unique is false, the symbol table is not searched
357 /// to determine if a Symbol found at this address has already been
358 /// added to the symbol table. When verify_unique is true, this
359 /// method resolves the Symbol as the first match in the SymbolTable
360 /// and appends a Symbol only if required/found.
363 /// The resolved symbol or nullptr. Returns nullptr if a
364 /// a Symbol could not be found for the specified so_addr.
365 //------------------------------------------------------------------
366 virtual Symbol *ResolveSymbolForAddress(const Address &so_addr,
367 bool verify_unique) {
368 // Typically overridden to lazily add stripped symbols recoverable from
369 // the exception handling unwind information (i.e. without parsing
370 // the entire eh_frame section.
372 // The availability of LC_FUNCTION_STARTS allows ObjectFileMachO
373 // to efficiently add stripped symbols when the symbol table is
374 // first constructed. Poorer cousins are PECoff and ELF.
378 //------------------------------------------------------------------
379 /// Detect if this object file has been stripped of local symbols.
380 //------------------------------------------------------------------
381 /// Detect if this object file has been stripped of local symbols.
384 /// Return \b true if the object file has been stripped of local
386 //------------------------------------------------------------------
387 virtual bool IsStripped() = 0;
389 //------------------------------------------------------------------
390 /// Frees the symbol table.
392 /// This function should only be used when an object file is
395 /// eSymtabFromUnifiedSectionList: Whether to clear symbol table
396 /// for unified module section list, or object file.
399 /// The symbol table for this object file.
400 //------------------------------------------------------------------
401 virtual void ClearSymtab();
403 //------------------------------------------------------------------
404 /// Gets the UUID for this object file.
406 /// If the object file format contains a UUID, the value should be
407 /// returned. Else ObjectFile instances should return the MD5
408 /// checksum of all of the bytes for the object file (or memory for
409 /// memory based object files).
412 /// Returns \b true if a UUID was successfully extracted into
413 /// \a uuid, \b false otherwise.
414 //------------------------------------------------------------------
415 virtual bool GetUUID(lldb_private::UUID *uuid) = 0;
417 //------------------------------------------------------------------
418 /// Gets the symbol file spec list for this object file.
420 /// If the object file format contains a debug symbol file link,
421 /// the values will be returned in the FileSpecList.
424 /// Returns filespeclist.
425 //------------------------------------------------------------------
426 virtual lldb_private::FileSpecList GetDebugSymbolFilePaths() {
427 return FileSpecList();
430 //------------------------------------------------------------------
431 /// Gets the file spec list of libraries re-exported by this object file.
433 /// If the object file format has the notion of one library re-exporting the
434 /// symbols from another,
435 /// the re-exported libraries will be returned in the FileSpecList.
438 /// Returns filespeclist.
439 //------------------------------------------------------------------
440 virtual lldb_private::FileSpecList GetReExportedLibraries() {
441 return FileSpecList();
444 //------------------------------------------------------------------
445 /// Sets the load address for an entire module, assuming a rigid
446 /// slide of sections, if possible in the implementation.
449 /// Returns true iff any section's load address changed.
450 //------------------------------------------------------------------
451 virtual bool SetLoadAddress(Target &target, lldb::addr_t value,
452 bool value_is_offset) {
456 //------------------------------------------------------------------
457 /// Gets whether endian swapping should occur when extracting data
458 /// from this object file.
461 /// Returns \b true if endian swapping is needed, \b false
463 //------------------------------------------------------------------
464 virtual lldb::ByteOrder GetByteOrder() const = 0;
466 //------------------------------------------------------------------
467 /// Attempts to parse the object header.
469 /// This function is used as a test to see if a given plug-in
470 /// instance can parse the header data already contained in
471 /// ObjectFile::m_data. If an object file parser does not
472 /// recognize that magic bytes in a header, false should be returned
473 /// and the next plug-in can attempt to parse an object file.
476 /// Returns \b true if the header was parsed successfully, \b
478 //------------------------------------------------------------------
479 virtual bool ParseHeader() = 0;
481 //------------------------------------------------------------------
482 /// Returns a reference to the UnwindTable for this ObjectFile
484 /// The UnwindTable contains FuncUnwinders objects for any function in
485 /// this ObjectFile. If a FuncUnwinders object hasn't been created yet
486 /// (i.e. the function has yet to be unwound in a stack walk), it
487 /// will be created when requested. Specifically, we do not create
488 /// FuncUnwinders objects for functions until they are needed.
491 /// Returns the unwind table for this object file.
492 //------------------------------------------------------------------
493 virtual lldb_private::UnwindTable &GetUnwindTable() { return m_unwind_table; }
495 //------------------------------------------------------------------
496 /// Returns if the function bounds for symbols in this symbol file
497 /// are likely accurate.
499 /// The unwinder can emulate the instructions of functions to understand
500 /// prologue/epilogue code sequences, where registers are spilled on
501 /// the stack, etc. This feature relies on having the correct start
502 /// addresses of all functions. If the ObjectFile has a way to tell
503 /// that symbols have been stripped and there's no way to reconstruct
504 /// start addresses (e.g. LC_FUNCTION_STARTS on Mach-O, or eh_frame
505 /// unwind info), the ObjectFile should indicate that assembly emulation
506 /// should not be used for this module.
508 /// It is uncommon for this to return false. An ObjectFile needs to
509 /// be sure that symbol start addresses are unavailable before false
510 /// is returned. If it is unclear, this should return true.
513 /// Returns true if assembly emulation should be used for this
515 /// Only returns false if the ObjectFile is sure that symbol
516 /// addresses are insufficient for accurate assembly emulation.
517 //------------------------------------------------------------------
518 virtual bool AllowAssemblyEmulationUnwindPlans() { return true; }
520 //------------------------------------------------------------------
521 /// Similar to Process::GetImageInfoAddress().
523 /// Some platforms embed auxiliary structures useful to debuggers in the
524 /// address space of the inferior process. This method returns the address
525 /// of such a structure if the information can be resolved via entries in
526 /// the object file. ELF, for example, provides a means to hook into the
527 /// runtime linker so that a debugger may monitor the loading and unloading
528 /// of shared libraries.
531 /// The address of any auxiliary tables, or an invalid address if this
532 /// object file format does not support or contain such information.
533 virtual lldb_private::Address GetImageInfoAddress(Target *target) {
537 //------------------------------------------------------------------
538 /// Returns the address of the Entry Point in this object file - if
539 /// the object file doesn't have an entry point (because it is not an
540 /// executable file) then an invalid address is returned.
543 /// Returns the entry address for this module.
544 //------------------------------------------------------------------
545 virtual lldb_private::Address GetEntryPointAddress() { return Address(); }
547 //------------------------------------------------------------------
548 /// Returns the address that represents the header of this object
551 /// The header address is defined as where the header for the object
552 /// file is that describes the content of the file. If the header
553 /// doesn't appear in a section that is defined in the object file,
554 /// an address with no section is returned that has the file offset
555 /// set in the m_file_offset member of the lldb_private::Address object.
558 /// Returns the entry address for this module.
559 //------------------------------------------------------------------
560 virtual lldb_private::Address GetHeaderAddress() {
561 return Address(m_memory_addr);
564 virtual uint32_t GetNumThreadContexts() { return 0; }
566 virtual lldb::RegisterContextSP
567 GetThreadContextAtIndex(uint32_t idx, lldb_private::Thread &thread) {
568 return lldb::RegisterContextSP();
571 //------------------------------------------------------------------
572 /// The object file should be able to calculate its type by looking
573 /// at its file header and possibly the sections or other data in
574 /// the object file. The file type is used in the debugger to help
575 /// select the correct plug-ins for the job at hand, so this is
576 /// important to get right. If any eTypeXXX definitions do not match
577 /// up with the type of file you are loading, please feel free to
578 /// add a new enumeration value.
581 /// The calculated file type for the current object file.
582 //------------------------------------------------------------------
583 virtual Type CalculateType() = 0;
585 //------------------------------------------------------------------
586 /// In cases where the type can't be calculated (elf files), this
587 /// routine allows someone to explicitly set it. As an example,
588 /// SymbolVendorELF uses this routine to set eTypeDebugInfo when
589 /// loading debug link files.
590 virtual void SetType(Type type) { m_type = type; }
592 //------------------------------------------------------------------
593 /// The object file should be able to calculate the strata of the
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.
602 /// The calculated object file strata for the current object
604 //------------------------------------------------------------------
605 virtual Strata CalculateStrata() = 0;
607 //------------------------------------------------------------------
608 /// Get the object file version numbers.
610 /// Many object files have a set of version numbers that describe
611 /// the version of the executable or shared library. Typically there
612 /// are major, minor and build, but there may be more. This function
613 /// will extract the versions from object files if they are available.
615 /// If \a versions is NULL, or if \a num_versions is 0, the return
616 /// value will indicate how many version numbers are available in
617 /// this object file. Then a subsequent call can be made to this
618 /// function with a value of \a versions and \a num_versions that
619 /// has enough storage to store some or all version numbers.
621 /// @param[out] versions
622 /// A pointer to an array of uint32_t types that is \a num_versions
623 /// long. If this value is NULL, the return value will indicate
624 /// how many version numbers are required for a subsequent call
625 /// to this function so that all versions can be retrieved. If
626 /// the value is non-NULL, then at most \a num_versions of the
627 /// existing versions numbers will be filled into \a versions.
628 /// If there is no version information available, \a versions
629 /// will be filled with \a num_versions UINT32_MAX values
630 /// and zero will be returned.
632 /// @param[in] num_versions
633 /// The maximum number of entries to fill into \a versions. If
634 /// this value is zero, then the return value will indicate
635 /// how many version numbers there are in total so another call
636 /// to this function can be make with adequate storage in
637 /// \a versions to get all of the version numbers. If \a
638 /// num_versions is less than the actual number of version
639 /// numbers in this object file, only \a num_versions will be
640 /// filled into \a versions (if \a versions is non-NULL).
643 /// This function always returns the number of version numbers
644 /// that this object file has regardless of the number of
645 /// version numbers that were copied into \a versions.
646 //------------------------------------------------------------------
647 virtual uint32_t GetVersion(uint32_t *versions, uint32_t num_versions) {
648 if (versions && num_versions) {
649 for (uint32_t i = 0; i < num_versions; ++i)
650 versions[i] = UINT32_MAX;
655 //------------------------------------------------------------------
656 /// Get the minimum OS version this object file can run on.
658 /// Some object files have information that specifies the minimum OS
659 /// version that they can be used on.
661 /// If \a versions is NULL, or if \a num_versions is 0, the return
662 /// value will indicate how many version numbers are available in
663 /// this object file. Then a subsequent call can be made to this
664 /// function with a value of \a versions and \a num_versions that
665 /// has enough storage to store some or all version numbers.
667 /// @param[out] versions
668 /// A pointer to an array of uint32_t types that is \a num_versions
669 /// long. If this value is NULL, the return value will indicate
670 /// how many version numbers are required for a subsequent call
671 /// to this function so that all versions can be retrieved. If
672 /// the value is non-NULL, then at most \a num_versions of the
673 /// existing versions numbers will be filled into \a versions.
674 /// If there is no version information available, \a versions
675 /// will be filled with \a num_versions UINT32_MAX values
676 /// and zero will be returned.
678 /// @param[in] num_versions
679 /// The maximum number of entries to fill into \a versions. If
680 /// this value is zero, then the return value will indicate
681 /// how many version numbers there are in total so another call
682 /// to this function can be make with adequate storage in
683 /// \a versions to get all of the version numbers. If \a
684 /// num_versions is less than the actual number of version
685 /// numbers in this object file, only \a num_versions will be
686 /// filled into \a versions (if \a versions is non-NULL).
689 /// This function always returns the number of version numbers
690 /// that this object file has regardless of the number of
691 /// version numbers that were copied into \a versions.
692 //------------------------------------------------------------------
693 virtual uint32_t GetMinimumOSVersion(uint32_t *versions,
694 uint32_t num_versions) {
695 if (versions && num_versions) {
696 for (uint32_t i = 0; i < num_versions; ++i)
697 versions[i] = UINT32_MAX;
702 //------------------------------------------------------------------
703 /// Get the SDK OS version this object file was built with.
705 /// The versions arguments and returns values are the same as the
706 /// GetMinimumOSVersion()
707 //------------------------------------------------------------------
708 virtual uint32_t GetSDKVersion(uint32_t *versions, uint32_t num_versions) {
709 if (versions && num_versions) {
710 for (uint32_t i = 0; i < num_versions; ++i)
711 versions[i] = UINT32_MAX;
716 //------------------------------------------------------------------
717 /// Return true if this file is a dynamic link editor (dyld)
719 /// Often times dyld has symbols that mirror symbols in libc and
720 /// other shared libraries (like "malloc" and "free") and the user
721 /// does _not_ want to stop in these shared libraries by default.
722 /// We can ask the ObjectFile if it is such a file and should be
723 /// avoided for things like settings breakpoints and doing function
724 /// lookups for expressions.
725 //------------------------------------------------------------------
726 virtual bool GetIsDynamicLinkEditor() { return false; }
728 //------------------------------------------------------------------
730 //------------------------------------------------------------------
732 if (m_type == eTypeInvalid)
733 m_type = CalculateType();
738 if (m_strata == eStrataInvalid)
739 m_strata = CalculateStrata();
743 // When an object file is in memory, subclasses should try and lock
744 // the process weak pointer. If the process weak pointer produces a
745 // valid ProcessSP, then subclasses can call this function to read
747 static lldb::DataBufferSP ReadMemory(const lldb::ProcessSP &process_sp,
748 lldb::addr_t addr, size_t byte_size);
750 size_t GetData(lldb::offset_t offset, size_t length,
751 DataExtractor &data) const;
753 size_t CopyData(lldb::offset_t offset, size_t length, void *dst) const;
755 virtual size_t ReadSectionData(const Section *section,
756 lldb::offset_t section_offset, void *dst,
757 size_t dst_len) const;
759 virtual size_t ReadSectionData(const Section *section,
760 DataExtractor §ion_data) const;
762 size_t MemoryMapSectionData(const Section *section,
763 DataExtractor §ion_data) const;
765 bool IsInMemory() const { return m_memory_addr != LLDB_INVALID_ADDRESS; }
767 // Strip linker annotations (such as @@VERSION) from symbol names.
769 StripLinkerSymbolAnnotations(llvm::StringRef symbol_name) const {
770 return symbol_name.str();
773 static lldb::SymbolType GetSymbolTypeFromName(
774 llvm::StringRef name,
775 lldb::SymbolType symbol_type_hint = lldb::eSymbolTypeUndefined);
778 //------------------------------------------------------------------
780 //------------------------------------------------------------------
784 lldb::addr_t m_file_offset; ///< The offset in bytes into the file, or the
786 lldb::addr_t m_length; ///< The length of this object file if it is known (can
787 ///be zero if length is unknown or can't be
790 m_data; ///< The data for this object file so things can be parsed lazily.
791 lldb_private::UnwindTable m_unwind_table; /// < Table of FuncUnwinders objects
792 /// created for this ObjectFile's
794 lldb::ProcessWP m_process_wp;
795 const lldb::addr_t m_memory_addr;
796 std::unique_ptr<lldb_private::SectionList> m_sections_ap;
797 std::unique_ptr<lldb_private::Symtab> m_symtab_ap;
798 uint32_t m_synthetic_symbol_idx;
800 //------------------------------------------------------------------
801 /// Sets the architecture for a module. At present the architecture
802 /// can only be set if it is invalid. It is not allowed to switch from
803 /// one concrete architecture to another.
805 /// @param[in] new_arch
806 /// The architecture this module will be set to.
809 /// Returns \b true if the architecture was changed, \b
811 //------------------------------------------------------------------
812 bool SetModulesArchitecture(const ArchSpec &new_arch);
814 ConstString GetNextSyntheticSymbolName();
817 DISALLOW_COPY_AND_ASSIGN(ObjectFile);
820 } // namespace lldb_private
822 #endif // liblldb_ObjectFile_h_