blob: 6d8717b0ef25efb05b1eec24cd04bb93ccfa801c [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
Eugene Zelenko8157a882015-10-23 16:56:07 +000019// Other libraries and framework includes
20// Project includes
Kate Stoneb9c1b512016-09-06 20:57:50 +000021#include "lldb/Core/ArchSpec.h"
Chris Lattner30fdc8d2010-06-08 16:52:24 +000022#include "lldb/Symbol/ObjectFile.h"
Zachary Turner5713a052017-03-22 18:40:07 +000023#include "lldb/Utility/FileSpec.h"
24#include "lldb/Utility/UUID.h"
Kate Stoneb9c1b512016-09-06 20:57:50 +000025#include "lldb/lldb-private.h"
Chris Lattner30fdc8d2010-06-08 16:52:24 +000026
Stephen Wilsonf325ba92010-07-13 23:07:23 +000027#include "ELFHeader.h"
Chris Lattner30fdc8d2010-06-08 16:52:24 +000028
Kate Stoneb9c1b512016-09-06 20:57:50 +000029struct ELFNote {
30 elf::elf_word n_namesz;
31 elf::elf_word n_descsz;
32 elf::elf_word n_type;
Ed Mastec113ff82013-12-02 17:49:13 +000033
Kate Stoneb9c1b512016-09-06 20:57:50 +000034 std::string n_name;
Ed Mastec113ff82013-12-02 17:49:13 +000035
Kate Stoneb9c1b512016-09-06 20:57:50 +000036 ELFNote() : n_namesz(0), n_descsz(0), n_type(0) {}
Ed Mastec113ff82013-12-02 17:49:13 +000037
Kate Stoneb9c1b512016-09-06 20:57:50 +000038 /// Parse an ELFNote entry from the given DataExtractor starting at position
39 /// \p offset.
40 ///
41 /// @param[in] data
42 /// The DataExtractor to read from.
43 ///
44 /// @param[in,out] offset
45 /// Pointer to an offset in the data. On return the offset will be
46 /// advanced by the number of bytes read.
47 ///
48 /// @return
49 /// True if the ELFRel entry was successfully read and false otherwise.
50 bool Parse(const lldb_private::DataExtractor &data, lldb::offset_t *offset);
Greg Claytonb704b692015-10-28 18:04:38 +000051
Kate Stoneb9c1b512016-09-06 20:57:50 +000052 size_t GetByteSize() const {
53 return 12 + llvm::alignTo(n_namesz, 4) + llvm::alignTo(n_descsz, 4);
54 }
Ed Mastec113ff82013-12-02 17:49:13 +000055};
56
Stephen Wilsonf325ba92010-07-13 23:07:23 +000057//------------------------------------------------------------------------------
58/// @class ObjectFileELF
59/// @brief Generic ELF object file reader.
60///
61/// This class provides a generic ELF (32/64 bit) reader plugin implementing the
62/// ObjectFile protocol.
Kate Stoneb9c1b512016-09-06 20:57:50 +000063class ObjectFileELF : public lldb_private::ObjectFile {
Chris Lattner30fdc8d2010-06-08 16:52:24 +000064public:
Kate Stoneb9c1b512016-09-06 20:57:50 +000065 ~ObjectFileELF() override;
Eugene Zelenko8157a882015-10-23 16:56:07 +000066
Kate Stoneb9c1b512016-09-06 20:57:50 +000067 //------------------------------------------------------------------
68 // Static Functions
69 //------------------------------------------------------------------
70 static void Initialize();
Chris Lattner30fdc8d2010-06-08 16:52:24 +000071
Kate Stoneb9c1b512016-09-06 20:57:50 +000072 static void Terminate();
Chris Lattner30fdc8d2010-06-08 16:52:24 +000073
Kate Stoneb9c1b512016-09-06 20:57:50 +000074 static lldb_private::ConstString GetPluginNameStatic();
Chris Lattner30fdc8d2010-06-08 16:52:24 +000075
Kate Stoneb9c1b512016-09-06 20:57:50 +000076 static const char *GetPluginDescriptionStatic();
Chris Lattner30fdc8d2010-06-08 16:52:24 +000077
Kate Stoneb9c1b512016-09-06 20:57:50 +000078 static lldb_private::ObjectFile *
79 CreateInstance(const lldb::ModuleSP &module_sp, lldb::DataBufferSP &data_sp,
80 lldb::offset_t data_offset, const lldb_private::FileSpec *file,
81 lldb::offset_t file_offset, lldb::offset_t length);
Chris Lattner30fdc8d2010-06-08 16:52:24 +000082
Kate Stoneb9c1b512016-09-06 20:57:50 +000083 static lldb_private::ObjectFile *CreateMemoryInstance(
84 const lldb::ModuleSP &module_sp, lldb::DataBufferSP &data_sp,
85 const lldb::ProcessSP &process_sp, lldb::addr_t header_addr);
Greg Claytonc9660542012-02-05 02:38:54 +000086
Kate Stoneb9c1b512016-09-06 20:57:50 +000087 static size_t GetModuleSpecifications(const lldb_private::FileSpec &file,
88 lldb::DataBufferSP &data_sp,
89 lldb::offset_t data_offset,
90 lldb::offset_t file_offset,
91 lldb::offset_t length,
92 lldb_private::ModuleSpecList &specs);
Michael Sartain9f0013d2013-05-17 00:20:21 +000093
Kate Stoneb9c1b512016-09-06 20:57:50 +000094 static bool MagicBytesMatch(lldb::DataBufferSP &data_sp, lldb::addr_t offset,
95 lldb::addr_t length);
Michael Sartain9f0013d2013-05-17 00:20:21 +000096
Kate Stoneb9c1b512016-09-06 20:57:50 +000097 //------------------------------------------------------------------
98 // PluginInterface protocol
99 //------------------------------------------------------------------
100 lldb_private::ConstString GetPluginName() override;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000101
Kate Stoneb9c1b512016-09-06 20:57:50 +0000102 uint32_t GetPluginVersion() override;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000103
Kate Stoneb9c1b512016-09-06 20:57:50 +0000104 //------------------------------------------------------------------
105 // ObjectFile Protocol.
106 //------------------------------------------------------------------
107 bool ParseHeader() override;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000108
Kate Stoneb9c1b512016-09-06 20:57:50 +0000109 bool SetLoadAddress(lldb_private::Target &target, lldb::addr_t value,
110 bool value_is_offset) override;
Steve Pucci9e02dac2014-02-06 19:02:19 +0000111
Kate Stoneb9c1b512016-09-06 20:57:50 +0000112 lldb::ByteOrder GetByteOrder() const override;
Stephen Wilsonf325ba92010-07-13 23:07:23 +0000113
Kate Stoneb9c1b512016-09-06 20:57:50 +0000114 bool IsExecutable() const override;
Jim Ingham5aee1622010-08-09 23:31:02 +0000115
Kate Stoneb9c1b512016-09-06 20:57:50 +0000116 uint32_t GetAddressByteSize() const override;
Stephen Wilsonf325ba92010-07-13 23:07:23 +0000117
Kate Stoneb9c1b512016-09-06 20:57:50 +0000118 lldb::AddressClass GetAddressClass(lldb::addr_t file_addr) override;
Todd Fialafbd703a2014-09-15 22:33:39 +0000119
Kate Stoneb9c1b512016-09-06 20:57:50 +0000120 lldb_private::Symtab *GetSymtab() override;
Stephen Wilsonf325ba92010-07-13 23:07:23 +0000121
Kate Stoneb9c1b512016-09-06 20:57:50 +0000122 bool IsStripped() override;
Greg Clayton3046e662013-07-10 01:23:25 +0000123
Kate Stoneb9c1b512016-09-06 20:57:50 +0000124 void CreateSections(lldb_private::SectionList &unified_section_list) override;
Stephen Wilsonf325ba92010-07-13 23:07:23 +0000125
Kate Stoneb9c1b512016-09-06 20:57:50 +0000126 void Dump(lldb_private::Stream *s) override;
Stephen Wilsonf325ba92010-07-13 23:07:23 +0000127
Kate Stoneb9c1b512016-09-06 20:57:50 +0000128 bool GetArchitecture(lldb_private::ArchSpec &arch) override;
Stephen Wilsonf325ba92010-07-13 23:07:23 +0000129
Kate Stoneb9c1b512016-09-06 20:57:50 +0000130 bool GetUUID(lldb_private::UUID *uuid) override;
Stephen Wilsonf325ba92010-07-13 23:07:23 +0000131
Kate Stoneb9c1b512016-09-06 20:57:50 +0000132 lldb_private::FileSpecList GetDebugSymbolFilePaths() override;
Michael Sartaina7499c92013-07-01 19:45:50 +0000133
Kate Stoneb9c1b512016-09-06 20:57:50 +0000134 uint32_t GetDependentModules(lldb_private::FileSpecList &files) override;
Stephen Wilsonf325ba92010-07-13 23:07:23 +0000135
Kate Stoneb9c1b512016-09-06 20:57:50 +0000136 lldb_private::Address
137 GetImageInfoAddress(lldb_private::Target *target) override;
Stephen Wilson2ab0a582011-01-15 00:08:44 +0000138
Kate Stoneb9c1b512016-09-06 20:57:50 +0000139 lldb_private::Address GetEntryPointAddress() override;
Ashok Thirumurthi4822d922013-07-11 20:39:00 +0000140
Kate Stoneb9c1b512016-09-06 20:57:50 +0000141 ObjectFile::Type CalculateType() override;
Ashok Thirumurthi4822d922013-07-11 20:39:00 +0000142
Kate Stoneb9c1b512016-09-06 20:57:50 +0000143 ObjectFile::Strata CalculateStrata() override;
Ashok Thirumurthi4822d922013-07-11 20:39:00 +0000144
Kate Stoneb9c1b512016-09-06 20:57:50 +0000145 // Returns number of program headers found in the ELF file.
146 size_t GetProgramHeaderCount();
147
148 // Returns the program header with the given index.
149 const elf::ELFProgramHeader *GetProgramHeaderByIndex(lldb::user_id_t id);
150
151 // Returns segment data for the given index.
152 lldb_private::DataExtractor GetSegmentDataByIndex(lldb::user_id_t id);
153
Pavel Labath4d35d6b2017-05-02 10:17:30 +0000154 llvm::StringRef
Kate Stoneb9c1b512016-09-06 20:57:50 +0000155 StripLinkerSymbolAnnotations(llvm::StringRef symbol_name) const override;
Pavel Labathc6ae7ea2015-03-04 10:25:22 +0000156
Stephen Wilsonf325ba92010-07-13 23:07:23 +0000157private:
Kate Stoneb9c1b512016-09-06 20:57:50 +0000158 ObjectFileELF(const lldb::ModuleSP &module_sp, lldb::DataBufferSP &data_sp,
159 lldb::offset_t data_offset, const lldb_private::FileSpec *file,
160 lldb::offset_t offset, lldb::offset_t length);
Stephen Wilsonf325ba92010-07-13 23:07:23 +0000161
Kate Stoneb9c1b512016-09-06 20:57:50 +0000162 ObjectFileELF(const lldb::ModuleSP &module_sp,
163 lldb::DataBufferSP &header_data_sp,
164 const lldb::ProcessSP &process_sp, lldb::addr_t header_addr);
Andrew MacPherson17220c12014-03-05 10:12:43 +0000165
Kate Stoneb9c1b512016-09-06 20:57:50 +0000166 typedef std::vector<elf::ELFProgramHeader> ProgramHeaderColl;
167 typedef ProgramHeaderColl::iterator ProgramHeaderCollIter;
168 typedef ProgramHeaderColl::const_iterator ProgramHeaderCollConstIter;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000169
Kate Stoneb9c1b512016-09-06 20:57:50 +0000170 struct ELFSectionHeaderInfo : public elf::ELFSectionHeader {
171 lldb_private::ConstString section_name;
172 };
Eugene Zelenko8157a882015-10-23 16:56:07 +0000173
Kate Stoneb9c1b512016-09-06 20:57:50 +0000174 typedef std::vector<ELFSectionHeaderInfo> SectionHeaderColl;
175 typedef SectionHeaderColl::iterator SectionHeaderCollIter;
176 typedef SectionHeaderColl::const_iterator SectionHeaderCollConstIter;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000177
Kate Stoneb9c1b512016-09-06 20:57:50 +0000178 typedef std::vector<elf::ELFDynamic> DynamicSymbolColl;
179 typedef DynamicSymbolColl::iterator DynamicSymbolCollIter;
180 typedef DynamicSymbolColl::const_iterator DynamicSymbolCollConstIter;
Stephen Wilson499b40e2011-03-30 16:07:05 +0000181
Kate Stoneb9c1b512016-09-06 20:57:50 +0000182 typedef std::map<lldb::addr_t, lldb::AddressClass>
183 FileAddressToAddressClassMap;
Tamas Berghammer83544cf2015-04-07 10:43:50 +0000184
Kate Stoneb9c1b512016-09-06 20:57:50 +0000185 /// Version of this reader common to all plugins based on this class.
186 static const uint32_t m_plugin_version = 1;
187 static const uint32_t g_core_uuid_magic;
Stephen Wilsonf325ba92010-07-13 23:07:23 +0000188
Kate Stoneb9c1b512016-09-06 20:57:50 +0000189 /// ELF file header.
190 elf::ELFHeader m_header;
Stephen Wilsonf325ba92010-07-13 23:07:23 +0000191
Kate Stoneb9c1b512016-09-06 20:57:50 +0000192 /// ELF build ID.
193 lldb_private::UUID m_uuid;
Michael Sartainc836ae72013-05-23 20:57:03 +0000194
Kate Stoneb9c1b512016-09-06 20:57:50 +0000195 /// ELF .gnu_debuglink file and crc data if available.
196 std::string m_gnu_debuglink_file;
197 uint32_t m_gnu_debuglink_crc;
Michael Sartaina7499c92013-07-01 19:45:50 +0000198
Kate Stoneb9c1b512016-09-06 20:57:50 +0000199 /// Collection of program headers.
200 ProgramHeaderColl m_program_headers;
Stephen Wilsonf325ba92010-07-13 23:07:23 +0000201
Kate Stoneb9c1b512016-09-06 20:57:50 +0000202 /// Collection of section headers.
203 SectionHeaderColl m_section_headers;
Stephen Wilsonf325ba92010-07-13 23:07:23 +0000204
Kate Stoneb9c1b512016-09-06 20:57:50 +0000205 /// Collection of symbols from the dynamic table.
206 DynamicSymbolColl m_dynamic_symbols;
Stephen Wilson499b40e2011-03-30 16:07:05 +0000207
Kate Stoneb9c1b512016-09-06 20:57:50 +0000208 /// List of file specifications corresponding to the modules (shared
209 /// libraries) on which this object file depends.
210 mutable std::unique_ptr<lldb_private::FileSpecList> m_filespec_ap;
Stephen Wilsonf325ba92010-07-13 23:07:23 +0000211
Kate Stoneb9c1b512016-09-06 20:57:50 +0000212 /// Cached value of the entry point for this module.
213 lldb_private::Address m_entry_point_address;
Stephen Wilson499b40e2011-03-30 16:07:05 +0000214
Kate Stoneb9c1b512016-09-06 20:57:50 +0000215 /// The architecture detected from parsing elf file contents.
216 lldb_private::ArchSpec m_arch_spec;
Todd Fialab91de782014-06-27 16:52:49 +0000217
Kate Stoneb9c1b512016-09-06 20:57:50 +0000218 /// The address class for each symbol in the elf file
219 FileAddressToAddressClassMap m_address_class_map;
Tamas Berghammer83544cf2015-04-07 10:43:50 +0000220
Kate Stoneb9c1b512016-09-06 20:57:50 +0000221 /// Returns a 1 based index of the given section header.
222 size_t SectionIndex(const SectionHeaderCollIter &I);
Stephen Wilsonf325ba92010-07-13 23:07:23 +0000223
Kate Stoneb9c1b512016-09-06 20:57:50 +0000224 /// Returns a 1 based index of the given section header.
225 size_t SectionIndex(const SectionHeaderCollConstIter &I) const;
Stephen Wilsonf325ba92010-07-13 23:07:23 +0000226
Kate Stoneb9c1b512016-09-06 20:57:50 +0000227 // Parses the ELF program headers.
228 static size_t GetProgramHeaderInfo(ProgramHeaderColl &program_headers,
Pavel Labathdf1a0d12017-06-20 08:11:47 +0000229 lldb_private::DataExtractor &object_data,
Kate Stoneb9c1b512016-09-06 20:57:50 +0000230 const elf::ELFHeader &header);
Todd Fiala4339f3a2014-03-25 19:29:09 +0000231
Kate Stoneb9c1b512016-09-06 20:57:50 +0000232 // Finds PT_NOTE segments and calculates their crc sum.
233 static uint32_t
234 CalculateELFNotesSegmentsCRC32(const ProgramHeaderColl &program_headers,
235 lldb_private::DataExtractor &data);
Todd Fiala4339f3a2014-03-25 19:29:09 +0000236
Kate Stoneb9c1b512016-09-06 20:57:50 +0000237 /// Parses all section headers present in this object file and populates
238 /// m_program_headers. This method will compute the header list only once.
239 /// Returns the number of headers parsed.
240 size_t ParseProgramHeaders();
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000241
Kate Stoneb9c1b512016-09-06 20:57:50 +0000242 /// Parses all section headers present in this object file and populates
243 /// m_section_headers. This method will compute the header list only once.
244 /// Returns the number of headers parsed.
245 size_t ParseSectionHeaders();
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000246
Kate Stoneb9c1b512016-09-06 20:57:50 +0000247 static void ParseARMAttributes(lldb_private::DataExtractor &data,
248 uint64_t length,
249 lldb_private::ArchSpec &arch_spec);
Saleem Abdulrasoold2d15042016-04-23 16:00:15 +0000250
Kate Stoneb9c1b512016-09-06 20:57:50 +0000251 /// Parses the elf section headers and returns the uuid, debug link name, crc,
252 /// archspec.
253 static size_t GetSectionHeaderInfo(SectionHeaderColl &section_headers,
Pavel Labathdf1a0d12017-06-20 08:11:47 +0000254 lldb_private::DataExtractor &object_data,
Kate Stoneb9c1b512016-09-06 20:57:50 +0000255 const elf::ELFHeader &header,
256 lldb_private::UUID &uuid,
257 std::string &gnu_debuglink_file,
258 uint32_t &gnu_debuglink_crc,
259 lldb_private::ArchSpec &arch_spec);
Michael Sartaina7499c92013-07-01 19:45:50 +0000260
Kate Stoneb9c1b512016-09-06 20:57:50 +0000261 /// Scans the dynamic section and locates all dependent modules (shared
262 /// libraries) populating m_filespec_ap. This method will compute the
263 /// dependent module list only once. Returns the number of dependent
264 /// modules parsed.
265 size_t ParseDependentModules();
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000266
Kate Stoneb9c1b512016-09-06 20:57:50 +0000267 /// Parses the dynamic symbol table and populates m_dynamic_symbols. The
268 /// vector retains the order as found in the object file. Returns the
269 /// number of dynamic symbols parsed.
270 size_t ParseDynamicSymbols();
Stephen Wilson499b40e2011-03-30 16:07:05 +0000271
Kate Stoneb9c1b512016-09-06 20:57:50 +0000272 /// Populates m_symtab_ap will all non-dynamic linker symbols. This method
273 /// will parse the symbols only once. Returns the number of symbols parsed.
274 unsigned ParseSymbolTable(lldb_private::Symtab *symbol_table,
275 lldb::user_id_t start_id,
276 lldb_private::Section *symtab);
Stephen Wilsonf325ba92010-07-13 23:07:23 +0000277
Kate Stoneb9c1b512016-09-06 20:57:50 +0000278 /// Helper routine for ParseSymbolTable().
279 unsigned ParseSymbols(lldb_private::Symtab *symbol_table,
280 lldb::user_id_t start_id,
281 lldb_private::SectionList *section_list,
282 const size_t num_symbols,
283 const lldb_private::DataExtractor &symtab_data,
284 const lldb_private::DataExtractor &strtab_data);
Michael Sartaina7499c92013-07-01 19:45:50 +0000285
Kate Stoneb9c1b512016-09-06 20:57:50 +0000286 /// Scans the relocation entries and adds a set of artificial symbols to the
287 /// given symbol table for each PLT slot. Returns the number of symbols
288 /// added.
289 unsigned ParseTrampolineSymbols(lldb_private::Symtab *symbol_table,
290 lldb::user_id_t start_id,
291 const ELFSectionHeaderInfo *rela_hdr,
292 lldb::user_id_t section_id);
Stephen Wilson499b40e2011-03-30 16:07:05 +0000293
Kate Stoneb9c1b512016-09-06 20:57:50 +0000294 void ParseUnwindSymbols(lldb_private::Symtab *symbol_table,
295 lldb_private::DWARFCallFrameInfo *eh_frame);
Tamas Berghammer6b63b142016-02-18 11:12:18 +0000296
Kate Stoneb9c1b512016-09-06 20:57:50 +0000297 /// Relocates debug sections
298 unsigned RelocateDebugSections(const elf::ELFSectionHeader *rel_hdr,
299 lldb::user_id_t rel_id);
Andrew MacPherson17220c12014-03-05 10:12:43 +0000300
Kate Stoneb9c1b512016-09-06 20:57:50 +0000301 unsigned RelocateSection(lldb_private::Symtab *symtab,
302 const elf::ELFHeader *hdr,
303 const elf::ELFSectionHeader *rel_hdr,
304 const elf::ELFSectionHeader *symtab_hdr,
305 const elf::ELFSectionHeader *debug_hdr,
306 lldb_private::DataExtractor &rel_data,
307 lldb_private::DataExtractor &symtab_data,
308 lldb_private::DataExtractor &debug_data,
309 lldb_private::Section *rel_section);
Andrew MacPherson17220c12014-03-05 10:12:43 +0000310
Kate Stoneb9c1b512016-09-06 20:57:50 +0000311 /// Loads the section name string table into m_shstr_data. Returns the
312 /// number of bytes constituting the table.
313 size_t GetSectionHeaderStringTable();
Andrew MacPherson17220c12014-03-05 10:12:43 +0000314
Kate Stoneb9c1b512016-09-06 20:57:50 +0000315 /// Utility method for looking up a section given its name. Returns the
316 /// index of the corresponding section or zero if no section with the given
317 /// name can be found (note that section indices are always 1 based, and so
318 /// section index 0 is never valid).
319 lldb::user_id_t GetSectionIndexByName(const char *name);
Andrew MacPherson17220c12014-03-05 10:12:43 +0000320
Kate Stoneb9c1b512016-09-06 20:57:50 +0000321 // Returns the ID of the first section that has the given type.
322 lldb::user_id_t GetSectionIndexByType(unsigned type);
Andrew MacPherson17220c12014-03-05 10:12:43 +0000323
Kate Stoneb9c1b512016-09-06 20:57:50 +0000324 /// Returns the section header with the given id or NULL.
325 const ELFSectionHeaderInfo *GetSectionHeaderByIndex(lldb::user_id_t id);
Stephen Wilson499b40e2011-03-30 16:07:05 +0000326
Kate Stoneb9c1b512016-09-06 20:57:50 +0000327 /// @name ELF header dump routines
328 //@{
329 static void DumpELFHeader(lldb_private::Stream *s,
330 const elf::ELFHeader &header);
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000331
Kate Stoneb9c1b512016-09-06 20:57:50 +0000332 static void DumpELFHeader_e_ident_EI_DATA(lldb_private::Stream *s,
333 unsigned char ei_data);
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000334
Kate Stoneb9c1b512016-09-06 20:57:50 +0000335 static void DumpELFHeader_e_type(lldb_private::Stream *s,
336 elf::elf_half e_type);
337 //@}
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000338
Kate Stoneb9c1b512016-09-06 20:57:50 +0000339 /// @name ELF program header dump routines
340 //@{
341 void DumpELFProgramHeaders(lldb_private::Stream *s);
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000342
Kate Stoneb9c1b512016-09-06 20:57:50 +0000343 static void DumpELFProgramHeader(lldb_private::Stream *s,
344 const elf::ELFProgramHeader &ph);
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000345
Kate Stoneb9c1b512016-09-06 20:57:50 +0000346 static void DumpELFProgramHeader_p_type(lldb_private::Stream *s,
347 elf::elf_word p_type);
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000348
Kate Stoneb9c1b512016-09-06 20:57:50 +0000349 static void DumpELFProgramHeader_p_flags(lldb_private::Stream *s,
350 elf::elf_word p_flags);
351 //@}
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000352
Kate Stoneb9c1b512016-09-06 20:57:50 +0000353 /// @name ELF section header dump routines
354 //@{
355 void DumpELFSectionHeaders(lldb_private::Stream *s);
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000356
Kate Stoneb9c1b512016-09-06 20:57:50 +0000357 static void DumpELFSectionHeader(lldb_private::Stream *s,
358 const ELFSectionHeaderInfo &sh);
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000359
Kate Stoneb9c1b512016-09-06 20:57:50 +0000360 static void DumpELFSectionHeader_sh_type(lldb_private::Stream *s,
361 elf::elf_word sh_type);
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000362
Kate Stoneb9c1b512016-09-06 20:57:50 +0000363 static void DumpELFSectionHeader_sh_flags(lldb_private::Stream *s,
364 elf::elf_xword sh_flags);
365 //@}
Stephen Wilsonf325ba92010-07-13 23:07:23 +0000366
Kate Stoneb9c1b512016-09-06 20:57:50 +0000367 /// ELF dependent module dump routine.
368 void DumpDependentModules(lldb_private::Stream *s);
Stephen Wilsonf325ba92010-07-13 23:07:23 +0000369
Kate Stoneb9c1b512016-09-06 20:57:50 +0000370 const elf::ELFDynamic *FindDynamicSymbol(unsigned tag);
Todd Fialab91de782014-06-27 16:52:49 +0000371
Kate Stoneb9c1b512016-09-06 20:57:50 +0000372 unsigned PLTRelocationType();
Ravitheja Addepally15f89c42016-01-19 12:55:21 +0000373
Zachary Turner97206d52017-05-12 04:51:55 +0000374 static lldb_private::Status
Kate Stoneb9c1b512016-09-06 20:57:50 +0000375 RefineModuleDetailsFromNote(lldb_private::DataExtractor &data,
376 lldb_private::ArchSpec &arch_spec,
377 lldb_private::UUID &uuid);
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000378};
379
Eugene Zelenko8157a882015-10-23 16:56:07 +0000380#endif // liblldb_ObjectFileELF_h_