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 <optional>
15#include <vector>
16
20#include "lldb/Utility/UUID.h"
21#include "lldb/lldb-private.h"
22
23#include "ELFHeader.h"
24
25struct ELFNote {
29
30 std::string n_name;
31
32 ELFNote() = default;
33
34 /// Parse an ELFNote entry from the given DataExtractor starting at position
35 /// \p offset.
36 ///
37 /// \param[in] data
38 /// The DataExtractor to read from.
39 ///
40 /// \param[in,out] offset
41 /// Pointer to an offset in the data. On return the offset will be
42 /// advanced by the number of bytes read.
43 ///
44 /// \return
45 /// True if the ELFRel entry was successfully read and false otherwise.
46 bool Parse(const lldb_private::DataExtractor &data, lldb::offset_t *offset);
47
48 size_t GetByteSize() const {
49 return 12 + llvm::alignTo(n_namesz, 4) + llvm::alignTo(n_descsz, 4);
50 }
51};
52
53/// \class ObjectFileELF
54/// Generic ELF object file reader.
55///
56/// This class provides a generic ELF (32/64 bit) reader plugin implementing
57/// the ObjectFile protocol.
59public:
60 // Static Functions
61 static void Initialize();
62
63 static void Terminate();
64
65 static llvm::StringRef GetPluginNameStatic() { return "elf"; }
66
67 static llvm::StringRef GetPluginDescriptionStatic() {
68 return "ELF object file reader.";
69 }
70
72 CreateInstance(const lldb::ModuleSP &module_sp,
73 lldb::DataExtractorSP extractor_sp, lldb::offset_t data_offset,
74 const lldb_private::FileSpec *file, lldb::offset_t file_offset,
75 lldb::offset_t length);
76
78 const lldb::ModuleSP &module_sp, lldb::WritableDataBufferSP data_sp,
79 const lldb::ProcessSP &process_sp, lldb::addr_t header_addr);
80
83 lldb::DataExtractorSP &extractor_sp,
84 lldb::offset_t file_offset, lldb::offset_t length);
85
86 static bool MagicBytesMatch(lldb::DataBufferSP data_sp, lldb::addr_t offset,
87 lldb::addr_t length);
88
89 // PluginInterface protocol
90 llvm::StringRef GetPluginName() override { return GetPluginNameStatic(); }
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 void ParseSymtab(lldb_private::Symtab &symtab) 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 std::optional<lldb_private::FileSpec> GetDebugLink();
128
129 uint32_t GetDependentModules(lldb_private::FileSpecList &files) override;
130
132
134 return true;
135 }
136
139
141
143
144 ObjectFile::Type CalculateType() override;
145
146 ObjectFile::Strata CalculateStrata() override;
147
149 lldb::offset_t section_offset, void *dst,
150 size_t dst_len) override;
151
153 lldb_private::DataExtractor &section_data) override;
154
155 llvm::ArrayRef<elf::ELFProgramHeader> ProgramHeaders();
157
158 llvm::StringRef
159 StripLinkerSymbolAnnotations(llvm::StringRef symbol_name) const override;
160
161 void RelocateSection(lldb_private::Section *section) override;
162
163protected:
164
165 std::vector<LoadableData>
166 GetLoadableData(lldb_private::Target &target) override;
167
169 MapFileDataWritable(const lldb_private::FileSpec &file, uint64_t Size,
170 uint64_t Offset);
171
172private:
173 ObjectFileELF(const lldb::ModuleSP &module_sp,
174 lldb::DataExtractorSP extractor_sp, lldb::offset_t data_offset,
175 const lldb_private::FileSpec *file, lldb::offset_t offset,
176 lldb::offset_t length);
177
178 ObjectFileELF(const lldb::ModuleSP &module_sp,
179 lldb::DataBufferSP header_data_sp,
180 const lldb::ProcessSP &process_sp, lldb::addr_t header_addr);
181
182 typedef std::vector<elf::ELFProgramHeader> ProgramHeaderColl;
183
185 std::string section_name;
186 };
187
188 typedef std::vector<ELFSectionHeaderInfo> SectionHeaderColl;
189 typedef SectionHeaderColl::iterator SectionHeaderCollIter;
190 typedef SectionHeaderColl::const_iterator SectionHeaderCollConstIter;
191
196 typedef std::vector<ELFDynamicWithName> DynamicSymbolColl;
197 typedef DynamicSymbolColl::iterator DynamicSymbolCollIter;
198 typedef DynamicSymbolColl::const_iterator DynamicSymbolCollConstIter;
199
200 /// An ordered map of file address to address class. Used on architectures
201 /// like Arm where there is an alternative ISA mode like Thumb. The container
202 /// is ordered so that it can be binary searched.
203 typedef std::map<lldb::addr_t, lldb_private::AddressClass>
205
206 /// Version of this reader common to all plugins based on this class.
207 static const uint32_t m_plugin_version = 1;
208 static const uint32_t g_core_uuid_magic;
209
210 /// ELF file header.
212
213 /// ELF build ID.
215
216 /// ELF .gnu_debuglink file and crc data if available.
219
220 /// Collection of program headers.
222
223 /// Collection of section headers.
225
226 /// The file address of the .dynamic section. This can be found in the p_vaddr
227 /// of the PT_DYNAMIC program header.
229
230 /// Collection of symbols from the dynamic table.
232
233 /// Object file parsed from .gnu_debugdata section (\sa
234 /// GetGnuDebugDataObjectFile())
235 std::shared_ptr<ObjectFileELF> m_gnu_debug_data_object_file;
236
237 /// List of file specifications corresponding to the modules (shared
238 /// libraries) on which this object file depends.
239 mutable std::unique_ptr<lldb_private::FileSpecList> m_filespec_up;
240
241 /// Cached value of the entry point for this module.
243
244 /// The architecture detected from parsing elf file contents.
246
247 /// The address class for each symbol in the elf file
249
250 /// Returns the index of the given section header.
251 size_t SectionIndex(const SectionHeaderCollIter &I);
252
253 /// Returns the index of the given section header.
254 size_t SectionIndex(const SectionHeaderCollConstIter &I) const;
255
256 // Parses the ELF program headers.
257 static size_t GetProgramHeaderInfo(ProgramHeaderColl &program_headers,
258 lldb_private::DataExtractor &object_data,
259 const elf::ELFHeader &header);
260
261 // Finds PT_NOTE segments and calculates their crc sum.
262 static uint32_t
265
266 /// Parses all section headers present in this object file and populates
267 /// m_program_headers. This method will compute the header list only once.
268 /// Returns true iff the headers have been successfully parsed.
269 bool ParseProgramHeaders();
270
271 /// Parses all section headers present in this object file and populates
272 /// m_section_headers. This method will compute the header list only once.
273 /// Returns the number of headers parsed.
274 size_t ParseSectionHeaders();
275
277
279 uint64_t length,
280 lldb_private::ArchSpec &arch_spec);
281
283 uint64_t length,
284 lldb_private::ArchSpec &arch_spec);
285
286 /// Parses the elf section headers and returns the uuid, debug link name,
287 /// crc, archspec.
288 static size_t GetSectionHeaderInfo(SectionHeaderColl &section_headers,
289 lldb_private::DataExtractor &object_data,
290 const elf::ELFHeader &header,
291 lldb_private::UUID &uuid,
292 std::string &gnu_debuglink_file,
293 uint32_t &gnu_debuglink_crc,
294 lldb_private::ArchSpec &arch_spec);
295
296 /// Scans the dynamic section and locates all dependent modules (shared
297 /// libraries) populating m_filespec_up. This method will compute the
298 /// dependent module list only once. Returns the number of dependent
299 /// modules parsed.
300 size_t ParseDependentModules();
301
302 /// Parses the dynamic symbol table and populates m_dynamic_symbols. The
303 /// vector retains the order as found in the object file. Returns the
304 /// number of dynamic symbols parsed.
305 size_t ParseDynamicSymbols();
306
307 /// Populates the symbol table with all non-dynamic linker symbols. This
308 /// method will parse the symbols only once. Returns the number of symbols
309 /// parsed and a map of address types (used by targets like Arm that have
310 /// an alternative ISA mode like Thumb).
311 std::pair<unsigned, FileAddressToAddressClassMap>
313 lldb_private::Section *symtab);
314
315 /// Helper routine for ParseSymbolTable().
316 std::pair<unsigned, FileAddressToAddressClassMap>
317 ParseSymbols(lldb_private::Symtab *symbol_table, lldb::user_id_t start_id,
318 lldb_private::SectionList *section_list,
319 const size_t num_symbols,
320 const lldb_private::DataExtractor &symtab_data,
321 const lldb_private::DataExtractor &strtab_data);
322
323 /// Scans the relocation entries and adds a set of artificial symbols to the
324 /// given symbol table for each PLT slot. Returns the number of symbols
325 /// added.
326 unsigned ParseTrampolineSymbols(lldb_private::Symtab *symbol_table,
327 lldb::user_id_t start_id,
328 const ELFSectionHeaderInfo *rela_hdr,
329 lldb::user_id_t section_id);
330
331 void ParseUnwindSymbols(lldb_private::Symtab *symbol_table,
333
334 /// Relocates debug sections
335 unsigned RelocateDebugSections(const elf::ELFSectionHeader *rel_hdr,
336 lldb::user_id_t rel_id,
337 lldb_private::Symtab *thetab);
338
339 unsigned ApplyRelocations(lldb_private::Symtab *symtab,
340 const elf::ELFHeader *hdr,
341 const elf::ELFSectionHeader *rel_hdr,
342 const elf::ELFSectionHeader *symtab_hdr,
343 const elf::ELFSectionHeader *debug_hdr,
345 lldb_private::DataExtractor &symtab_data,
346 lldb_private::DataExtractor &debug_data,
347 lldb_private::Section *rel_section);
348
349 /// Loads the section name string table into m_shstr_data. Returns the
350 /// number of bytes constituting the table.
352
353 /// Utility method for looking up a section given its name. Returns the
354 /// index of the corresponding section or zero if no section with the given
355 /// name can be found (note that section indices are always 1 based, and so
356 /// section index 0 is never valid).
357 lldb::user_id_t GetSectionIndexByName(llvm::StringRef name);
358
359 /// Returns the section header with the given id or NULL.
361
362 /// \name ELF header dump routines
363 //@{
364 static void DumpELFHeader(lldb_private::Stream *s,
365 const elf::ELFHeader &header);
366
368 unsigned char ei_data);
369
371 elf::elf_half e_type);
372 //@}
373
374 /// \name ELF program header dump routines
375 //@{
377
379 const elf::ELFProgramHeader &ph);
380
382 elf::elf_word p_type);
383
385 elf::elf_word p_flags);
386 //@}
387
388 /// \name ELF section header dump routines
389 //@{
391
393 const ELFSectionHeaderInfo &sh);
394
396 elf::elf_word sh_type);
397
399 elf::elf_xword sh_flags);
400 //@}
401
402 /// ELF dependent module dump routine.
404
405 /// ELF dump the .dynamic section
407
408 const elf::ELFDynamic *FindDynamicSymbol(unsigned tag);
409
410 unsigned PLTRelocationType();
411
414 lldb_private::ArchSpec &arch_spec,
415 lldb_private::UUID &uuid);
416
418
419 /// Takes the .gnu_debugdata and returns the decompressed object file that is
420 /// stored within that section.
421 ///
422 /// \returns either the decompressed object file stored within the
423 /// .gnu_debugdata section or \c nullptr if an error occurred or if there's no
424 /// section with that name.
425 std::shared_ptr<ObjectFileELF> GetGnuDebugDataObjectFile();
426
427 /// Get the bytes that represent the .dynamic section.
428 ///
429 /// This function will fetch the data for the .dynamic section in an ELF file.
430 /// The PT_DYNAMIC program header will be used to extract the data and this
431 /// function will fall back to using the section headers if PT_DYNAMIC isn't
432 /// found.
433 ///
434 /// \return The bytes that represent the string table data or \c std::nullopt
435 /// if an error occurred.
436 std::optional<lldb_private::DataExtractor> GetDynamicData();
437
438 /// Get the bytes that represent the dynamic string table data.
439 ///
440 /// This function will fetch the data for the string table in an ELF file. If
441 /// the ELF file is loaded from a file on disk, it will use the section
442 /// headers to extract the data and fall back to using the DT_STRTAB and
443 /// DT_STRSZ .dynamic entries.
444 ///
445 /// \return The bytes that represent the string table data or \c std::nullopt
446 /// if an error occurred.
447 std::optional<lldb_private::DataExtractor> GetDynstrData();
448
449 /// Read the bytes pointed to by the \a dyn dynamic entry.
450 ///
451 /// ELFDynamic::d_ptr values contain file addresses if we load the ELF file
452 /// form a file on disk, or they contain load addresses if they were read
453 /// from memory. This function will correctly extract the data in both cases
454 /// if it is available.
455 ///
456 /// \param[in] dyn The dynamic entry to use to fetch the data from.
457 ///
458 /// \param[in] length The number of bytes to read.
459 ///
460 /// \param[in] offset The number of bytes to skip after the d_ptr value
461 /// before reading data.
462 ///
463 /// \return The bytes that represent the dynanic entries data or
464 /// \c std::nullopt if an error occurred or the data is not available.
465 std::optional<lldb_private::DataExtractor>
466 ReadDataFromDynamic(const elf::ELFDynamic *dyn, uint64_t length,
467 uint64_t offset = 0);
468
469 /// Get the bytes that represent the dynamic symbol table from the .dynamic
470 /// section from process memory.
471 ///
472 /// This functon uses the DT_SYMTAB value from the .dynamic section to read
473 /// the symbols table data from process memory. The number of symbols in the
474 /// symbol table is calculated by looking at the DT_HASH or DT_GNU_HASH
475 /// values as the symbol count isn't stored in the .dynamic section.
476 ///
477 /// \return The bytes that represent the symbol table data from the .dynamic
478 /// section or section headers or \c std::nullopt if an error
479 /// occurred or if there is no dynamic symbol data available.
480 std::optional<lldb_private::DataExtractor>
481 GetDynsymDataFromDynamic(uint32_t &num_symbols);
482
483 /// Get the number of symbols from the DT_HASH dynamic entry.
484 std::optional<uint32_t> GetNumSymbolsFromDynamicHash();
485
486 /// Get the number of symbols from the DT_GNU_HASH dynamic entry.
487 std::optional<uint32_t> GetNumSymbolsFromDynamicGnuHash();
488};
489
490#endif // LLDB_SOURCE_PLUGINS_OBJECTFILE_ELF_OBJECTFILEELF_H
Generic structures and typedefs for ELF files.
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.
std::vector< elf::ELFProgramHeader > ProgramHeaderColl
static void DumpELFHeader(lldb_private::Stream *s, const elf::ELFHeader &header)
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 ...
lldb_private::ArchSpec m_arch_spec
The architecture detected from parsing elf file contents.
static void DumpELFSectionHeader_sh_type(lldb_private::Stream *s, elf::elf_word sh_type)
std::shared_ptr< ObjectFileELF > m_gnu_debug_data_object_file
Object file parsed from .gnu_debugdata section (.
SectionHeaderColl::iterator SectionHeaderCollIter
uint32_t m_gnu_debuglink_crc
unsigned RelocateDebugSections(const elf::ELFSectionHeader *rel_hdr, lldb::user_id_t rel_id, lldb_private::Symtab *thetab)
Relocates debug sections.
bool isA(const void *ClassID) const override
bool AnySegmentHasPhysicalAddress()
static bool classof(const ObjectFile *obj)
static void Initialize()
static void DumpELFProgramHeader(lldb_private::Stream *s, const elf::ELFProgramHeader &ph)
lldb_private::Address m_entry_point_address
Cached value of the entry point for this module.
size_t ReadSectionData(lldb_private::Section *section, lldb::offset_t section_offset, void *dst, size_t dst_len) override
llvm::StringRef StripLinkerSymbolAnnotations(llvm::StringRef symbol_name) const override
static void ParseARMAttributes(lldb_private::DataExtractor &data, uint64_t length, lldb_private::ArchSpec &arch_spec)
lldb_private::DataExtractor GetSegmentData(const elf::ELFProgramHeader &H)
void RelocateSection(lldb_private::Section *section) override
Perform relocations on the section if necessary.
FileAddressToAddressClassMap m_address_class_map
The address class for each symbol in the elf file.
static llvm::StringRef GetPluginDescriptionStatic()
static const uint32_t g_core_uuid_magic
bool ReExportedLibrariesShadowLocalDefinitions() const override
Whether a symbol that this object file has not itself tagged as a re-export can still be shadowed by ...
bool IsExecutable() const override
Tells whether this object file is capable of being the main executable for a process.
void DumpDependentModules(lldb_private::Stream *s)
ELF dependent module dump routine.
static void DumpELFHeader_e_type(lldb_private::Stream *s, elf::elf_half e_type)
static size_t GetProgramHeaderInfo(ProgramHeaderColl &program_headers, lldb_private::DataExtractor &object_data, const elf::ELFHeader &header)
std::optional< lldb_private::DataExtractor > GetDynsymDataFromDynamic(uint32_t &num_symbols)
Get the bytes that represent the dynamic symbol table from the .dynamic section from process memory.
DynamicSymbolColl m_dynamic_symbols
Collection of symbols from the dynamic table.
static void DumpELFSectionHeader(lldb_private::Stream *s, const ELFSectionHeaderInfo &sh)
std::vector< ELFSectionHeaderInfo > SectionHeaderColl
static void DumpELFHeader_e_ident_EI_DATA(lldb_private::Stream *s, unsigned char ei_data)
lldb_private::ArchSpec GetArchitecture() override
Get the ArchSpec for this object file.
std::optional< lldb_private::FileSpec > GetDebugLink()
Return the contents of the .gnu_debuglink section, if the object file contains it.
llvm::StringRef GetPluginName() override
lldb_private::AddressClass GetAddressClass(lldb::addr_t file_addr) override
Get the address type given a file address in an object file.
static void DumpELFSectionHeader_sh_flags(lldb_private::Stream *s, elf::elf_xword sh_flags)
DynamicSymbolColl::const_iterator DynamicSymbolCollConstIter
lldb_private::UUID GetUUID() override
Gets the UUID for this object file.
std::optional< uint32_t > GetNumSymbolsFromDynamicGnuHash()
Get the number of symbols from the DT_GNU_HASH dynamic entry.
std::optional< lldb_private::DataExtractor > ReadDataFromDynamic(const elf::ELFDynamic *dyn, uint64_t length, uint64_t offset=0)
Read the bytes pointed to by the dyn dynamic entry.
static void DumpELFProgramHeader_p_type(lldb_private::Stream *s, elf::elf_word p_type)
static lldb_private::Status RefineModuleDetailsFromNote(lldb_private::DataExtractor &data, lldb_private::ArchSpec &arch_spec, lldb_private::UUID &uuid)
size_t SectionIndex(const SectionHeaderCollIter &I)
Returns the index of the given section header.
static void DumpELFProgramHeader_p_flags(lldb_private::Stream *s, elf::elf_word p_flags)
static llvm::StringRef GetPluginNameStatic()
size_t ParseDependentModules()
Scans the dynamic section and locates all dependent modules (shared libraries) populating m_filespec_...
void DumpELFSectionHeaders(lldb_private::Stream *s)
static lldb_private::ObjectFile * CreateInstance(const lldb::ModuleSP &module_sp, lldb::DataExtractorSP extractor_sp, lldb::offset_t data_offset, const lldb_private::FileSpec *file, lldb::offset_t file_offset, lldb::offset_t length)
std::shared_ptr< ObjectFileELF > GetGnuDebugDataObjectFile()
Takes the .gnu_debugdata and returns the decompressed object file that is stored within that section.
static const uint32_t m_plugin_version
Version of this reader common to all plugins based on this class.
static lldb::WritableDataBufferSP MapFileDataWritable(const lldb_private::FileSpec &file, uint64_t Size, uint64_t Offset)
void Dump(lldb_private::Stream *s) override
Dump a description of this object to a Stream.
static uint32_t CalculateELFNotesSegmentsCRC32(const ProgramHeaderColl &program_headers, lldb_private::DataExtractor &data)
lldb_private::UUID m_uuid
ELF build ID.
void DumpELFProgramHeaders(lldb_private::Stream *s)
std::pair< unsigned, FileAddressToAddressClassMap > ParseSymbolTable(lldb_private::Symtab *symbol_table, lldb::user_id_t start_id, lldb_private::Section *symtab)
Populates the symbol table with all non-dynamic linker symbols.
size_t ParseDynamicSymbols()
Parses the dynamic symbol table and populates m_dynamic_symbols.
static lldb_private::ModuleSpecList GetModuleSpecifications(const lldb_private::FileSpec &file, lldb::DataExtractorSP &extractor_sp, lldb::offset_t file_offset, lldb::offset_t length)
std::optional< lldb_private::DataExtractor > GetDynamicData()
Get the bytes that represent the .dynamic section.
ObjectFile::Type CalculateType() override
The object file should be able to calculate its type by looking at its file header and possibly the s...
lldb::SectionType GetSectionType(const ELFSectionHeaderInfo &H) const
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...
lldb_private::FileSpecList GetReExportedLibraries() override
Gets the file spec list of libraries re-exported by this object file.
std::unique_ptr< lldb_private::FileSpecList > m_filespec_up
List of file specifications corresponding to the modules (shared libraries) on which this object file...
std::optional< uint32_t > GetNumSymbolsFromDynamicHash()
Get the number of symbols from the DT_HASH dynamic entry.
bool ParseProgramHeaders()
Parses all section headers present in this object file and populates m_program_headers.
DynamicSymbolColl::iterator DynamicSymbolCollIter
size_t GetSectionHeaderStringTable()
Loads the section name string table into m_shstr_data.
std::vector< LoadableData > GetLoadableData(lldb_private::Target &target) override
Loads this objfile to memory.
const ELFSectionHeaderInfo * GetSectionHeaderByIndex(lldb::user_id_t id)
Returns the section header with the given id or NULL.
void CreateSections(lldb_private::SectionList &unified_section_list) override
static bool MagicBytesMatch(lldb::DataBufferSP data_sp, lldb::addr_t offset, lldb::addr_t length)
ObjectFileELF(const lldb::ModuleSP &module_sp, lldb::DataExtractorSP extractor_sp, lldb::offset_t data_offset, const lldb_private::FileSpec *file, lldb::offset_t offset, lldb::offset_t length)
uint32_t GetAddressByteSize() const override
Gets the address size in bytes for the current object file.
SectionHeaderColl::const_iterator SectionHeaderCollConstIter
ProgramHeaderColl m_program_headers
Collection of program headers.
void DumpELFDynamic(lldb_private::Stream *s)
ELF dump the .dynamic section.
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)
lldb::ByteOrder GetByteOrder() const override
Gets whether endian swapping should occur when extracting data from this object file.
bool ParseHeader() override
Attempts to parse the object header.
static void ParseRISCVAttributes(const lldb_private::DataExtractor &data, uint64_t length, lldb_private::ArchSpec &arch_spec)
static void Terminate()
elf::ELFHeader m_header
ELF file header.
std::string m_gnu_debuglink_file
ELF .gnu_debuglink file and crc data if available.
void ParseUnwindSymbols(lldb_private::Symtab *symbol_table, lldb_private::DWARFCallFrameInfo *eh_frame)
std::pair< unsigned, FileAddressToAddressClassMap > 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().
SectionHeaderColl m_section_headers
Collection of section headers.
std::vector< ELFDynamicWithName > DynamicSymbolColl
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...
static char ID
ObjectFile::Strata CalculateStrata() override
The object file should be able to calculate the strata of the object file.
void ParseSymtab(lldb_private::Symtab &symtab) override
Parse the symbol table into the provides symbol table object.
unsigned PLTRelocationType()
static lldb_private::ObjectFile * CreateMemoryInstance(const lldb::ModuleSP &module_sp, lldb::WritableDataBufferSP data_sp, const lldb::ProcessSP &process_sp, lldb::addr_t header_addr)
lldb::user_id_t GetSectionIndexByName(llvm::StringRef name)
Utility method for looking up a section given its name.
lldb::addr_t m_dynamic_base_addr
The file address of the .dynamic section.
uint32_t GetDependentModules(lldb_private::FileSpecList &files) override
Extract the dependent modules from an object file.
size_t ParseSectionHeaders()
Parses all section headers present in this object file and populates m_section_headers.
lldb_private::Address GetBaseAddress() override
Returns base address of this object file.
bool IsStripped() override
Detect if this object file has been stripped of local symbols.
const elf::ELFDynamic * FindDynamicSymbol(unsigned tag)
std::map< lldb::addr_t, lldb_private::AddressClass > FileAddressToAddressClassMap
An ordered map of file address to address class.
llvm::ArrayRef< elf::ELFProgramHeader > ProgramHeaders()
std::optional< lldb_private::DataExtractor > GetDynstrData()
Get the bytes that represent the dynamic string table data.
lldb_private::Address GetImageInfoAddress(lldb_private::Target *target) override
Similar to Process::GetImageInfoAddress().
A section + offset based address class.
Definition Address.h:62
An architecture specification class.
Definition ArchSpec.h:32
An data extractor class.
A file collection class.
A file utility class.
Definition FileSpec.h:56
A plug-in interface definition class for object file parsers.
Definition ObjectFile.h:46
ObjectFile(const lldb::ModuleSP &module_sp, const FileSpec *file_spec_ptr, lldb::offset_t file_offset, lldb::offset_t length, lldb::DataExtractorSP extractor_sp, lldb::offset_t data_offset)
Construct with a parent module, offset, and header data.
An error handling class.
Definition Status.h:118
A stream class that can stream formatted output to a file.
Definition Stream.h:28
Represents UUID's of various sizes.
Definition UUID.h:27
#define LLDB_INVALID_ADDRESS
uint32_t elf_word
Definition ELFHeader.h:44
uint64_t elf_xword
Definition ELFHeader.h:47
uint16_t elf_half
Definition ELFHeader.h:43
uint64_t offset_t
Definition lldb-types.h:86
std::shared_ptr< lldb_private::Process > ProcessSP
ByteOrder
Byte ordering definitions.
uint64_t user_id_t
Definition lldb-types.h:83
std::shared_ptr< lldb_private::DataBuffer > DataBufferSP
std::shared_ptr< lldb_private::WritableDataBuffer > WritableDataBufferSP
uint64_t addr_t
Definition lldb-types.h:80
std::shared_ptr< lldb_private::DataExtractor > DataExtractorSP
std::shared_ptr< lldb_private::Module > ModuleSP
bool Parse(const lldb_private::DataExtractor &data, lldb::offset_t *offset)
Parse an ELFNote entry from the given DataExtractor starting at position offset.
size_t GetByteSize() const
elf::elf_word n_descsz
ELFNote()=default
std::string n_name
elf::elf_word n_namesz
elf::elf_word n_type
Represents an entry in an ELF dynamic table.
Definition ELFHeader.h:276
Generic representation of an ELF file header.
Definition ELFHeader.h:56
Generic representation of an ELF program header.
Definition ELFHeader.h:192
Generic representation of an ELF section header.
Definition ELFHeader.h:159