blob: 2909f4e52e4aab2233b181413307881841446470 [file] [log] [blame]
Stephen Wilsonf325ba92010-07-13 23:07:23 +00001//===-- ObjectFileELF.h --------------------------------------- -*- C++ -*-===//
Chris Lattner30fdc8d2010-06-08 16:52:24 +00002//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10#ifndef liblldb_ObjectFileELF_h_
11#define liblldb_ObjectFileELF_h_
12
Eugene Zelenko8157a882015-10-23 16:56:07 +000013// C Includes
Chris Lattner30fdc8d2010-06-08 16:52:24 +000014#include <stdint.h>
Eugene Zelenko8157a882015-10-23 16:56:07 +000015
16// C++ Includes
Chris Lattner30fdc8d2010-06-08 16:52:24 +000017#include <vector>
18
Chris Lattner30fdc8d2010-06-08 16:52:24 +000019#include "lldb/Symbol/ObjectFile.h"
Pavel Labath5f19b902017-11-13 16:16:33 +000020#include "lldb/Utility/ArchSpec.h"
Zachary Turner5713a052017-03-22 18:40:07 +000021#include "lldb/Utility/FileSpec.h"
22#include "lldb/Utility/UUID.h"
Kate Stoneb9c1b512016-09-06 20:57:50 +000023#include "lldb/lldb-private.h"
Chris Lattner30fdc8d2010-06-08 16:52:24 +000024
Stephen Wilsonf325ba92010-07-13 23:07:23 +000025#include "ELFHeader.h"
Chris Lattner30fdc8d2010-06-08 16:52:24 +000026
Kate Stoneb9c1b512016-09-06 20:57:50 +000027struct ELFNote {
28 elf::elf_word n_namesz;
29 elf::elf_word n_descsz;
30 elf::elf_word n_type;
Ed Mastec113ff82013-12-02 17:49:13 +000031
Kate Stoneb9c1b512016-09-06 20:57:50 +000032 std::string n_name;
Ed Mastec113ff82013-12-02 17:49:13 +000033
Kate Stoneb9c1b512016-09-06 20:57:50 +000034 ELFNote() : n_namesz(0), n_descsz(0), n_type(0) {}
Ed Mastec113ff82013-12-02 17:49:13 +000035
Kate Stoneb9c1b512016-09-06 20:57:50 +000036 /// Parse an ELFNote entry from the given DataExtractor starting at position
37 /// \p offset.
38 ///
39 /// @param[in] data
40 /// The DataExtractor to read from.
41 ///
42 /// @param[in,out] offset
43 /// Pointer to an offset in the data. On return the offset will be
44 /// advanced by the number of bytes read.
45 ///
46 /// @return
47 /// True if the ELFRel entry was successfully read and false otherwise.
48 bool Parse(const lldb_private::DataExtractor &data, lldb::offset_t *offset);
Greg Claytonb704b692015-10-28 18:04:38 +000049
Kate Stoneb9c1b512016-09-06 20:57:50 +000050 size_t GetByteSize() const {
51 return 12 + llvm::alignTo(n_namesz, 4) + llvm::alignTo(n_descsz, 4);
52 }
Ed Mastec113ff82013-12-02 17:49:13 +000053};
54
Stephen Wilsonf325ba92010-07-13 23:07:23 +000055//------------------------------------------------------------------------------
56/// @class ObjectFileELF
57/// @brief Generic ELF object file reader.
58///
59/// This class provides a generic ELF (32/64 bit) reader plugin implementing the
60/// ObjectFile protocol.
Kate Stoneb9c1b512016-09-06 20:57:50 +000061class ObjectFileELF : public lldb_private::ObjectFile {
Chris Lattner30fdc8d2010-06-08 16:52:24 +000062public:
Kate Stoneb9c1b512016-09-06 20:57:50 +000063 ~ObjectFileELF() override;
Eugene Zelenko8157a882015-10-23 16:56:07 +000064
Kate Stoneb9c1b512016-09-06 20:57:50 +000065 //------------------------------------------------------------------
66 // Static Functions
67 //------------------------------------------------------------------
68 static void Initialize();
Chris Lattner30fdc8d2010-06-08 16:52:24 +000069
Kate Stoneb9c1b512016-09-06 20:57:50 +000070 static void Terminate();
Chris Lattner30fdc8d2010-06-08 16:52:24 +000071
Kate Stoneb9c1b512016-09-06 20:57:50 +000072 static lldb_private::ConstString GetPluginNameStatic();
Chris Lattner30fdc8d2010-06-08 16:52:24 +000073
Kate Stoneb9c1b512016-09-06 20:57:50 +000074 static const char *GetPluginDescriptionStatic();
Chris Lattner30fdc8d2010-06-08 16:52:24 +000075
Kate Stoneb9c1b512016-09-06 20:57:50 +000076 static lldb_private::ObjectFile *
77 CreateInstance(const lldb::ModuleSP &module_sp, lldb::DataBufferSP &data_sp,
78 lldb::offset_t data_offset, const lldb_private::FileSpec *file,
79 lldb::offset_t file_offset, lldb::offset_t length);
Chris Lattner30fdc8d2010-06-08 16:52:24 +000080
Kate Stoneb9c1b512016-09-06 20:57:50 +000081 static lldb_private::ObjectFile *CreateMemoryInstance(
82 const lldb::ModuleSP &module_sp, lldb::DataBufferSP &data_sp,
83 const lldb::ProcessSP &process_sp, lldb::addr_t header_addr);
Greg Claytonc9660542012-02-05 02:38:54 +000084
Kate Stoneb9c1b512016-09-06 20:57:50 +000085 static size_t GetModuleSpecifications(const lldb_private::FileSpec &file,
86 lldb::DataBufferSP &data_sp,
87 lldb::offset_t data_offset,
88 lldb::offset_t file_offset,
89 lldb::offset_t length,
90 lldb_private::ModuleSpecList &specs);
Michael Sartain9f0013d2013-05-17 00:20:21 +000091
Kate Stoneb9c1b512016-09-06 20:57:50 +000092 static bool MagicBytesMatch(lldb::DataBufferSP &data_sp, lldb::addr_t offset,
93 lldb::addr_t length);
Michael Sartain9f0013d2013-05-17 00:20:21 +000094
Kate Stoneb9c1b512016-09-06 20:57:50 +000095 //------------------------------------------------------------------
96 // PluginInterface protocol
97 //------------------------------------------------------------------
98 lldb_private::ConstString GetPluginName() override;
Chris Lattner30fdc8d2010-06-08 16:52:24 +000099
Kate Stoneb9c1b512016-09-06 20:57:50 +0000100 uint32_t GetPluginVersion() override;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000101
Kate Stoneb9c1b512016-09-06 20:57:50 +0000102 //------------------------------------------------------------------
103 // ObjectFile Protocol.
104 //------------------------------------------------------------------
105 bool ParseHeader() override;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000106
Kate Stoneb9c1b512016-09-06 20:57:50 +0000107 bool SetLoadAddress(lldb_private::Target &target, lldb::addr_t value,
108 bool value_is_offset) override;
Steve Pucci9e02dac2014-02-06 19:02:19 +0000109
Kate Stoneb9c1b512016-09-06 20:57:50 +0000110 lldb::ByteOrder GetByteOrder() const override;
Stephen Wilsonf325ba92010-07-13 23:07:23 +0000111
Kate Stoneb9c1b512016-09-06 20:57:50 +0000112 bool IsExecutable() const override;
Jim Ingham5aee1622010-08-09 23:31:02 +0000113
Kate Stoneb9c1b512016-09-06 20:57:50 +0000114 uint32_t GetAddressByteSize() const override;
Stephen Wilsonf325ba92010-07-13 23:07:23 +0000115
Kate Stoneb9c1b512016-09-06 20:57:50 +0000116 lldb::AddressClass GetAddressClass(lldb::addr_t file_addr) override;
Todd Fialafbd703a2014-09-15 22:33:39 +0000117
Kate Stoneb9c1b512016-09-06 20:57:50 +0000118 lldb_private::Symtab *GetSymtab() override;
Stephen Wilsonf325ba92010-07-13 23:07:23 +0000119
Kate Stoneb9c1b512016-09-06 20:57:50 +0000120 bool IsStripped() override;
Greg Clayton3046e662013-07-10 01:23:25 +0000121
Kate Stoneb9c1b512016-09-06 20:57:50 +0000122 void CreateSections(lldb_private::SectionList &unified_section_list) override;
Stephen Wilsonf325ba92010-07-13 23:07:23 +0000123
Kate Stoneb9c1b512016-09-06 20:57:50 +0000124 void Dump(lldb_private::Stream *s) override;
Stephen Wilsonf325ba92010-07-13 23:07:23 +0000125
Kate Stoneb9c1b512016-09-06 20:57:50 +0000126 bool GetArchitecture(lldb_private::ArchSpec &arch) override;
Stephen Wilsonf325ba92010-07-13 23:07:23 +0000127
Kate Stoneb9c1b512016-09-06 20:57:50 +0000128 bool GetUUID(lldb_private::UUID *uuid) override;
Stephen Wilsonf325ba92010-07-13 23:07:23 +0000129
Kate Stoneb9c1b512016-09-06 20:57:50 +0000130 lldb_private::FileSpecList GetDebugSymbolFilePaths() override;
Michael Sartaina7499c92013-07-01 19:45:50 +0000131
Kate Stoneb9c1b512016-09-06 20:57:50 +0000132 uint32_t GetDependentModules(lldb_private::FileSpecList &files) override;
Stephen Wilsonf325ba92010-07-13 23:07:23 +0000133
Kate Stoneb9c1b512016-09-06 20:57:50 +0000134 lldb_private::Address
135 GetImageInfoAddress(lldb_private::Target *target) override;
Stephen Wilson2ab0a582011-01-15 00:08:44 +0000136
Kate Stoneb9c1b512016-09-06 20:57:50 +0000137 lldb_private::Address GetEntryPointAddress() override;
Ashok Thirumurthi4822d922013-07-11 20:39:00 +0000138
Kate Stoneb9c1b512016-09-06 20:57:50 +0000139 ObjectFile::Type CalculateType() override;
Ashok Thirumurthi4822d922013-07-11 20:39:00 +0000140
Kate Stoneb9c1b512016-09-06 20:57:50 +0000141 ObjectFile::Strata CalculateStrata() override;
Ashok Thirumurthi4822d922013-07-11 20:39:00 +0000142
Pavel Labathe2867bc2017-12-15 14:23:58 +0000143 size_t ReadSectionData(lldb_private::Section *section,
144 lldb::offset_t section_offset, void *dst,
145 size_t dst_len) override;
146
147 size_t ReadSectionData(lldb_private::Section *section,
148 lldb_private::DataExtractor &section_data) override;
149
Kate Stoneb9c1b512016-09-06 20:57:50 +0000150 // Returns number of program headers found in the ELF file.
151 size_t GetProgramHeaderCount();
152
153 // Returns the program header with the given index.
154 const elf::ELFProgramHeader *GetProgramHeaderByIndex(lldb::user_id_t id);
155
156 // Returns segment data for the given index.
157 lldb_private::DataExtractor GetSegmentDataByIndex(lldb::user_id_t id);
158
Pavel Labath4d35d6b2017-05-02 10:17:30 +0000159 llvm::StringRef
Kate Stoneb9c1b512016-09-06 20:57:50 +0000160 StripLinkerSymbolAnnotations(llvm::StringRef symbol_name) const override;
Pavel Labathc6ae7ea2015-03-04 10:25:22 +0000161
Ed Masted13f6912017-10-02 14:35:07 +0000162 void RelocateSection(lldb_private::Section *section) override;
163
Stephen Wilsonf325ba92010-07-13 23:07:23 +0000164private:
Kate Stoneb9c1b512016-09-06 20:57:50 +0000165 ObjectFileELF(const lldb::ModuleSP &module_sp, lldb::DataBufferSP &data_sp,
166 lldb::offset_t data_offset, const lldb_private::FileSpec *file,
167 lldb::offset_t offset, lldb::offset_t length);
Stephen Wilsonf325ba92010-07-13 23:07:23 +0000168
Kate Stoneb9c1b512016-09-06 20:57:50 +0000169 ObjectFileELF(const lldb::ModuleSP &module_sp,
170 lldb::DataBufferSP &header_data_sp,
171 const lldb::ProcessSP &process_sp, lldb::addr_t header_addr);
Andrew MacPherson17220c12014-03-05 10:12:43 +0000172
Kate Stoneb9c1b512016-09-06 20:57:50 +0000173 typedef std::vector<elf::ELFProgramHeader> ProgramHeaderColl;
174 typedef ProgramHeaderColl::iterator ProgramHeaderCollIter;
175 typedef ProgramHeaderColl::const_iterator ProgramHeaderCollConstIter;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000176
Kate Stoneb9c1b512016-09-06 20:57:50 +0000177 struct ELFSectionHeaderInfo : public elf::ELFSectionHeader {
178 lldb_private::ConstString section_name;
179 };
Eugene Zelenko8157a882015-10-23 16:56:07 +0000180
Kate Stoneb9c1b512016-09-06 20:57:50 +0000181 typedef std::vector<ELFSectionHeaderInfo> SectionHeaderColl;
182 typedef SectionHeaderColl::iterator SectionHeaderCollIter;
183 typedef SectionHeaderColl::const_iterator SectionHeaderCollConstIter;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000184
Kate Stoneb9c1b512016-09-06 20:57:50 +0000185 typedef std::vector<elf::ELFDynamic> DynamicSymbolColl;
186 typedef DynamicSymbolColl::iterator DynamicSymbolCollIter;
187 typedef DynamicSymbolColl::const_iterator DynamicSymbolCollConstIter;
Stephen Wilson499b40e2011-03-30 16:07:05 +0000188
Kate Stoneb9c1b512016-09-06 20:57:50 +0000189 typedef std::map<lldb::addr_t, lldb::AddressClass>
190 FileAddressToAddressClassMap;
Tamas Berghammer83544cf2015-04-07 10:43:50 +0000191
Kate Stoneb9c1b512016-09-06 20:57:50 +0000192 /// Version of this reader common to all plugins based on this class.
193 static const uint32_t m_plugin_version = 1;
194 static const uint32_t g_core_uuid_magic;
Stephen Wilsonf325ba92010-07-13 23:07:23 +0000195
Kate Stoneb9c1b512016-09-06 20:57:50 +0000196 /// ELF file header.
197 elf::ELFHeader m_header;
Stephen Wilsonf325ba92010-07-13 23:07:23 +0000198
Kate Stoneb9c1b512016-09-06 20:57:50 +0000199 /// ELF build ID.
200 lldb_private::UUID m_uuid;
Michael Sartainc836ae72013-05-23 20:57:03 +0000201
Kate Stoneb9c1b512016-09-06 20:57:50 +0000202 /// ELF .gnu_debuglink file and crc data if available.
203 std::string m_gnu_debuglink_file;
204 uint32_t m_gnu_debuglink_crc;
Michael Sartaina7499c92013-07-01 19:45:50 +0000205
Kate Stoneb9c1b512016-09-06 20:57:50 +0000206 /// Collection of program headers.
207 ProgramHeaderColl m_program_headers;
Stephen Wilsonf325ba92010-07-13 23:07:23 +0000208
Kate Stoneb9c1b512016-09-06 20:57:50 +0000209 /// Collection of section headers.
210 SectionHeaderColl m_section_headers;
Stephen Wilsonf325ba92010-07-13 23:07:23 +0000211
Kate Stoneb9c1b512016-09-06 20:57:50 +0000212 /// Collection of symbols from the dynamic table.
213 DynamicSymbolColl m_dynamic_symbols;
Stephen Wilson499b40e2011-03-30 16:07:05 +0000214
Kate Stoneb9c1b512016-09-06 20:57:50 +0000215 /// 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_ap;
Stephen Wilsonf325ba92010-07-13 23:07:23 +0000218
Kate Stoneb9c1b512016-09-06 20:57:50 +0000219 /// Cached value of the entry point for this module.
220 lldb_private::Address m_entry_point_address;
Stephen Wilson499b40e2011-03-30 16:07:05 +0000221
Kate Stoneb9c1b512016-09-06 20:57:50 +0000222 /// The architecture detected from parsing elf file contents.
223 lldb_private::ArchSpec m_arch_spec;
Todd Fialab91de782014-06-27 16:52:49 +0000224
Kate Stoneb9c1b512016-09-06 20:57:50 +0000225 /// The address class for each symbol in the elf file
226 FileAddressToAddressClassMap m_address_class_map;
Tamas Berghammer83544cf2015-04-07 10:43:50 +0000227
Kate Stoneb9c1b512016-09-06 20:57:50 +0000228 /// Returns a 1 based index of the given section header.
229 size_t SectionIndex(const SectionHeaderCollIter &I);
Stephen Wilsonf325ba92010-07-13 23:07:23 +0000230
Kate Stoneb9c1b512016-09-06 20:57:50 +0000231 /// Returns a 1 based index of the given section header.
232 size_t SectionIndex(const SectionHeaderCollConstIter &I) const;
Stephen Wilsonf325ba92010-07-13 23:07:23 +0000233
Kate Stoneb9c1b512016-09-06 20:57:50 +0000234 // Parses the ELF program headers.
235 static size_t GetProgramHeaderInfo(ProgramHeaderColl &program_headers,
Pavel Labathdf1a0d12017-06-20 08:11:47 +0000236 lldb_private::DataExtractor &object_data,
Kate Stoneb9c1b512016-09-06 20:57:50 +0000237 const elf::ELFHeader &header);
Todd Fiala4339f3a2014-03-25 19:29:09 +0000238
Kate Stoneb9c1b512016-09-06 20:57:50 +0000239 // Finds PT_NOTE segments and calculates their crc sum.
240 static uint32_t
241 CalculateELFNotesSegmentsCRC32(const ProgramHeaderColl &program_headers,
242 lldb_private::DataExtractor &data);
Todd Fiala4339f3a2014-03-25 19:29:09 +0000243
Kate Stoneb9c1b512016-09-06 20:57:50 +0000244 /// 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 the number of headers parsed.
247 size_t ParseProgramHeaders();
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000248
Kate Stoneb9c1b512016-09-06 20:57:50 +0000249 /// 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();
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000253
Kate Stoneb9c1b512016-09-06 20:57:50 +0000254 static void ParseARMAttributes(lldb_private::DataExtractor &data,
255 uint64_t length,
256 lldb_private::ArchSpec &arch_spec);
Saleem Abdulrasoold2d15042016-04-23 16:00:15 +0000257
Kate Stoneb9c1b512016-09-06 20:57:50 +0000258 /// Parses the elf section headers and returns the uuid, debug link name, crc,
259 /// archspec.
260 static size_t GetSectionHeaderInfo(SectionHeaderColl &section_headers,
Pavel Labathdf1a0d12017-06-20 08:11:47 +0000261 lldb_private::DataExtractor &object_data,
Kate Stoneb9c1b512016-09-06 20:57:50 +0000262 const elf::ELFHeader &header,
263 lldb_private::UUID &uuid,
264 std::string &gnu_debuglink_file,
265 uint32_t &gnu_debuglink_crc,
266 lldb_private::ArchSpec &arch_spec);
Michael Sartaina7499c92013-07-01 19:45:50 +0000267
Kate Stoneb9c1b512016-09-06 20:57:50 +0000268 /// Scans the dynamic section and locates all dependent modules (shared
269 /// libraries) populating m_filespec_ap. This method will compute the
270 /// dependent module list only once. Returns the number of dependent
271 /// modules parsed.
272 size_t ParseDependentModules();
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000273
Kate Stoneb9c1b512016-09-06 20:57:50 +0000274 /// Parses the dynamic symbol table and populates m_dynamic_symbols. The
275 /// vector retains the order as found in the object file. Returns the
276 /// number of dynamic symbols parsed.
277 size_t ParseDynamicSymbols();
Stephen Wilson499b40e2011-03-30 16:07:05 +0000278
Kate Stoneb9c1b512016-09-06 20:57:50 +0000279 /// Populates m_symtab_ap will all non-dynamic linker symbols. This method
280 /// will parse the symbols only once. Returns the number of symbols parsed.
281 unsigned ParseSymbolTable(lldb_private::Symtab *symbol_table,
282 lldb::user_id_t start_id,
283 lldb_private::Section *symtab);
Stephen Wilsonf325ba92010-07-13 23:07:23 +0000284
Kate Stoneb9c1b512016-09-06 20:57:50 +0000285 /// Helper routine for ParseSymbolTable().
286 unsigned ParseSymbols(lldb_private::Symtab *symbol_table,
287 lldb::user_id_t start_id,
288 lldb_private::SectionList *section_list,
289 const size_t num_symbols,
290 const lldb_private::DataExtractor &symtab_data,
291 const lldb_private::DataExtractor &strtab_data);
Michael Sartaina7499c92013-07-01 19:45:50 +0000292
Kate Stoneb9c1b512016-09-06 20:57:50 +0000293 /// Scans the relocation entries and adds a set of artificial symbols to the
294 /// given symbol table for each PLT slot. Returns the number of symbols
295 /// added.
296 unsigned ParseTrampolineSymbols(lldb_private::Symtab *symbol_table,
297 lldb::user_id_t start_id,
298 const ELFSectionHeaderInfo *rela_hdr,
299 lldb::user_id_t section_id);
Stephen Wilson499b40e2011-03-30 16:07:05 +0000300
Kate Stoneb9c1b512016-09-06 20:57:50 +0000301 void ParseUnwindSymbols(lldb_private::Symtab *symbol_table,
302 lldb_private::DWARFCallFrameInfo *eh_frame);
Tamas Berghammer6b63b142016-02-18 11:12:18 +0000303
Kate Stoneb9c1b512016-09-06 20:57:50 +0000304 /// Relocates debug sections
305 unsigned RelocateDebugSections(const elf::ELFSectionHeader *rel_hdr,
Ed Masted13f6912017-10-02 14:35:07 +0000306 lldb::user_id_t rel_id,
307 lldb_private::Symtab *thetab);
Andrew MacPherson17220c12014-03-05 10:12:43 +0000308
Ed Masted13f6912017-10-02 14:35:07 +0000309 unsigned ApplyRelocations(lldb_private::Symtab *symtab,
310 const elf::ELFHeader *hdr,
311 const elf::ELFSectionHeader *rel_hdr,
312 const elf::ELFSectionHeader *symtab_hdr,
313 const elf::ELFSectionHeader *debug_hdr,
314 lldb_private::DataExtractor &rel_data,
315 lldb_private::DataExtractor &symtab_data,
316 lldb_private::DataExtractor &debug_data,
317 lldb_private::Section *rel_section);
Andrew MacPherson17220c12014-03-05 10:12:43 +0000318
Kate Stoneb9c1b512016-09-06 20:57:50 +0000319 /// Loads the section name string table into m_shstr_data. Returns the
320 /// number of bytes constituting the table.
321 size_t GetSectionHeaderStringTable();
Andrew MacPherson17220c12014-03-05 10:12:43 +0000322
Kate Stoneb9c1b512016-09-06 20:57:50 +0000323 /// Utility method for looking up a section given its name. Returns the
324 /// index of the corresponding section or zero if no section with the given
325 /// name can be found (note that section indices are always 1 based, and so
326 /// section index 0 is never valid).
327 lldb::user_id_t GetSectionIndexByName(const char *name);
Andrew MacPherson17220c12014-03-05 10:12:43 +0000328
Kate Stoneb9c1b512016-09-06 20:57:50 +0000329 // Returns the ID of the first section that has the given type.
330 lldb::user_id_t GetSectionIndexByType(unsigned type);
Andrew MacPherson17220c12014-03-05 10:12:43 +0000331
Kate Stoneb9c1b512016-09-06 20:57:50 +0000332 /// Returns the section header with the given id or NULL.
333 const ELFSectionHeaderInfo *GetSectionHeaderByIndex(lldb::user_id_t id);
Stephen Wilson499b40e2011-03-30 16:07:05 +0000334
Kate Stoneb9c1b512016-09-06 20:57:50 +0000335 /// @name ELF header dump routines
336 //@{
337 static void DumpELFHeader(lldb_private::Stream *s,
338 const elf::ELFHeader &header);
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000339
Kate Stoneb9c1b512016-09-06 20:57:50 +0000340 static void DumpELFHeader_e_ident_EI_DATA(lldb_private::Stream *s,
341 unsigned char ei_data);
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000342
Kate Stoneb9c1b512016-09-06 20:57:50 +0000343 static void DumpELFHeader_e_type(lldb_private::Stream *s,
344 elf::elf_half e_type);
345 //@}
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000346
Kate Stoneb9c1b512016-09-06 20:57:50 +0000347 /// @name ELF program header dump routines
348 //@{
349 void DumpELFProgramHeaders(lldb_private::Stream *s);
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000350
Kate Stoneb9c1b512016-09-06 20:57:50 +0000351 static void DumpELFProgramHeader(lldb_private::Stream *s,
352 const elf::ELFProgramHeader &ph);
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000353
Kate Stoneb9c1b512016-09-06 20:57:50 +0000354 static void DumpELFProgramHeader_p_type(lldb_private::Stream *s,
355 elf::elf_word p_type);
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000356
Kate Stoneb9c1b512016-09-06 20:57:50 +0000357 static void DumpELFProgramHeader_p_flags(lldb_private::Stream *s,
358 elf::elf_word p_flags);
359 //@}
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000360
Kate Stoneb9c1b512016-09-06 20:57:50 +0000361 /// @name ELF section header dump routines
362 //@{
363 void DumpELFSectionHeaders(lldb_private::Stream *s);
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000364
Kate Stoneb9c1b512016-09-06 20:57:50 +0000365 static void DumpELFSectionHeader(lldb_private::Stream *s,
366 const ELFSectionHeaderInfo &sh);
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000367
Kate Stoneb9c1b512016-09-06 20:57:50 +0000368 static void DumpELFSectionHeader_sh_type(lldb_private::Stream *s,
369 elf::elf_word sh_type);
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000370
Kate Stoneb9c1b512016-09-06 20:57:50 +0000371 static void DumpELFSectionHeader_sh_flags(lldb_private::Stream *s,
372 elf::elf_xword sh_flags);
373 //@}
Stephen Wilsonf325ba92010-07-13 23:07:23 +0000374
Kate Stoneb9c1b512016-09-06 20:57:50 +0000375 /// ELF dependent module dump routine.
376 void DumpDependentModules(lldb_private::Stream *s);
Stephen Wilsonf325ba92010-07-13 23:07:23 +0000377
Kate Stoneb9c1b512016-09-06 20:57:50 +0000378 const elf::ELFDynamic *FindDynamicSymbol(unsigned tag);
Todd Fialab91de782014-06-27 16:52:49 +0000379
Kate Stoneb9c1b512016-09-06 20:57:50 +0000380 unsigned PLTRelocationType();
Ravitheja Addepally15f89c42016-01-19 12:55:21 +0000381
Zachary Turner97206d52017-05-12 04:51:55 +0000382 static lldb_private::Status
Kate Stoneb9c1b512016-09-06 20:57:50 +0000383 RefineModuleDetailsFromNote(lldb_private::DataExtractor &data,
384 lldb_private::ArchSpec &arch_spec,
385 lldb_private::UUID &uuid);
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000386};
387
Eugene Zelenko8157a882015-10-23 16:56:07 +0000388#endif // liblldb_ObjectFileELF_h_