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 bool GetArchitecture(lldb_private::ArchSpec &arch) = 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 name of the cpu, vendor and OS for this object file.
310 /// This value is a string that represents the target triple where the cpu
311 /// type, the vendor and the OS are encoded into a string.
313 /// @param[out] target_triple
314 /// The string value of the target triple.
317 /// \b True if the target triple was able to be computed, \b
319 //------------------------------------------------------------------
320 virtual bool GetArchitecture(ArchSpec &arch) = 0;
322 //------------------------------------------------------------------
323 /// Gets the section list for the currently selected architecture (and
324 /// object for archives).
326 /// Section list parsing can be deferred by ObjectFile instances until this
327 /// accessor is called the first time.
330 /// The list of sections contained in this object file.
331 //------------------------------------------------------------------
332 virtual SectionList *GetSectionList(bool update_module_section_list = true);
334 virtual void CreateSections(SectionList &unified_section_list) = 0;
336 //------------------------------------------------------------------
337 /// Notify the ObjectFile that the file addresses in the Sections for this
338 /// module have been changed.
339 //------------------------------------------------------------------
340 virtual void SectionFileAddressesChanged() {}
342 //------------------------------------------------------------------
343 /// Gets the symbol table for the currently selected architecture (and
344 /// object for archives).
346 /// Symbol table parsing can be deferred by ObjectFile instances until this
347 /// accessor is called the first time.
350 /// The symbol table for this object file.
351 //------------------------------------------------------------------
352 virtual Symtab *GetSymtab() = 0;
354 //------------------------------------------------------------------
355 /// Perform relocations on the section if necessary.
357 //------------------------------------------------------------------
358 virtual void RelocateSection(lldb_private::Section *section);
360 //------------------------------------------------------------------
361 /// Appends a Symbol for the specified so_addr to the symbol table.
363 /// If verify_unique is false, the symbol table is not searched to determine
364 /// if a Symbol found at this address has already been added to the symbol
365 /// table. When verify_unique is true, this method resolves the Symbol as
366 /// the first match in the SymbolTable and appends a Symbol only if
370 /// The resolved symbol or nullptr. Returns nullptr if a
371 /// a Symbol could not be found for the specified so_addr.
372 //------------------------------------------------------------------
373 virtual Symbol *ResolveSymbolForAddress(const Address &so_addr,
374 bool verify_unique) {
375 // Typically overridden to lazily add stripped symbols recoverable from the
376 // exception handling unwind information (i.e. without parsing the entire
379 // The availability of LC_FUNCTION_STARTS allows ObjectFileMachO to
380 // efficiently add stripped symbols when the symbol table is first
381 // constructed. Poorer cousins are PECoff and ELF.
385 //------------------------------------------------------------------
386 /// Detect if this object file has been stripped of local symbols.
387 //------------------------------------------------------------------
388 /// Detect if this object file has been stripped of local symbols.
391 /// Return \b true if the object file has been stripped of local
393 //------------------------------------------------------------------
394 virtual bool IsStripped() = 0;
396 //------------------------------------------------------------------
397 /// Frees the symbol table.
399 /// This function should only be used when an object file is
402 /// eSymtabFromUnifiedSectionList: Whether to clear symbol table
403 /// for unified module section list, or object file.
406 /// The symbol table for this object file.
407 //------------------------------------------------------------------
408 virtual void ClearSymtab();
410 //------------------------------------------------------------------
411 /// Gets the UUID for this object file.
413 /// If the object file format contains a UUID, the value should be returned.
414 /// Else ObjectFile instances should return the MD5 checksum of all of the
415 /// bytes for the object file (or memory for memory based object files).
418 /// Returns \b true if a UUID was successfully extracted into
419 /// \a uuid, \b false otherwise.
420 //------------------------------------------------------------------
421 virtual bool GetUUID(lldb_private::UUID *uuid) = 0;
423 //------------------------------------------------------------------
424 /// Gets the symbol file spec list for this object file.
426 /// If the object file format contains a debug symbol file link, the values
427 /// will be returned in the FileSpecList.
430 /// Returns filespeclist.
431 //------------------------------------------------------------------
432 virtual lldb_private::FileSpecList GetDebugSymbolFilePaths() {
433 return FileSpecList();
436 //------------------------------------------------------------------
437 /// Gets the file spec list of libraries re-exported by this object file.
439 /// If the object file format has the notion of one library re-exporting the
440 /// symbols from another, the re-exported libraries will be returned in the
444 /// Returns filespeclist.
445 //------------------------------------------------------------------
446 virtual lldb_private::FileSpecList GetReExportedLibraries() {
447 return FileSpecList();
450 //------------------------------------------------------------------
451 /// Sets the load address for an entire module, assuming a rigid slide of
452 /// sections, if possible in the implementation.
455 /// Returns true iff any section's load address changed.
456 //------------------------------------------------------------------
457 virtual bool SetLoadAddress(Target &target, lldb::addr_t value,
458 bool value_is_offset) {
462 //------------------------------------------------------------------
463 /// Gets whether endian swapping should occur when extracting data from this
467 /// Returns \b true if endian swapping is needed, \b false
469 //------------------------------------------------------------------
470 virtual lldb::ByteOrder GetByteOrder() const = 0;
472 //------------------------------------------------------------------
473 /// Attempts to parse the object header.
475 /// This function is used as a test to see if a given plug-in instance can
476 /// parse the header data already contained in ObjectFile::m_data. If an
477 /// object file parser does not recognize that magic bytes in a header,
478 /// false should be returned and the next plug-in can attempt to parse an
482 /// Returns \b true if the header was parsed successfully, \b
484 //------------------------------------------------------------------
485 virtual bool ParseHeader() = 0;
487 //------------------------------------------------------------------
488 /// Returns a reference to the UnwindTable for this ObjectFile
490 /// The UnwindTable contains FuncUnwinders objects for any function in this
491 /// ObjectFile. If a FuncUnwinders object hasn't been created yet (i.e. the
492 /// function has yet to be unwound in a stack walk), it will be created when
493 /// requested. Specifically, we do not create FuncUnwinders objects for
494 /// functions until they are needed.
497 /// Returns the unwind table for this object file.
498 //------------------------------------------------------------------
499 virtual lldb_private::UnwindTable &GetUnwindTable() { return m_unwind_table; }
501 //------------------------------------------------------------------
502 /// Returns if the function bounds for symbols in this symbol file are
505 /// The unwinder can emulate the instructions of functions to understand
506 /// prologue/epilogue code sequences, where registers are spilled on the
507 /// stack, etc. This feature relies on having the correct start addresses
508 /// of all functions. If the ObjectFile has a way to tell that symbols have
509 /// been stripped and there's no way to reconstruct start addresses (e.g.
510 /// LC_FUNCTION_STARTS on Mach-O, or eh_frame unwind info), the ObjectFile
511 /// should indicate that assembly emulation should not be used for this
514 /// It is uncommon for this to return false. An ObjectFile needs to be sure
515 /// that symbol start addresses are unavailable before false is returned.
516 /// If it is unclear, this should return true.
519 /// Returns true if assembly emulation should be used for this
521 /// Only returns false if the ObjectFile is sure that symbol
522 /// addresses are insufficient for accurate assembly emulation.
523 //------------------------------------------------------------------
524 virtual bool AllowAssemblyEmulationUnwindPlans() { return true; }
526 //------------------------------------------------------------------
527 /// Similar to Process::GetImageInfoAddress().
529 /// Some platforms embed auxiliary structures useful to debuggers in the
530 /// address space of the inferior process. This method returns the address
531 /// of such a structure if the information can be resolved via entries in
532 /// the object file. ELF, for example, provides a means to hook into the
533 /// runtime linker so that a debugger may monitor the loading and unloading
534 /// of shared libraries.
537 /// The address of any auxiliary tables, or an invalid address if this
538 /// object file format does not support or contain such information.
539 virtual lldb_private::Address GetImageInfoAddress(Target *target) {
543 //------------------------------------------------------------------
544 /// Returns the address of the Entry Point in this object file - if the
545 /// object file doesn't have an entry point (because it is not an executable
546 /// file) then an invalid address is returned.
549 /// Returns the entry address for this module.
550 //------------------------------------------------------------------
551 virtual lldb_private::Address GetEntryPointAddress() { return Address(); }
553 //------------------------------------------------------------------
554 /// Returns the address that represents the header of this object file.
556 /// The header address is defined as where the header for the object file is
557 /// that describes the content of the file. If the header doesn't appear in
558 /// a section that is defined in the object file, an address with no section
559 /// is returned that has the file offset set in the m_file_offset member of
560 /// the lldb_private::Address object.
563 /// Returns the entry address for this module.
564 //------------------------------------------------------------------
565 virtual lldb_private::Address GetHeaderAddress() {
566 return Address(m_memory_addr);
569 virtual uint32_t GetNumThreadContexts() { return 0; }
571 //------------------------------------------------------------------
572 /// Some object files may have an identifier string embedded in them, e.g.
573 /// in a Mach-O core file using the LC_IDENT load command (which is
574 /// obsolete, but can still be found in some old files)
577 /// Returns the identifier string if one exists, else an empty
579 //------------------------------------------------------------------
580 virtual std::string GetIdentifierString () {
581 return std::string();
584 //------------------------------------------------------------------
585 /// When the ObjectFile is a core file, lldb needs to locate the "binary" in
586 /// the core file. lldb can iterate over the pages looking for a valid
587 /// binary, but some core files may have metadata describing where the main
588 /// binary is exactly which removes ambiguity when there are multiple
589 /// binaries present in the captured memory pages.
591 /// @param[out] address
592 /// If the address of the binary is specified, this will be set.
593 /// This is an address is the virtual address space of the core file
594 /// memory segments; it is not an offset into the object file.
595 /// If no address is available, will be set to LLDB_INVALID_ADDRESS.
598 /// If the uuid of the binary is specified, this will be set.
599 /// If no UUID is available, will be cleared.
602 /// Returns true if either address or uuid has been set.
603 //------------------------------------------------------------------
604 virtual bool GetCorefileMainBinaryInfo (lldb::addr_t &address, UUID &uuid) {
605 address = LLDB_INVALID_ADDRESS;
610 virtual lldb::RegisterContextSP
611 GetThreadContextAtIndex(uint32_t idx, lldb_private::Thread &thread) {
612 return lldb::RegisterContextSP();
615 //------------------------------------------------------------------
616 /// The object file should be able to calculate its type by looking at its
617 /// file header and possibly the sections or other data in the object file.
618 /// The file type is used in the debugger to help select the correct plug-
619 /// ins for the job at hand, so this is important to get right. If any
620 /// eTypeXXX definitions do not match up with the type of file you are
621 /// loading, please feel free to add a new enumeration value.
624 /// The calculated file type for the current object file.
625 //------------------------------------------------------------------
626 virtual Type CalculateType() = 0;
628 //------------------------------------------------------------------
629 /// In cases where the type can't be calculated (elf files), this routine
630 /// allows someone to explicitly set it. As an example, SymbolVendorELF uses
631 /// this routine to set eTypeDebugInfo when loading debug link files.
632 virtual void SetType(Type type) { m_type = type; }
634 //------------------------------------------------------------------
635 /// The object file should be able to calculate the strata of the object
638 /// Many object files for platforms might be for either user space debugging
639 /// or for kernel debugging. If your object file subclass can figure this
640 /// out, it will help with debugger plug-in selection when it comes time to
644 /// The calculated object file strata for the current object
646 //------------------------------------------------------------------
647 virtual Strata CalculateStrata() = 0;
649 //------------------------------------------------------------------
650 /// Get the object file version numbers.
652 /// Many object files have a set of version numbers that describe the
653 /// version of the executable or shared library. Typically there are major,
654 /// minor and build, but there may be more. This function will extract the
655 /// versions from object files if they are available.
658 /// This function returns extracted version numbers as a
659 /// llvm::VersionTuple. In case of error an empty VersionTuple is
661 //------------------------------------------------------------------
662 virtual llvm::VersionTuple GetVersion() { return llvm::VersionTuple(); }
664 //------------------------------------------------------------------
665 /// Get the minimum OS version this object file can run on.
667 /// Some object files have information that specifies the minimum OS version
668 /// that they can be used on.
671 /// This function returns extracted version numbers as a
672 /// llvm::VersionTuple. In case of error an empty VersionTuple is
674 //------------------------------------------------------------------
675 virtual llvm::VersionTuple GetMinimumOSVersion() {
676 return llvm::VersionTuple();
679 //------------------------------------------------------------------
680 /// Get the SDK OS version this object file was built with.
682 /// The versions arguments and returns values are the same as the
683 /// GetMinimumOSVersion()
684 //------------------------------------------------------------------
685 virtual uint32_t GetSDKVersion(uint32_t *versions, uint32_t num_versions) {
686 if (versions && num_versions) {
687 for (uint32_t i = 0; i < num_versions; ++i)
688 versions[i] = UINT32_MAX;
693 //------------------------------------------------------------------
694 /// Return true if this file is a dynamic link editor (dyld)
696 /// Often times dyld has symbols that mirror symbols in libc and other
697 /// shared libraries (like "malloc" and "free") and the user does _not_ want
698 /// to stop in these shared libraries by default. We can ask the ObjectFile
699 /// if it is such a file and should be avoided for things like settings
700 /// breakpoints and doing function lookups for expressions.
701 //------------------------------------------------------------------
702 virtual bool GetIsDynamicLinkEditor() { return false; }
704 //------------------------------------------------------------------
706 //------------------------------------------------------------------
708 if (m_type == eTypeInvalid)
709 m_type = CalculateType();
714 if (m_strata == eStrataInvalid)
715 m_strata = CalculateStrata();
719 // When an object file is in memory, subclasses should try and lock the
720 // process weak pointer. If the process weak pointer produces a valid
721 // ProcessSP, then subclasses can call this function to read memory.
722 static lldb::DataBufferSP ReadMemory(const lldb::ProcessSP &process_sp,
723 lldb::addr_t addr, size_t byte_size);
725 // This function returns raw file contents. Do not use it if you want
726 // transparent decompression of section contents.
727 size_t GetData(lldb::offset_t offset, size_t length,
728 DataExtractor &data) const;
730 // This function returns raw file contents. Do not use it if you want
731 // transparent decompression of section contents.
732 size_t CopyData(lldb::offset_t offset, size_t length, void *dst) const;
734 // This function will transparently decompress section data if the section if
736 virtual size_t ReadSectionData(Section *section,
737 lldb::offset_t section_offset, void *dst,
740 // This function will transparently decompress section data if the section if
741 // compressed. Note that for compressed section the resulting data size may
742 // be larger than what Section::GetFileSize reports.
743 virtual size_t ReadSectionData(Section *section,
744 DataExtractor §ion_data);
746 bool IsInMemory() const { return m_memory_addr != LLDB_INVALID_ADDRESS; }
748 // Strip linker annotations (such as @@VERSION) from symbol names.
749 virtual llvm::StringRef
750 StripLinkerSymbolAnnotations(llvm::StringRef symbol_name) const {
754 static lldb::SymbolType GetSymbolTypeFromName(
755 llvm::StringRef name,
756 lldb::SymbolType symbol_type_hint = lldb::eSymbolTypeUndefined);
758 //------------------------------------------------------------------
759 /// Loads this objfile to memory.
761 /// Loads the bits needed to create an executable image to the memory. It is
762 /// useful with bare-metal targets where target does not have the ability to
763 /// start a process itself.
765 /// @param[in] target
766 /// Target where to load.
769 //------------------------------------------------------------------
770 virtual std::vector<LoadableData> GetLoadableData(Target &target);
773 //------------------------------------------------------------------
775 //------------------------------------------------------------------
779 lldb::addr_t m_file_offset; ///< The offset in bytes into the file, or the
781 lldb::addr_t m_length; ///< The length of this object file if it is known (can
782 ///be zero if length is unknown or can't be
785 m_data; ///< The data for this object file so things can be parsed lazily.
786 lldb_private::UnwindTable m_unwind_table; /// < Table of FuncUnwinders objects
787 /// created for this ObjectFile's
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 uint32_t m_synthetic_symbol_idx;
795 //------------------------------------------------------------------
796 /// Sets the architecture for a module. At present the architecture can
797 /// only be set if it is invalid. It is not allowed to switch from one
798 /// concrete architecture to another.
800 /// @param[in] new_arch
801 /// The architecture this module will be set to.
804 /// Returns \b true if the architecture was changed, \b
806 //------------------------------------------------------------------
807 bool SetModulesArchitecture(const ArchSpec &new_arch);
809 ConstString GetNextSyntheticSymbolName();
811 static lldb::DataBufferSP MapFileData(const FileSpec &file, uint64_t Size,
815 DISALLOW_COPY_AND_ASSIGN(ObjectFile);
818 } // namespace lldb_private
820 #endif // liblldb_ObjectFile_h_