LLDB  mainline
ObjectFileELF.h
Go to the documentation of this file.
1 //===-- ObjectFileELF.h --------------------------------------- -*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #ifndef LLDB_SOURCE_PLUGINS_OBJECTFILE_ELF_OBJECTFILEELF_H
10 #define LLDB_SOURCE_PLUGINS_OBJECTFILE_ELF_OBJECTFILEELF_H
11 
12 #include <cstdint>
13 
14 #include <vector>
15 
16 #include "lldb/Symbol/ObjectFile.h"
17 #include "lldb/Utility/ArchSpec.h"
18 #include "lldb/Utility/FileSpec.h"
19 #include "lldb/Utility/UUID.h"
20 #include "lldb/lldb-private.h"
21 
22 #include "ELFHeader.h"
23 
24 struct ELFNote {
28 
30 
31  ELFNote() = default;
32 
33  /// Parse an ELFNote entry from the given DataExtractor starting at position
34  /// \p offset.
35  ///
36  /// \param[in] data
37  /// The DataExtractor to read from.
38  ///
39  /// \param[in,out] offset
40  /// Pointer to an offset in the data. On return the offset will be
41  /// advanced by the number of bytes read.
42  ///
43  /// \return
44  /// True if the ELFRel entry was successfully read and false otherwise.
45  bool Parse(const lldb_private::DataExtractor &data, lldb::offset_t *offset);
46 
47  size_t GetByteSize() const {
48  return 12 + llvm::alignTo(n_namesz, 4) + llvm::alignTo(n_descsz, 4);
49  }
50 };
51 
52 /// \class ObjectFileELF
53 /// Generic ELF object file reader.
54 ///
55 /// This class provides a generic ELF (32/64 bit) reader plugin implementing
56 /// the ObjectFile protocol.
58 public:
59  // Static Functions
60  static void Initialize();
61 
62  static void Terminate();
63 
65 
66  static const char *GetPluginDescriptionStatic();
67 
69  CreateInstance(const lldb::ModuleSP &module_sp, lldb::DataBufferSP &data_sp,
70  lldb::offset_t data_offset, const lldb_private::FileSpec *file,
71  lldb::offset_t file_offset, lldb::offset_t length);
72 
74  const lldb::ModuleSP &module_sp, lldb::DataBufferSP &data_sp,
75  const lldb::ProcessSP &process_sp, lldb::addr_t header_addr);
76 
77  static size_t GetModuleSpecifications(const lldb_private::FileSpec &file,
78  lldb::DataBufferSP &data_sp,
79  lldb::offset_t data_offset,
80  lldb::offset_t file_offset,
81  lldb::offset_t length,
83 
84  static bool MagicBytesMatch(lldb::DataBufferSP &data_sp, lldb::addr_t offset,
85  lldb::addr_t length);
86 
87  // PluginInterface protocol
88  llvm::StringRef GetPluginName() override {
90  }
91 
92  // LLVM RTTI support
93  static char ID;
94  bool isA(const void *ClassID) const override {
95  return ClassID == &ID || ObjectFile::isA(ClassID);
96  }
97  static bool classof(const ObjectFile *obj) { return obj->isA(&ID); }
98 
99  // ObjectFile Protocol.
100  bool ParseHeader() override;
101 
103  bool value_is_offset) override;
104 
105  lldb::ByteOrder GetByteOrder() const override;
106 
107  bool IsExecutable() const override;
108 
109  uint32_t GetAddressByteSize() const override;
110 
112 
113  lldb_private::Symtab *GetSymtab() override;
114 
115  bool IsStripped() override;
116 
117  void CreateSections(lldb_private::SectionList &unified_section_list) override;
118 
119  void Dump(lldb_private::Stream *s) override;
120 
122 
123  lldb_private::UUID GetUUID() override;
124 
125  /// Return the contents of the .gnu_debuglink section, if the object file
126  /// contains it.
127  llvm::Optional<lldb_private::FileSpec> GetDebugLink();
128 
129  uint32_t GetDependentModules(lldb_private::FileSpecList &files) override;
130 
132  GetImageInfoAddress(lldb_private::Target *target) override;
133 
135 
137 
138  ObjectFile::Type CalculateType() override;
139 
140  ObjectFile::Strata CalculateStrata() override;
141 
142  size_t ReadSectionData(lldb_private::Section *section,
143  lldb::offset_t section_offset, void *dst,
144  size_t dst_len) override;
145 
146  size_t ReadSectionData(lldb_private::Section *section,
147  lldb_private::DataExtractor &section_data) override;
148 
149  llvm::ArrayRef<elf::ELFProgramHeader> ProgramHeaders();
151 
152  llvm::StringRef
153  StripLinkerSymbolAnnotations(llvm::StringRef symbol_name) const override;
154 
155  void RelocateSection(lldb_private::Section *section) override;
156 
157 protected:
158 
159  std::vector<LoadableData>
160  GetLoadableData(lldb_private::Target &target) override;
161 
162 private:
163  ObjectFileELF(const lldb::ModuleSP &module_sp, lldb::DataBufferSP &data_sp,
164  lldb::offset_t data_offset, const lldb_private::FileSpec *file,
165  lldb::offset_t offset, lldb::offset_t length);
166 
167  ObjectFileELF(const lldb::ModuleSP &module_sp,
168  lldb::DataBufferSP &header_data_sp,
169  const lldb::ProcessSP &process_sp, lldb::addr_t header_addr);
170 
171  typedef std::vector<elf::ELFProgramHeader> ProgramHeaderColl;
172 
175  };
176 
177  typedef std::vector<ELFSectionHeaderInfo> SectionHeaderColl;
178  typedef SectionHeaderColl::iterator SectionHeaderCollIter;
179  typedef SectionHeaderColl::const_iterator SectionHeaderCollConstIter;
180 
181  typedef std::vector<elf::ELFDynamic> DynamicSymbolColl;
182  typedef DynamicSymbolColl::iterator DynamicSymbolCollIter;
183  typedef DynamicSymbolColl::const_iterator DynamicSymbolCollConstIter;
184 
185  typedef std::map<lldb::addr_t, lldb_private::AddressClass>
187 
188  /// Version of this reader common to all plugins based on this class.
189  static const uint32_t m_plugin_version = 1;
191 
192  /// ELF file header.
194 
195  /// ELF build ID.
197 
198  /// ELF .gnu_debuglink file and crc data if available.
201 
202  /// Collection of program headers.
204 
205  /// Collection of section headers.
207 
208  /// Collection of symbols from the dynamic table.
210 
211  /// Object file parsed from .gnu_debugdata section (\sa
212  /// GetGnuDebugDataObjectFile())
213  std::shared_ptr<ObjectFileELF> m_gnu_debug_data_object_file;
214 
215  /// List of file specifications corresponding to the modules (shared
216  /// libraries) on which this object file depends.
217  mutable std::unique_ptr<lldb_private::FileSpecList> m_filespec_up;
218 
219  /// Cached value of the entry point for this module.
221 
222  /// The architecture detected from parsing elf file contents.
224 
225  /// The address class for each symbol in the elf file
227 
228  /// Returns the index of the given section header.
229  size_t SectionIndex(const SectionHeaderCollIter &I);
230 
231  /// Returns the index of the given section header.
232  size_t SectionIndex(const SectionHeaderCollConstIter &I) const;
233 
234  // Parses the ELF program headers.
235  static size_t GetProgramHeaderInfo(ProgramHeaderColl &program_headers,
236  lldb_private::DataExtractor &object_data,
237  const elf::ELFHeader &header);
238 
239  // Finds PT_NOTE segments and calculates their crc sum.
240  static uint32_t
241  CalculateELFNotesSegmentsCRC32(const ProgramHeaderColl &program_headers,
243 
244  /// Parses all section headers present in this object file and populates
245  /// m_program_headers. This method will compute the header list only once.
246  /// Returns true iff the headers have been successfully parsed.
247  bool ParseProgramHeaders();
248 
249  /// Parses all section headers present in this object file and populates
250  /// m_section_headers. This method will compute the header list only once.
251  /// Returns the number of headers parsed.
252  size_t ParseSectionHeaders();
253 
255 
257  uint64_t length,
258  lldb_private::ArchSpec &arch_spec);
259 
260  /// Parses the elf section headers and returns the uuid, debug link name,
261  /// crc, archspec.
262  static size_t GetSectionHeaderInfo(SectionHeaderColl &section_headers,
263  lldb_private::DataExtractor &object_data,
264  const elf::ELFHeader &header,
265  lldb_private::UUID &uuid,
266  std::string &gnu_debuglink_file,
267  uint32_t &gnu_debuglink_crc,
268  lldb_private::ArchSpec &arch_spec);
269 
270  /// Scans the dynamic section and locates all dependent modules (shared
271  /// libraries) populating m_filespec_up. This method will compute the
272  /// dependent module list only once. Returns the number of dependent
273  /// modules parsed.
274  size_t ParseDependentModules();
275 
276  /// Parses the dynamic symbol table and populates m_dynamic_symbols. The
277  /// vector retains the order as found in the object file. Returns the
278  /// number of dynamic symbols parsed.
279  size_t ParseDynamicSymbols();
280 
281  /// Populates m_symtab_up will all non-dynamic linker symbols. This method
282  /// will parse the symbols only once. Returns the number of symbols parsed.
283  unsigned ParseSymbolTable(lldb_private::Symtab *symbol_table,
284  lldb::user_id_t start_id,
285  lldb_private::Section *symtab);
286 
287  /// Helper routine for ParseSymbolTable().
288  unsigned ParseSymbols(lldb_private::Symtab *symbol_table,
289  lldb::user_id_t start_id,
290  lldb_private::SectionList *section_list,
291  const size_t num_symbols,
292  const lldb_private::DataExtractor &symtab_data,
293  const lldb_private::DataExtractor &strtab_data);
294 
295  /// Scans the relocation entries and adds a set of artificial symbols to the
296  /// given symbol table for each PLT slot. Returns the number of symbols
297  /// added.
298  unsigned ParseTrampolineSymbols(lldb_private::Symtab *symbol_table,
299  lldb::user_id_t start_id,
300  const ELFSectionHeaderInfo *rela_hdr,
301  lldb::user_id_t section_id);
302 
303  void ParseUnwindSymbols(lldb_private::Symtab *symbol_table,
305 
306  /// Relocates debug sections
307  unsigned RelocateDebugSections(const elf::ELFSectionHeader *rel_hdr,
308  lldb::user_id_t rel_id,
309  lldb_private::Symtab *thetab);
310 
311  unsigned ApplyRelocations(lldb_private::Symtab *symtab,
312  const elf::ELFHeader *hdr,
313  const elf::ELFSectionHeader *rel_hdr,
314  const elf::ELFSectionHeader *symtab_hdr,
315  const elf::ELFSectionHeader *debug_hdr,
316  lldb_private::DataExtractor &rel_data,
317  lldb_private::DataExtractor &symtab_data,
318  lldb_private::DataExtractor &debug_data,
319  lldb_private::Section *rel_section);
320 
321  /// Loads the section name string table into m_shstr_data. Returns the
322  /// number of bytes constituting the table.
324 
325  /// Utility method for looking up a section given its name. Returns the
326  /// index of the corresponding section or zero if no section with the given
327  /// name can be found (note that section indices are always 1 based, and so
328  /// section index 0 is never valid).
329  lldb::user_id_t GetSectionIndexByName(const char *name);
330 
331  /// Returns the section header with the given id or NULL.
333 
334  /// \name ELF header dump routines
335  //@{
336  static void DumpELFHeader(lldb_private::Stream *s,
337  const elf::ELFHeader &header);
338 
340  unsigned char ei_data);
341 
343  elf::elf_half e_type);
344  //@}
345 
346  /// \name ELF program header dump routines
347  //@{
349 
351  const elf::ELFProgramHeader &ph);
352 
354  elf::elf_word p_type);
355 
357  elf::elf_word p_flags);
358  //@}
359 
360  /// \name ELF section header dump routines
361  //@{
363 
365  const ELFSectionHeaderInfo &sh);
366 
368  elf::elf_word sh_type);
369 
371  elf::elf_xword sh_flags);
372  //@}
373 
374  /// ELF dependent module dump routine.
376 
377  const elf::ELFDynamic *FindDynamicSymbol(unsigned tag);
378 
379  unsigned PLTRelocationType();
380 
381  static lldb_private::Status
383  lldb_private::ArchSpec &arch_spec,
384  lldb_private::UUID &uuid);
385 
387 
388  /// Takes the .gnu_debugdata and returns the decompressed object file that is
389  /// stored within that section.
390  ///
391  /// \returns either the decompressed object file stored within the
392  /// .gnu_debugdata section or \c nullptr if an error occured or if there's no
393  /// section with that name.
394  std::shared_ptr<ObjectFileELF> GetGnuDebugDataObjectFile();
395 };
396 
397 #endif // LLDB_SOURCE_PLUGINS_OBJECTFILE_ELF_OBJECTFILEELF_H
ObjectFileELF::StripLinkerSymbolAnnotations
llvm::StringRef StripLinkerSymbolAnnotations(llvm::StringRef symbol_name) const override
Definition: ObjectFileELF.cpp:1540
ObjectFileELF::m_filespec_up
std::unique_ptr< lldb_private::FileSpecList > m_filespec_up
List of file specifications corresponding to the modules (shared libraries) on which this object file...
Definition: ObjectFileELF.h:217
ObjectFileELF::m_dynamic_symbols
DynamicSymbolColl m_dynamic_symbols
Collection of symbols from the dynamic table.
Definition: ObjectFileELF.h:209
lldb_private::UUID
Definition: UUID.h:23
ObjectFileELF::DumpELFSectionHeader_sh_type
static void DumpELFSectionHeader_sh_type(lldb_private::Stream *s, elf::elf_word sh_type)
Definition: ObjectFileELF.cpp:3158
ObjectFileELF::GetSymtab
lldb_private::Symtab * GetSymtab() override
Gets the symbol table for the currently selected architecture (and object for archives).
Definition: ObjectFileELF.cpp:2699
ObjectFileELF::m_gnu_debug_data_object_file
std::shared_ptr< ObjectFileELF > m_gnu_debug_data_object_file
Object file parsed from .gnu_debugdata section (.
Definition: ObjectFileELF.h:213
ObjectFileELF::Initialize
static void Initialize()
Definition: ObjectFileELF.cpp:327
ObjectFileELF::SectionHeaderCollIter
SectionHeaderColl::iterator SectionHeaderCollIter
Definition: ObjectFileELF.h:178
ObjectFileELF::CreateMemoryInstance
static lldb_private::ObjectFile * CreateMemoryInstance(const lldb::ModuleSP &module_sp, lldb::DataBufferSP &data_sp, const lldb::ProcessSP &process_sp, lldb::addr_t header_addr)
Definition: ObjectFileELF.cpp:389
ObjectFileELF::GetModuleSpecifications
static size_t GetModuleSpecifications(const lldb_private::FileSpec &file, lldb::DataBufferSP &data_sp, lldb::offset_t data_offset, lldb::offset_t file_offset, lldb::offset_t length, lldb_private::ModuleSpecList &specs)
Definition: ObjectFileELF.cpp:512
lldb_private::ArchSpec
Definition: ArchSpec.h:33
ObjectFileELF::ProgramHeaders
llvm::ArrayRef< elf::ELFProgramHeader > ProgramHeaders()
Definition: ObjectFileELF.cpp:3384
ObjectFileELF::m_gnu_debuglink_crc
uint32_t m_gnu_debuglink_crc
Definition: ObjectFileELF.h:200
elf::ELFHeader
Definition: ELFHeader.h:56
ObjectFileELF::GetGnuDebugDataObjectFile
std::shared_ptr< ObjectFileELF > GetGnuDebugDataObjectFile()
Takes the .gnu_debugdata and returns the decompressed object file that is stored within that section.
Definition: ObjectFileELF.cpp:1879
ObjectFileELF::classof
static bool classof(const ObjectFile *obj)
Definition: ObjectFileELF.h:97
elf::elf_xword
uint64_t elf_xword
Definition: ELFHeader.h:47
ObjectFileELF::ObjectFileELF
ObjectFileELF(const lldb::ModuleSP &module_sp, lldb::DataBufferSP &data_sp, lldb::offset_t data_offset, const lldb_private::FileSpec *file, lldb::offset_t offset, lldb::offset_t length)
ObjectFileELF::ID
static char ID
Definition: ObjectFileELF.h:93
lldb_private::AddressClass
AddressClass
Definition: lldb-private-enumerations.h:48
ObjectFileELF::FindDynamicSymbol
const elf::ELFDynamic * FindDynamicSymbol(unsigned tag)
Definition: ObjectFileELF.cpp:2356
UUID.h
ObjectFileELF::GetPluginDescriptionStatic
static const char * GetPluginDescriptionStatic()
Definition: ObjectFileELF.cpp:342
ObjectFileELF::RefineModuleDetailsFromNote
static lldb_private::Status RefineModuleDetailsFromNote(lldb_private::DataExtractor &data, lldb_private::ArchSpec &arch_spec, lldb_private::UUID &uuid)
Definition: ObjectFileELF.cpp:1007
ObjectFileELF::ParseProgramHeaders
bool ParseProgramHeaders()
Parses all section headers present in this object file and populates m_program_headers.
Definition: ObjectFileELF.cpp:1002
ObjectFileELF::GetBaseAddress
lldb_private::Address GetBaseAddress() override
Returns base address of this object file.
Definition: ObjectFileELF.cpp:895
lldb_private::ModuleSpecList
Definition: ModuleSpec.h:280
ObjectFileELF::ProgramHeaderColl
std::vector< elf::ELFProgramHeader > ProgramHeaderColl
Definition: ObjectFileELF.h:171
lldb_private::ObjectFile::ObjectFile
ObjectFile(const lldb::ModuleSP &module_sp, const FileSpec *file_spec_ptr, lldb::offset_t file_offset, lldb::offset_t length, const lldb::DataBufferSP &data_sp, lldb::offset_t data_offset)
Construct with a parent module, offset, and header data.
Definition: ObjectFile.cpp:237
ObjectFileELF::SectionHeaderColl
std::vector< ELFSectionHeaderInfo > SectionHeaderColl
Definition: ObjectFileELF.h:177
ELFNote::n_name
std::string n_name
Definition: ObjectFileELF.h:29
ObjectFileELF::GetDependentModules
uint32_t GetDependentModules(lldb_private::FileSpecList &files) override
Definition: ObjectFileELF.cpp:800
ObjectFileELF::GetAddressByteSize
uint32_t GetAddressByteSize() const override
Gets the address size in bytes for the current object file.
Definition: ObjectFileELF.cpp:711
lldb_private::SectionList
Definition: Section.h:34
ObjectFileELF::GetArchitecture
lldb_private::ArchSpec GetArchitecture() override
Get the ArchSpec for this object file.
Definition: ObjectFileELF.cpp:3233
lldb::offset_t
uint64_t offset_t
Definition: lldb-types.h:87
ObjectFileELF::GetSectionType
lldb::SectionType GetSectionType(const ELFSectionHeaderInfo &H) const
Definition: ObjectFileELF.cpp:1618
ObjectFileELF::ELFSectionHeaderInfo::section_name
lldb_private::ConstString section_name
Definition: ObjectFileELF.h:174
lldb_private::Stream
Definition: Stream.h:28
lldb::addr_t
uint64_t addr_t
Definition: lldb-types.h:83
lldb_private::Target
Definition: Target.h:450
ObjectFileELF::ReadSectionData
size_t ReadSectionData(lldb_private::Section *section, lldb::offset_t section_offset, void *dst, size_t dst_len) override
Definition: ObjectFileELF.cpp:3324
ObjectFileELF::AnySegmentHasPhysicalAddress
bool AnySegmentHasPhysicalAddress()
Definition: ObjectFileELF.cpp:3393
ObjectFileELF::ParseDynamicSymbols
size_t ParseDynamicSymbols()
Parses the dynamic symbol table and populates m_dynamic_symbols.
Definition: ObjectFileELF.cpp:2323
ELFHeader.h
ELFNote
Definition: ObjectFileELF.h:24
ELFNote::n_type
elf::elf_word n_type
Definition: ObjectFileELF.h:27
ObjectFileELF::m_arch_spec
lldb_private::ArchSpec m_arch_spec
The architecture detected from parsing elf file contents.
Definition: ObjectFileELF.h:223
ObjectFileELF::ApplyRelocations
unsigned ApplyRelocations(lldb_private::Symtab *symtab, const elf::ELFHeader *hdr, const elf::ELFSectionHeader *rel_hdr, const elf::ELFSectionHeader *symtab_hdr, const elf::ELFSectionHeader *debug_hdr, lldb_private::DataExtractor &rel_data, lldb_private::DataExtractor &symtab_data, lldb_private::DataExtractor &debug_data, lldb_private::Section *rel_section)
Definition: ObjectFileELF.cpp:2559
ELFNote::n_descsz
elf::elf_word n_descsz
Definition: ObjectFileELF.h:26
elf::ELFSectionHeader
Definition: ELFHeader.h:159
lldb_private::FileSpec
Definition: FileSpec.h:56
ObjectFileELF::DumpELFProgramHeaders
void DumpELFProgramHeaders(lldb_private::Stream *s)
Definition: ObjectFileELF.cpp:3122
ObjectFileELF::CalculateType
ObjectFile::Type CalculateType() override
The object file should be able to calculate its type by looking at its file header and possibly the s...
Definition: ObjectFileELF.cpp:3259
ObjectFileELF::GetSectionHeaderStringTable
size_t GetSectionHeaderStringTable()
Loads the section name string table into m_shstr_data.
ObjectFileELF::GetEntryPointAddress
lldb_private::Address GetEntryPointAddress() override
Returns the address of the Entry Point in this object file - if the object file doesn't have an entry...
Definition: ObjectFileELF.cpp:878
lldb_private::DataExtractor
Definition: DataExtractor.h:48
lldb_private::ConstString::GetStringRef
llvm::StringRef GetStringRef() const
Get the string value as a llvm::StringRef.
Definition: ConstString.h:202
ObjectFileELF::CalculateStrata
ObjectFile::Strata CalculateStrata() override
The object file should be able to calculate the strata of the object file.
Definition: ObjectFileELF.cpp:3287
ObjectFileELF::GetUUID
lldb_private::UUID GetUUID() override
Gets the UUID for this object file.
Definition: ObjectFileELF.cpp:756
ObjectFileELF::CreateInstance
static lldb_private::ObjectFile * CreateInstance(const lldb::ModuleSP &module_sp, lldb::DataBufferSP &data_sp, lldb::offset_t data_offset, const lldb_private::FileSpec *file, lldb::offset_t file_offset, lldb::offset_t length)
Definition: ObjectFileELF.cpp:346
ObjectFileELF::m_address_class_map
FileAddressToAddressClassMap m_address_class_map
The address class for each symbol in the elf file.
Definition: ObjectFileELF.h:226
ObjectFileELF::GetPluginName
llvm::StringRef GetPluginName() override
Definition: ObjectFileELF.h:88
ObjectFileELF::SectionHeaderCollConstIter
SectionHeaderColl::const_iterator SectionHeaderCollConstIter
Definition: ObjectFileELF.h:179
ObjectFileELF::GetPluginNameStatic
static lldb_private::ConstString GetPluginNameStatic()
Definition: ObjectFileELF.cpp:337
ObjectFileELF::ParseHeader
bool ParseHeader() override
Attempts to parse the object header.
Definition: ObjectFileELF.cpp:751
ObjectFileELF::Dump
void Dump(lldb_private::Stream *s) override
Dump a description of this object to a Stream.
Definition: ObjectFileELF.cpp:2957
elf::ELFDynamic
Definition: ELFHeader.h:276
ELFNote::GetByteSize
size_t GetByteSize() const
Definition: ObjectFileELF.h:47
ObjectFileELF::DynamicSymbolCollConstIter
DynamicSymbolColl::const_iterator DynamicSymbolCollConstIter
Definition: ObjectFileELF.h:183
lldb_private::ConstString
Definition: ConstString.h:40
ObjectFileELF::DumpELFProgramHeader
static void DumpELFProgramHeader(lldb_private::Stream *s, const elf::ELFProgramHeader &ph)
Definition: ObjectFileELF.cpp:3074
ObjectFileELF::RelocateSection
void RelocateSection(lldb_private::Section *section) override
Perform relocations on the section if necessary.
Definition: ObjectFileELF.cpp:2849
ObjectFileELF::ParseUnwindSymbols
void ParseUnwindSymbols(lldb_private::Symtab *symbol_table, lldb_private::DWARFCallFrameInfo *eh_frame)
Definition: ObjectFileELF.cpp:2890
ObjectFileELF::GetAddressClass
lldb_private::AddressClass GetAddressClass(lldb::addr_t file_addr) override
Get the address type given a file address in an object file.
Definition: ObjectFileELF.cpp:715
ObjectFileELF::SectionIndex
size_t SectionIndex(const SectionHeaderCollIter &I)
Returns the index of the given section header.
Definition: ObjectFileELF.cpp:743
ObjectFileELF::m_program_headers
ProgramHeaderColl m_program_headers
Collection of program headers.
Definition: ObjectFileELF.h:203
ObjectFileELF::PLTRelocationType
unsigned PLTRelocationType()
Definition: ObjectFileELF.cpp:2372
string
string(SUBSTRING ${p} 10 -1 pStripped) if($
Definition: Plugins/CMakeLists.txt:40
ObjectFileELF::DumpELFHeader_e_type
static void DumpELFHeader_e_type(lldb_private::Stream *s, elf::elf_half e_type)
Definition: ObjectFileELF.cpp:3029
ObjectFileELF::ParseDependentModules
size_t ParseDependentModules()
Scans the dynamic section and locates all dependent modules (shared libraries) populating m_filespec_...
Definition: ObjectFileELF.cpp:908
ELFNote::ELFNote
ELFNote()=default
ObjectFileELF::GetDebugLink
llvm::Optional< lldb_private::FileSpec > GetDebugLink()
Return the contents of the .gnu_debuglink section, if the object file contains it.
Definition: ObjectFileELF.cpp:794
ObjectFileELF::SetLoadAddress
bool SetLoadAddress(lldb_private::Target &target, lldb::addr_t value, bool value_is_offset) override
Sets the load address for an entire module, assuming a rigid slide of sections, if possible in the im...
Definition: ObjectFileELF.cpp:657
ObjectFile.h
ObjectFileELF::IsExecutable
bool IsExecutable() const override
Tells whether this object file is capable of being the main executable for a process.
Definition: ObjectFileELF.cpp:653
lldb-private.h
ObjectFileELF::DumpDependentModules
void DumpDependentModules(lldb_private::Stream *s)
ELF dependent module dump routine.
Definition: ObjectFileELF.cpp:3221
lldb_private::Section
Definition: Section.h:96
ObjectFileELF::CreateSections
void CreateSections(lldb_private::SectionList &unified_section_list) override
Definition: ObjectFileELF.cpp:1774
ObjectFileELF::Terminate
static void Terminate()
Definition: ObjectFileELF.cpp:333
ObjectFileELF::ParseTrampolineSymbols
unsigned ParseTrampolineSymbols(lldb_private::Symtab *symbol_table, lldb::user_id_t start_id, const ELFSectionHeaderInfo *rela_hdr, lldb::user_id_t section_id)
Scans the relocation entries and adds a set of artificial symbols to the given symbol table for each ...
Definition: ObjectFileELF.cpp:2489
lldb_private::Status
Definition: Status.h:44
lldb_private::Symtab
Definition: Symtab.h:22
uint32_t
ObjectFileELF::m_section_headers
SectionHeaderColl m_section_headers
Collection of section headers.
Definition: ObjectFileELF.h:206
ObjectFileELF::CalculateELFNotesSegmentsCRC32
static uint32_t CalculateELFNotesSegmentsCRC32(const ProgramHeaderColl &program_headers, lldb_private::DataExtractor &data)
Definition: ObjectFileELF.cpp:424
lldb::SectionType
SectionType
Definition: lldb-enumerations.h:646
lldb_private::Address
Definition: Address.h:59
ObjectFileELF::DumpELFSectionHeader
static void DumpELFSectionHeader(lldb_private::Stream *s, const ELFSectionHeaderInfo &sh)
Definition: ObjectFileELF.cpp:3142
ObjectFileELF::MagicBytesMatch
static bool MagicBytesMatch(lldb::DataBufferSP &data_sp, lldb::addr_t offset, lldb::addr_t length)
Definition: ObjectFileELF.cpp:408
ArchSpec.h
elf::ELFProgramHeader
Definition: ELFHeader.h:192
ObjectFileELF::GetSegmentData
lldb_private::DataExtractor GetSegmentData(const elf::ELFProgramHeader &H)
Definition: ObjectFileELF.cpp:3389
uint16_t
ObjectFileELF
Definition: ObjectFileELF.h:57
ObjectFileELF::DumpELFHeader_e_ident_EI_DATA
static void DumpELFHeader_e_ident_EI_DATA(lldb_private::Stream *s, unsigned char ei_data)
Definition: ObjectFileELF.cpp:3054
ELFNote::n_namesz
elf::elf_word n_namesz
Definition: ObjectFileELF.h:25
lldb_private::DWARFCallFrameInfo
Definition: DWARFCallFrameInfo.h:33
ObjectFileELF::m_plugin_version
static const uint32_t m_plugin_version
Version of this reader common to all plugins based on this class.
Definition: ObjectFileELF.h:189
ObjectFileELF::GetProgramHeaderInfo
static size_t GetProgramHeaderInfo(ProgramHeaderColl &program_headers, lldb_private::DataExtractor &object_data, const elf::ELFHeader &header)
Definition: ObjectFileELF.cpp:967
ObjectFileELF::m_uuid
lldb_private::UUID m_uuid
ELF build ID.
Definition: ObjectFileELF.h:196
ObjectFileELF::DumpELFHeader
static void DumpELFHeader(lldb_private::Stream *s, const elf::ELFHeader &header)
Definition: ObjectFileELF.cpp:2994
ObjectFileELF::ParseSymbolTable
unsigned ParseSymbolTable(lldb_private::Symtab *symbol_table, lldb::user_id_t start_id, lldb_private::Section *symtab)
Populates m_symtab_up will all non-dynamic linker symbols.
Definition: ObjectFileELF.cpp:2280
lldb::user_id_t
uint64_t user_id_t
Definition: lldb-types.h:84
ObjectFileELF::m_entry_point_address
lldb_private::Address m_entry_point_address
Cached value of the entry point for this module.
Definition: ObjectFileELF.h:220
ObjectFileELF::GetImageInfoAddress
lldb_private::Address GetImageInfoAddress(lldb_private::Target *target) override
Similar to Process::GetImageInfoAddress().
Definition: ObjectFileELF.cpp:812
ObjectFileELF::DynamicSymbolColl
std::vector< elf::ELFDynamic > DynamicSymbolColl
Definition: ObjectFileELF.h:181
ObjectFileELF::g_core_uuid_magic
static const uint32_t g_core_uuid_magic
Definition: ObjectFileELF.h:190
ObjectFileELF::DumpELFSectionHeader_sh_flags
static void DumpELFSectionHeader_sh_flags(lldb_private::Stream *s, elf::elf_xword sh_flags)
Definition: ObjectFileELF.cpp:3186
ObjectFileELF::GetSectionHeaderByIndex
const ELFSectionHeaderInfo * GetSectionHeaderByIndex(lldb::user_id_t id)
Returns the section header with the given id or NULL.
Definition: ObjectFileELF.cpp:1553
FileSpec.h
ObjectFileELF::FileAddressToAddressClassMap
std::map< lldb::addr_t, lldb_private::AddressClass > FileAddressToAddressClassMap
Definition: ObjectFileELF.h:186
ObjectFileELF::DynamicSymbolCollIter
DynamicSymbolColl::iterator DynamicSymbolCollIter
Definition: ObjectFileELF.h:182
ObjectFileELF::GetByteOrder
lldb::ByteOrder GetByteOrder() const override
Gets whether endian swapping should occur when extracting data from this object file.
Definition: ObjectFileELF.cpp:703
ObjectFileELF::RelocateDebugSections
unsigned RelocateDebugSections(const elf::ELFSectionHeader *rel_hdr, lldb::user_id_t rel_id, lldb_private::Symtab *thetab)
Relocates debug sections.
Definition: ObjectFileELF.cpp:2652
ObjectFileELF::DumpELFSectionHeaders
void DumpELFSectionHeaders(lldb_private::Stream *s)
Definition: ObjectFileELF.cpp:3198
ObjectFileELF::GetSectionHeaderInfo
static size_t GetSectionHeaderInfo(SectionHeaderColl &section_headers, lldb_private::DataExtractor &object_data, const elf::ELFHeader &header, lldb_private::UUID &uuid, std::string &gnu_debuglink_file, uint32_t &gnu_debuglink_crc, lldb_private::ArchSpec &arch_spec)
Parses the elf section headers and returns the uuid, debug link name, crc, archspec.
Definition: ObjectFileELF.cpp:1314
ObjectFileELF::ParseARMAttributes
static void ParseARMAttributes(lldb_private::DataExtractor &data, uint64_t length, lldb_private::ArchSpec &arch_spec)
Definition: ObjectFileELF.cpp:1243
ObjectFileELF::IsStripped
bool IsStripped() override
Detect if this object file has been stripped of local symbols.
Definition: ObjectFileELF.cpp:2947
ObjectFileELF::ParseSectionHeaders
size_t ParseSectionHeaders()
Parses all section headers present in this object file and populates m_section_headers.
Definition: ObjectFileELF.cpp:1546
ObjectFileELF::DumpELFProgramHeader_p_flags
static void DumpELFProgramHeader_p_flags(lldb_private::Stream *s, elf::elf_word p_flags)
Definition: ObjectFileELF.cpp:3111
ObjectFileELF::GetSectionIndexByName
lldb::user_id_t GetSectionIndexByName(const char *name)
Utility method for looking up a section given its name.
Definition: ObjectFileELF.cpp:1563
ObjectFileELF::ParseSymbols
unsigned ParseSymbols(lldb_private::Symtab *symbol_table, lldb::user_id_t start_id, lldb_private::SectionList *section_list, const size_t num_symbols, const lldb_private::DataExtractor &symtab_data, const lldb_private::DataExtractor &strtab_data)
Helper routine for ParseSymbolTable().
Definition: ObjectFileELF.cpp:1947
ObjectFileELF::DumpELFProgramHeader_p_type
static void DumpELFProgramHeader_p_type(lldb_private::Stream *s, elf::elf_word p_type)
Definition: ObjectFileELF.cpp:3090
ObjectFileELF::m_header
elf::ELFHeader m_header
ELF file header.
Definition: ObjectFileELF.h:193
ObjectFileELF::isA
bool isA(const void *ClassID) const override
Definition: ObjectFileELF.h:94
ObjectFileELF::ELFSectionHeaderInfo
Definition: ObjectFileELF.h:173
lldb_private::ObjectFile
Definition: ObjectFile.h:58
ELFNote::Parse
bool Parse(const lldb_private::DataExtractor &data, lldb::offset_t *offset)
Parse an ELFNote entry from the given DataExtractor starting at position offset.
Definition: ObjectFileELF.cpp:216
ObjectFileELF::GetLoadableData
std::vector< LoadableData > GetLoadableData(lldb_private::Target &target) override
Loads this objfile to memory.
Definition: ObjectFileELF.cpp:3402
ObjectFileELF::m_gnu_debuglink_file
std::string m_gnu_debuglink_file
ELF .gnu_debuglink file and crc data if available.
Definition: ObjectFileELF.h:199
lldb::ByteOrder
ByteOrder
Byte ordering definitions.
Definition: lldb-enumerations.h:138