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/FileSpecList.h"
14 #include "lldb/Core/ModuleChild.h"
15 #include "lldb/Core/PluginInterface.h"
16 #include "lldb/Symbol/Symtab.h"
17 #include "lldb/Symbol/UnwindTable.h"
18 #include "lldb/Utility/DataExtractor.h"
19 #include "lldb/Utility/Endian.h"
20 #include "lldb/Utility/FileSpec.h"
21 #include "lldb/Utility/UUID.h"
22 #include "lldb/lldb-private.h"
23 #include "llvm/Support/VersionTuple.h"
25 namespace lldb_private {
27 class ObjectFileJITDelegate {
29 ObjectFileJITDelegate() {}
31 virtual ~ObjectFileJITDelegate() {}
33 virtual lldb::ByteOrder GetByteOrder() const = 0;
35 virtual uint32_t GetAddressByteSize() const = 0;
37 virtual void PopulateSymtab(lldb_private::ObjectFile *obj_file,
38 lldb_private::Symtab &symtab) = 0;
40 virtual void PopulateSectionList(lldb_private::ObjectFile *obj_file,
41 lldb_private::SectionList §ion_list) = 0;
43 virtual ArchSpec GetArchitecture() = 0;
46 //----------------------------------------------------------------------
47 /// @class ObjectFile ObjectFile.h "lldb/Symbol/ObjectFile.h"
48 /// A plug-in interface definition class for object file parsers.
50 /// Object files belong to Module objects and know how to extract information
51 /// from executable, shared library, and object (.o) files used by operating
52 /// system runtime. The symbol table and section list for an object file.
54 /// Object files can be represented by the entire file, or by part of a file.
55 /// An example of a partial file ObjectFile is one that contains information
56 /// for one of multiple architectures in the same file.
58 /// Once an architecture is selected the object file information can be
59 /// extracted from this abstract class.
60 //----------------------------------------------------------------------
61 class ObjectFile : public std::enable_shared_from_this<ObjectFile>,
62 public PluginInterface,
64 friend class lldb_private::Module;
69 eTypeCoreFile, /// A core file that has a checkpoint of a program's
71 eTypeExecutable, /// A normal executable
72 eTypeDebugInfo, /// An object file that contains only debug information
73 eTypeDynamicLinker, /// The platform's dynamic linker executable
74 eTypeObjectFile, /// An intermediate object file
75 eTypeSharedLibrary, /// A shared library that can be used during execution
76 eTypeStubLibrary, /// A library that can be linked against but not used for
78 eTypeJIT, /// JIT code that has symbols, sections and possibly debug info
93 llvm::ArrayRef<uint8_t> Contents;
96 //------------------------------------------------------------------
97 /// Construct with a parent module, offset, and header data.
99 /// Object files belong to modules and a valid module must be supplied upon
100 /// construction. The at an offset within a file for objects that contain
101 /// more than one architecture or object.
102 //------------------------------------------------------------------
103 ObjectFile(const lldb::ModuleSP &module_sp, const FileSpec *file_spec_ptr,
104 lldb::offset_t file_offset, lldb::offset_t length,
105 const lldb::DataBufferSP &data_sp, lldb::offset_t data_offset);
107 ObjectFile(const lldb::ModuleSP &module_sp, const lldb::ProcessSP &process_sp,
108 lldb::addr_t header_addr, lldb::DataBufferSP &data_sp);
110 //------------------------------------------------------------------
113 /// The destructor is virtual since this class is designed to be inherited
114 /// from by the plug-in instance.
115 //------------------------------------------------------------------
116 ~ObjectFile() override;
118 //------------------------------------------------------------------
119 /// Dump a description of this object to a Stream.
121 /// Dump a description of the current contents of this object to the
122 /// supplied stream \a s. The dumping should include the section list if it
123 /// has been parsed, and the symbol table if it has been parsed.
126 /// The stream to which to dump the object description.
127 //------------------------------------------------------------------
128 virtual void Dump(Stream *s) = 0;
130 //------------------------------------------------------------------
131 /// Find a ObjectFile plug-in that can parse \a file_spec.
133 /// Scans all loaded plug-in interfaces that implement versions of the
134 /// ObjectFile plug-in interface and returns the first instance that can
137 /// @param[in] module
138 /// The parent module that owns this object file.
140 /// @param[in] file_spec
141 /// A file specification that indicates which file to use as the
144 /// @param[in] file_offset
145 /// The offset into the file at which to start parsing the
146 /// object. This is for files that contain multiple
147 /// architectures or objects.
149 /// @param[in] file_size
150 /// The size of the current object file if it can be determined
151 /// or if it is known. This can be zero.
153 /// @see ObjectFile::ParseHeader()
154 //------------------------------------------------------------------
155 static lldb::ObjectFileSP
156 FindPlugin(const lldb::ModuleSP &module_sp, const FileSpec *file_spec,
157 lldb::offset_t file_offset, lldb::offset_t file_size,
158 lldb::DataBufferSP &data_sp, lldb::offset_t &data_offset);
160 //------------------------------------------------------------------
161 /// Find a ObjectFile plug-in that can parse a file in memory.
163 /// Scans all loaded plug-in interfaces that implement versions of the
164 /// ObjectFile plug-in interface and returns the first instance that can
167 /// @param[in] module
168 /// The parent module that owns this object file.
170 /// @param[in] process_sp
171 /// A shared pointer to the process whose memory space contains
172 /// an object file. This will be stored as a std::weak_ptr.
174 /// @param[in] header_addr
175 /// The address of the header for the object file in memory.
176 //------------------------------------------------------------------
177 static lldb::ObjectFileSP FindPlugin(const lldb::ModuleSP &module_sp,
178 const lldb::ProcessSP &process_sp,
179 lldb::addr_t header_addr,
180 lldb::DataBufferSP &file_data_sp);
182 static size_t GetModuleSpecifications(const FileSpec &file,
183 lldb::offset_t file_offset,
184 lldb::offset_t file_size,
185 ModuleSpecList &specs);
187 static size_t GetModuleSpecifications(const lldb_private::FileSpec &file,
188 lldb::DataBufferSP &data_sp,
189 lldb::offset_t data_offset,
190 lldb::offset_t file_offset,
191 lldb::offset_t file_size,
192 lldb_private::ModuleSpecList &specs);
193 //------------------------------------------------------------------
194 /// Split a path into a file path with object name.
196 /// For paths like "/tmp/foo.a(bar.o)" we often need to split a path up into
197 /// the actual path name and into the object name so we can make a valid
198 /// object file from it.
200 /// @param[in] path_with_object
201 /// A path that might contain an archive path with a .o file
202 /// specified in parens in the basename of the path.
204 /// @param[out] archive_file
205 /// If \b true is returned, \a file_spec will be filled in with
206 /// the path to the archive.
208 /// @param[out] archive_object
209 /// If \b true is returned, \a object will be filled in with
210 /// the name of the object inside the archive.
213 /// \b true if the path matches the pattern of archive + object
214 /// and \a archive_file and \a archive_object are modified,
215 /// \b false otherwise and \a archive_file and \a archive_object
216 /// are guaranteed to be remain unchanged.
217 //------------------------------------------------------------------
218 static bool SplitArchivePathWithObject(
219 const char *path_with_object, lldb_private::FileSpec &archive_file,
220 lldb_private::ConstString &archive_object, bool must_exist);
222 //------------------------------------------------------------------
223 /// Gets the address size in bytes for the current object file.
226 /// The size of an address in bytes for the currently selected
227 /// architecture (and object for archives). Returns zero if no
228 /// architecture or object has been selected.
229 //------------------------------------------------------------------
230 virtual uint32_t GetAddressByteSize() const = 0;
232 //------------------------------------------------------------------
233 /// Get the address type given a file address in an object file.
235 /// Many binary file formats know what kinds This is primarily for ARM
236 /// binaries, though it can be applied to any executable file format that
237 /// supports different opcode types within the same binary. ARM binaries
238 /// support having both ARM and Thumb within the same executable container.
239 /// We need to be able to get @return
240 /// The size of an address in bytes for the currently selected
241 /// architecture (and object for archives). Returns zero if no
242 /// architecture or object has been selected.
243 //------------------------------------------------------------------
244 virtual AddressClass GetAddressClass(lldb::addr_t file_addr);
246 //------------------------------------------------------------------
247 /// Extract the dependent modules from an object file.
249 /// If an object file has information about which other images it depends on
250 /// (such as shared libraries), this function will provide the list. Since
251 /// many executables or shared libraries may depend on the same files,
252 /// FileSpecList::AppendIfUnique(const FileSpec &) should be used to make
253 /// sure any files that are added are not already in the list.
255 /// @param[out] file_list
256 /// A list of file specification objects that gets dependent
257 /// files appended to.
260 /// The number of new files that were appended to \a file_list.
262 /// @see FileSpecList::AppendIfUnique(const FileSpec &)
263 //------------------------------------------------------------------
264 virtual uint32_t GetDependentModules(FileSpecList &file_list) = 0;
266 //------------------------------------------------------------------
267 /// Tells whether this object file is capable of being the main executable
271 /// \b true if it is, \b false otherwise.
272 //------------------------------------------------------------------
273 virtual bool IsExecutable() const = 0;
275 //------------------------------------------------------------------
276 /// Returns the offset into a file at which this object resides.
278 /// Some files contain many object files, and this function allows access to
279 /// an object's offset within the file.
282 /// The offset in bytes into the file. Defaults to zero for
283 /// simple object files that a represented by an entire file.
284 //------------------------------------------------------------------
285 virtual lldb::addr_t GetFileOffset() const { return m_file_offset; }
287 virtual lldb::addr_t GetByteSize() const { return m_length; }
289 //------------------------------------------------------------------
290 /// Get accessor to the object file specification.
293 /// The file specification object pointer if there is one, or
294 /// NULL if this object is only from memory.
295 //------------------------------------------------------------------
296 virtual FileSpec &GetFileSpec() { return m_file; }
298 //------------------------------------------------------------------
299 /// Get const accessor to the object file specification.
302 /// The const file specification object pointer if there is one,
303 /// or NULL if this object is only from memory.
304 //------------------------------------------------------------------
305 virtual const FileSpec &GetFileSpec() const { return m_file; }
307 //------------------------------------------------------------------
308 /// Get the ArchSpec for this object file.
311 /// The ArchSpec of this object file. In case of error, an invalid
312 /// ArchSpec object is returned.
313 //------------------------------------------------------------------
314 virtual ArchSpec GetArchitecture() = 0;
316 //------------------------------------------------------------------
317 /// Gets the section list for the currently selected architecture (and
318 /// object for archives).
320 /// Section list parsing can be deferred by ObjectFile instances until this
321 /// accessor is called the first time.
324 /// The list of sections contained in this object file.
325 //------------------------------------------------------------------
326 virtual SectionList *GetSectionList(bool update_module_section_list = true);
328 virtual void CreateSections(SectionList &unified_section_list) = 0;
330 //------------------------------------------------------------------
331 /// Notify the ObjectFile that the file addresses in the Sections for this
332 /// module have been changed.
333 //------------------------------------------------------------------
334 virtual void SectionFileAddressesChanged() {}
336 //------------------------------------------------------------------
337 /// Gets the symbol table for the currently selected architecture (and
338 /// object for archives).
340 /// Symbol table parsing can be deferred by ObjectFile instances until this
341 /// accessor is called the first time.
344 /// The symbol table for this object file.
345 //------------------------------------------------------------------
346 virtual Symtab *GetSymtab() = 0;
348 //------------------------------------------------------------------
349 /// Perform relocations on the section if necessary.
351 //------------------------------------------------------------------
352 virtual void RelocateSection(lldb_private::Section *section);
354 //------------------------------------------------------------------
355 /// Appends a Symbol for the specified so_addr to the symbol table.
357 /// If verify_unique is false, the symbol table is not searched to determine
358 /// if a Symbol found at this address has already been added to the symbol
359 /// table. When verify_unique is true, this method resolves the Symbol as
360 /// the first match in the SymbolTable and appends a Symbol only if
364 /// The resolved symbol or nullptr. Returns nullptr if a
365 /// a Symbol could not be found for the specified so_addr.
366 //------------------------------------------------------------------
367 virtual Symbol *ResolveSymbolForAddress(const Address &so_addr,
368 bool verify_unique) {
369 // Typically overridden to lazily add stripped symbols recoverable from the
370 // exception handling unwind information (i.e. without parsing the entire
373 // The availability of LC_FUNCTION_STARTS allows ObjectFileMachO to
374 // efficiently add stripped symbols when the symbol table is first
375 // constructed. Poorer cousins are PECoff and ELF.
379 //------------------------------------------------------------------
380 /// Detect if this object file has been stripped of local symbols.
381 //------------------------------------------------------------------
382 /// Detect if this object file has been stripped of local symbols.
385 /// Return \b true if the object file has been stripped of local
387 //------------------------------------------------------------------
388 virtual bool IsStripped() = 0;
390 //------------------------------------------------------------------
391 /// Frees the symbol table.
393 /// This function should only be used when an object file is
396 /// eSymtabFromUnifiedSectionList: Whether to clear symbol table
397 /// for unified module section list, or object file.
400 /// The symbol table for this object file.
401 //------------------------------------------------------------------
402 virtual void ClearSymtab();
404 //------------------------------------------------------------------
405 /// Gets the UUID for this object file.
407 /// If the object file format contains a UUID, the value should be returned.
408 /// Else ObjectFile instances should return the MD5 checksum of all of the
409 /// bytes for the object file (or memory for 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, the values
421 /// 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, the re-exported libraries will be returned in the
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 slide of
446 /// 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 from this
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 instance can
470 /// parse the header data already contained in ObjectFile::m_data. If an
471 /// object file parser does not recognize that magic bytes in a header,
472 /// false should be returned and the next plug-in can attempt to parse an
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 this
485 /// ObjectFile. If a FuncUnwinders object hasn't been created yet (i.e. the
486 /// function has yet to be unwound in a stack walk), it will be created when
487 /// requested. Specifically, we do not create FuncUnwinders objects for
488 /// 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 are
499 /// The unwinder can emulate the instructions of functions to understand
500 /// prologue/epilogue code sequences, where registers are spilled on the
501 /// stack, etc. This feature relies on having the correct start addresses
502 /// of all functions. If the ObjectFile has a way to tell that symbols have
503 /// been stripped and there's no way to reconstruct start addresses (e.g.
504 /// LC_FUNCTION_STARTS on Mach-O, or eh_frame unwind info), the ObjectFile
505 /// should indicate that assembly emulation should not be used for this
508 /// It is uncommon for this to return false. An ObjectFile needs to be sure
509 /// that symbol start addresses are unavailable before false is returned.
510 /// 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 the
539 /// object file doesn't have an entry point (because it is not an executable
540 /// 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 base address of this object file.
550 /// This also sometimes referred to as the "preferred load address" or the
551 /// "image base address". Addresses within object files are often expressed
552 /// relative to this base. If this address corresponds to a specific section
553 /// (usually the first byte of the first section) then the returned address
554 /// will have this section set. Otherwise, the address will just have the
555 /// offset member filled in, indicating that this represents a file address.
556 //------------------------------------------------------------------
557 virtual lldb_private::Address GetBaseAddress() {
558 return Address(m_memory_addr);
561 virtual uint32_t GetNumThreadContexts() { return 0; }
563 //------------------------------------------------------------------
564 /// Some object files may have an identifier string embedded in them, e.g.
565 /// in a Mach-O core file using the LC_IDENT load command (which is
566 /// obsolete, but can still be found in some old files)
569 /// Returns the identifier string if one exists, else an empty
571 //------------------------------------------------------------------
572 virtual std::string GetIdentifierString () {
573 return std::string();
576 //------------------------------------------------------------------
577 /// When the ObjectFile is a core file, lldb needs to locate the "binary" in
578 /// the core file. lldb can iterate over the pages looking for a valid
579 /// binary, but some core files may have metadata describing where the main
580 /// binary is exactly which removes ambiguity when there are multiple
581 /// binaries present in the captured memory pages.
583 /// @param[out] address
584 /// If the address of the binary is specified, this will be set.
585 /// This is an address is the virtual address space of the core file
586 /// memory segments; it is not an offset into the object file.
587 /// If no address is available, will be set to LLDB_INVALID_ADDRESS.
590 /// If the uuid of the binary is specified, this will be set.
591 /// If no UUID is available, will be cleared.
594 /// Returns true if either address or uuid has been set.
595 //------------------------------------------------------------------
596 virtual bool GetCorefileMainBinaryInfo (lldb::addr_t &address, UUID &uuid) {
597 address = LLDB_INVALID_ADDRESS;
602 virtual lldb::RegisterContextSP
603 GetThreadContextAtIndex(uint32_t idx, lldb_private::Thread &thread) {
604 return lldb::RegisterContextSP();
607 //------------------------------------------------------------------
608 /// The object file should be able to calculate its type by looking at its
609 /// file header and possibly the sections or other data in the object file.
610 /// The file type is used in the debugger to help select the correct plug-
611 /// ins for the job at hand, so this is important to get right. If any
612 /// eTypeXXX definitions do not match up with the type of file you are
613 /// loading, please feel free to add a new enumeration value.
616 /// The calculated file type for the current object file.
617 //------------------------------------------------------------------
618 virtual Type CalculateType() = 0;
620 //------------------------------------------------------------------
621 /// In cases where the type can't be calculated (elf files), this routine
622 /// allows someone to explicitly set it. As an example, SymbolVendorELF uses
623 /// this routine to set eTypeDebugInfo when loading debug link files.
624 virtual void SetType(Type type) { m_type = type; }
626 //------------------------------------------------------------------
627 /// The object file should be able to calculate the strata of the object
630 /// Many object files for platforms might be for either user space debugging
631 /// or for kernel debugging. If your object file subclass can figure this
632 /// out, it will help with debugger plug-in selection when it comes time to
636 /// The calculated object file strata for the current object
638 //------------------------------------------------------------------
639 virtual Strata CalculateStrata() = 0;
641 //------------------------------------------------------------------
642 /// Get the object file version numbers.
644 /// Many object files have a set of version numbers that describe the
645 /// version of the executable or shared library. Typically there are major,
646 /// minor and build, but there may be more. This function will extract the
647 /// versions from object files if they are available.
650 /// This function returns extracted version numbers as a
651 /// llvm::VersionTuple. In case of error an empty VersionTuple is
653 //------------------------------------------------------------------
654 virtual llvm::VersionTuple GetVersion() { return llvm::VersionTuple(); }
656 //------------------------------------------------------------------
657 /// Get the minimum OS version this object file can run on.
659 /// Some object files have information that specifies the minimum OS version
660 /// that they can be used on.
663 /// This function returns extracted version numbers as a
664 /// llvm::VersionTuple. In case of error an empty VersionTuple is
666 //------------------------------------------------------------------
667 virtual llvm::VersionTuple GetMinimumOSVersion() {
668 return llvm::VersionTuple();
671 //------------------------------------------------------------------
672 /// Get the SDK OS version this object file was built with.
674 /// The versions arguments and returns values are the same as the
675 /// GetMinimumOSVersion()
676 //------------------------------------------------------------------
677 virtual uint32_t GetSDKVersion(uint32_t *versions, uint32_t num_versions) {
678 if (versions && num_versions) {
679 for (uint32_t i = 0; i < num_versions; ++i)
680 versions[i] = UINT32_MAX;
685 //------------------------------------------------------------------
686 /// Return true if this file is a dynamic link editor (dyld)
688 /// Often times dyld has symbols that mirror symbols in libc and other
689 /// shared libraries (like "malloc" and "free") and the user does _not_ want
690 /// to stop in these shared libraries by default. We can ask the ObjectFile
691 /// if it is such a file and should be avoided for things like settings
692 /// breakpoints and doing function lookups for expressions.
693 //------------------------------------------------------------------
694 virtual bool GetIsDynamicLinkEditor() { return false; }
696 //------------------------------------------------------------------
698 //------------------------------------------------------------------
700 if (m_type == eTypeInvalid)
701 m_type = CalculateType();
706 if (m_strata == eStrataInvalid)
707 m_strata = CalculateStrata();
711 // When an object file is in memory, subclasses should try and lock the
712 // process weak pointer. If the process weak pointer produces a valid
713 // ProcessSP, then subclasses can call this function to read memory.
714 static lldb::DataBufferSP ReadMemory(const lldb::ProcessSP &process_sp,
715 lldb::addr_t addr, size_t byte_size);
717 // This function returns raw file contents. Do not use it if you want
718 // transparent decompression of section contents.
719 size_t GetData(lldb::offset_t offset, size_t length,
720 DataExtractor &data) const;
722 // This function returns raw file contents. Do not use it if you want
723 // transparent decompression of section contents.
724 size_t CopyData(lldb::offset_t offset, size_t length, void *dst) const;
726 // This function will transparently decompress section data if the section if
728 virtual size_t ReadSectionData(Section *section,
729 lldb::offset_t section_offset, void *dst,
732 // This function will transparently decompress section data if the section if
733 // compressed. Note that for compressed section the resulting data size may
734 // be larger than what Section::GetFileSize reports.
735 virtual size_t ReadSectionData(Section *section,
736 DataExtractor §ion_data);
738 bool IsInMemory() const { return m_memory_addr != LLDB_INVALID_ADDRESS; }
740 // Strip linker annotations (such as @@VERSION) from symbol names.
741 virtual llvm::StringRef
742 StripLinkerSymbolAnnotations(llvm::StringRef symbol_name) const {
746 static lldb::SymbolType GetSymbolTypeFromName(
747 llvm::StringRef name,
748 lldb::SymbolType symbol_type_hint = lldb::eSymbolTypeUndefined);
750 //------------------------------------------------------------------
751 /// Loads this objfile to memory.
753 /// Loads the bits needed to create an executable image to the memory. It is
754 /// useful with bare-metal targets where target does not have the ability to
755 /// start a process itself.
757 /// @param[in] target
758 /// Target where to load.
761 //------------------------------------------------------------------
762 virtual std::vector<LoadableData> GetLoadableData(Target &target);
765 //------------------------------------------------------------------
767 //------------------------------------------------------------------
771 lldb::addr_t m_file_offset; ///< The offset in bytes into the file, or the
773 lldb::addr_t m_length; ///< The length of this object file if it is known (can
774 ///be zero if length is unknown or can't be
777 m_data; ///< The data for this object file so things can be parsed lazily.
778 lldb_private::UnwindTable m_unwind_table; /// < Table of FuncUnwinders objects
779 /// created for this ObjectFile's
781 lldb::ProcessWP m_process_wp;
782 const lldb::addr_t m_memory_addr;
783 std::unique_ptr<lldb_private::SectionList> m_sections_ap;
784 std::unique_ptr<lldb_private::Symtab> m_symtab_ap;
785 uint32_t m_synthetic_symbol_idx;
787 //------------------------------------------------------------------
788 /// Sets the architecture for a module. At present the architecture can
789 /// only be set if it is invalid. It is not allowed to switch from one
790 /// concrete architecture to another.
792 /// @param[in] new_arch
793 /// The architecture this module will be set to.
796 /// Returns \b true if the architecture was changed, \b
798 //------------------------------------------------------------------
799 bool SetModulesArchitecture(const ArchSpec &new_arch);
801 ConstString GetNextSyntheticSymbolName();
803 static lldb::DataBufferSP MapFileData(const FileSpec &file, uint64_t Size,
807 DISALLOW_COPY_AND_ASSIGN(ObjectFile);
810 } // namespace lldb_private
813 template <> struct format_provider<lldb_private::ObjectFile::Type> {
814 static void format(const lldb_private::ObjectFile::Type &type,
815 raw_ostream &OS, StringRef Style);
818 template <> struct format_provider<lldb_private::ObjectFile::Strata> {
819 static void format(const lldb_private::ObjectFile::Strata &strata,
820 raw_ostream &OS, StringRef Style);
824 #endif // liblldb_ObjectFile_h_