blob: 48ae96a7c26825e5e05ad3472d175440b088dc39 [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
Ravitheja Addepally15f89c42016-01-19 12:55:21 +000017#include <functional>
Chris Lattner30fdc8d2010-06-08 16:52:24 +000018#include <vector>
19
Eugene Zelenko8157a882015-10-23 16:56:07 +000020// Other libraries and framework includes
21// Project includes
Chris Lattner30fdc8d2010-06-08 16:52:24 +000022#include "lldb/lldb-private.h"
Greg Clayton53239f02011-02-08 05:05:52 +000023#include "lldb/Host/FileSpec.h"
Chris Lattner30fdc8d2010-06-08 16:52:24 +000024#include "lldb/Symbol/ObjectFile.h"
Michael Sartainc836ae72013-05-23 20:57:03 +000025#include "lldb/Core/UUID.h"
Todd Fialab91de782014-06-27 16:52:49 +000026#include "lldb/Core/ArchSpec.h"
Chris Lattner30fdc8d2010-06-08 16:52:24 +000027
Stephen Wilsonf325ba92010-07-13 23:07:23 +000028#include "ELFHeader.h"
Chris Lattner30fdc8d2010-06-08 16:52:24 +000029
Ed Mastec113ff82013-12-02 17:49:13 +000030struct ELFNote
31{
32 elf::elf_word n_namesz;
33 elf::elf_word n_descsz;
34 elf::elf_word n_type;
35
36 std::string n_name;
37
38 ELFNote() : n_namesz(0), n_descsz(0), n_type(0)
39 {
40 }
41
42 /// Parse an ELFNote entry from the given DataExtractor starting at position
43 /// \p offset.
44 ///
45 /// @param[in] data
46 /// The DataExtractor to read from.
47 ///
48 /// @param[in,out] offset
49 /// Pointer to an offset in the data. On return the offset will be
50 /// advanced by the number of bytes read.
51 ///
52 /// @return
53 /// True if the ELFRel entry was successfully read and false otherwise.
54 bool
55 Parse(const lldb_private::DataExtractor &data, lldb::offset_t *offset);
Greg Claytonb704b692015-10-28 18:04:38 +000056
57 size_t
58 GetByteSize() const
59 {
Rafael Espindolaa94ae1e2016-01-18 20:57:54 +000060 return 12 + llvm::alignTo (n_namesz, 4) + llvm::alignTo (n_descsz, 4);
Greg Claytonb704b692015-10-28 18:04:38 +000061 }
Ed Mastec113ff82013-12-02 17:49:13 +000062};
63
Stephen Wilsonf325ba92010-07-13 23:07:23 +000064//------------------------------------------------------------------------------
65/// @class ObjectFileELF
66/// @brief Generic ELF object file reader.
67///
68/// This class provides a generic ELF (32/64 bit) reader plugin implementing the
69/// ObjectFile protocol.
Chris Lattner30fdc8d2010-06-08 16:52:24 +000070class ObjectFileELF :
71 public lldb_private::ObjectFile
72{
73public:
Eugene Zelenko8157a882015-10-23 16:56:07 +000074 ~ObjectFileELF() override;
75
Chris Lattner30fdc8d2010-06-08 16:52:24 +000076 //------------------------------------------------------------------
77 // Static Functions
78 //------------------------------------------------------------------
79 static void
80 Initialize();
81
82 static void
83 Terminate();
84
Greg Clayton57abc5d2013-05-10 21:47:16 +000085 static lldb_private::ConstString
Chris Lattner30fdc8d2010-06-08 16:52:24 +000086 GetPluginNameStatic();
87
88 static const char *
89 GetPluginDescriptionStatic();
90
91 static lldb_private::ObjectFile *
Greg Claytone72dfb32012-02-24 01:59:29 +000092 CreateInstance(const lldb::ModuleSP &module_sp,
Greg Clayton5ce9c562013-02-06 17:22:03 +000093 lldb::DataBufferSP& data_sp,
94 lldb::offset_t data_offset,
Chris Lattner30fdc8d2010-06-08 16:52:24 +000095 const lldb_private::FileSpec* file,
Greg Clayton5ce9c562013-02-06 17:22:03 +000096 lldb::offset_t file_offset,
97 lldb::offset_t length);
Chris Lattner30fdc8d2010-06-08 16:52:24 +000098
Greg Claytonc9660542012-02-05 02:38:54 +000099 static lldb_private::ObjectFile *
Greg Claytone72dfb32012-02-24 01:59:29 +0000100 CreateMemoryInstance (const lldb::ModuleSP &module_sp,
Greg Claytonc9660542012-02-05 02:38:54 +0000101 lldb::DataBufferSP& data_sp,
102 const lldb::ProcessSP &process_sp,
103 lldb::addr_t header_addr);
104
Greg Claytonf4d6de62013-04-24 22:29:28 +0000105 static size_t
106 GetModuleSpecifications (const lldb_private::FileSpec& file,
107 lldb::DataBufferSP& data_sp,
108 lldb::offset_t data_offset,
109 lldb::offset_t file_offset,
110 lldb::offset_t length,
111 lldb_private::ModuleSpecList &specs);
Michael Sartain9f0013d2013-05-17 00:20:21 +0000112
113 static bool
114 MagicBytesMatch (lldb::DataBufferSP& data_sp,
115 lldb::addr_t offset,
116 lldb::addr_t length);
117
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000118 //------------------------------------------------------------------
119 // PluginInterface protocol
120 //------------------------------------------------------------------
Greg Clayton6d06d902015-03-12 00:16:14 +0000121 lldb_private::ConstString
122 GetPluginName() override;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000123
Greg Clayton6d06d902015-03-12 00:16:14 +0000124 uint32_t
125 GetPluginVersion() override;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000126
Stephen Wilsonf325ba92010-07-13 23:07:23 +0000127 //------------------------------------------------------------------
128 // ObjectFile Protocol.
129 //------------------------------------------------------------------
Greg Clayton6d06d902015-03-12 00:16:14 +0000130 bool
131 ParseHeader() override;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000132
Greg Clayton6d06d902015-03-12 00:16:14 +0000133 bool
Greg Clayton751caf62014-02-07 22:54:47 +0000134 SetLoadAddress (lldb_private::Target &target,
135 lldb::addr_t value,
Greg Clayton6d06d902015-03-12 00:16:14 +0000136 bool value_is_offset) override;
Steve Pucci9e02dac2014-02-06 19:02:19 +0000137
Greg Clayton6d06d902015-03-12 00:16:14 +0000138 lldb::ByteOrder
139 GetByteOrder() const override;
Stephen Wilsonf325ba92010-07-13 23:07:23 +0000140
Greg Clayton6d06d902015-03-12 00:16:14 +0000141 bool
142 IsExecutable () const override;
Jim Ingham5aee1622010-08-09 23:31:02 +0000143
Greg Clayton6d06d902015-03-12 00:16:14 +0000144 uint32_t
145 GetAddressByteSize() const override;
Stephen Wilsonf325ba92010-07-13 23:07:23 +0000146
Greg Clayton6d06d902015-03-12 00:16:14 +0000147 lldb::AddressClass
148 GetAddressClass (lldb::addr_t file_addr) override;
Todd Fialafbd703a2014-09-15 22:33:39 +0000149
Greg Clayton6d06d902015-03-12 00:16:14 +0000150 lldb_private::Symtab *
151 GetSymtab() override;
Stephen Wilsonf325ba92010-07-13 23:07:23 +0000152
Tamas Berghammer5bfd4d02016-02-10 12:10:58 +0000153 lldb_private::Symbol *
154 ResolveSymbolForAddress(const lldb_private::Address& so_addr, bool verify_unique) override;
155
Greg Clayton6d06d902015-03-12 00:16:14 +0000156 bool
157 IsStripped () override;
Greg Clayton3046e662013-07-10 01:23:25 +0000158
Greg Clayton6d06d902015-03-12 00:16:14 +0000159 void
160 CreateSections (lldb_private::SectionList &unified_section_list) override;
Stephen Wilsonf325ba92010-07-13 23:07:23 +0000161
Greg Clayton6d06d902015-03-12 00:16:14 +0000162 void
163 Dump(lldb_private::Stream *s) override;
Stephen Wilsonf325ba92010-07-13 23:07:23 +0000164
Greg Clayton6d06d902015-03-12 00:16:14 +0000165 bool
166 GetArchitecture (lldb_private::ArchSpec &arch) override;
Stephen Wilsonf325ba92010-07-13 23:07:23 +0000167
Greg Clayton6d06d902015-03-12 00:16:14 +0000168 bool
169 GetUUID(lldb_private::UUID* uuid) override;
Stephen Wilsonf325ba92010-07-13 23:07:23 +0000170
Greg Clayton6d06d902015-03-12 00:16:14 +0000171 lldb_private::FileSpecList
172 GetDebugSymbolFilePaths() override;
Michael Sartaina7499c92013-07-01 19:45:50 +0000173
Greg Clayton6d06d902015-03-12 00:16:14 +0000174 uint32_t
175 GetDependentModules(lldb_private::FileSpecList& files) override;
Stephen Wilsonf325ba92010-07-13 23:07:23 +0000176
Greg Clayton6d06d902015-03-12 00:16:14 +0000177 lldb_private::Address
178 GetImageInfoAddress(lldb_private::Target *target) override;
Jim Ingham672e6f52011-03-07 23:44:08 +0000179
Greg Clayton6d06d902015-03-12 00:16:14 +0000180 lldb_private::Address
181 GetEntryPointAddress () override;
Greg Clayton9e00b6a652011-07-09 00:41:34 +0000182
Greg Clayton6d06d902015-03-12 00:16:14 +0000183 ObjectFile::Type
184 CalculateType() override;
Greg Clayton9e00b6a652011-07-09 00:41:34 +0000185
Greg Clayton6d06d902015-03-12 00:16:14 +0000186 ObjectFile::Strata
187 CalculateStrata() override;
Stephen Wilson2ab0a582011-01-15 00:08:44 +0000188
Ashok Thirumurthi4822d922013-07-11 20:39:00 +0000189 // Returns number of program headers found in the ELF file.
190 size_t
191 GetProgramHeaderCount();
192
193 // Returns the program header with the given index.
194 const elf::ELFProgramHeader *
195 GetProgramHeaderByIndex(lldb::user_id_t id);
196
197 // Returns segment data for the given index.
198 lldb_private::DataExtractor
199 GetSegmentDataByIndex(lldb::user_id_t id);
200
Pavel Labathc6ae7ea2015-03-04 10:25:22 +0000201 std::string
202 StripLinkerSymbolAnnotations(llvm::StringRef symbol_name) const override;
203
Stephen Wilsonf325ba92010-07-13 23:07:23 +0000204private:
Greg Claytone72dfb32012-02-24 01:59:29 +0000205 ObjectFileELF(const lldb::ModuleSP &module_sp,
Greg Clayton5ce9c562013-02-06 17:22:03 +0000206 lldb::DataBufferSP& data_sp,
207 lldb::offset_t data_offset,
Stephen Wilsonf325ba92010-07-13 23:07:23 +0000208 const lldb_private::FileSpec* file,
Greg Clayton5ce9c562013-02-06 17:22:03 +0000209 lldb::offset_t offset,
210 lldb::offset_t length);
Stephen Wilsonf325ba92010-07-13 23:07:23 +0000211
Andrew MacPherson17220c12014-03-05 10:12:43 +0000212 ObjectFileELF (const lldb::ModuleSP &module_sp,
Tamas Berghammerf2561842015-06-30 10:41:23 +0000213 lldb::DataBufferSP& header_data_sp,
Andrew MacPherson17220c12014-03-05 10:12:43 +0000214 const lldb::ProcessSP &process_sp,
215 lldb::addr_t header_addr);
216
Stephen Wilsonf325ba92010-07-13 23:07:23 +0000217 typedef std::vector<elf::ELFProgramHeader> ProgramHeaderColl;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000218 typedef ProgramHeaderColl::iterator ProgramHeaderCollIter;
219 typedef ProgramHeaderColl::const_iterator ProgramHeaderCollConstIter;
220
Michael Sartaina7499c92013-07-01 19:45:50 +0000221 struct ELFSectionHeaderInfo : public elf::ELFSectionHeader
222 {
223 lldb_private::ConstString section_name;
224 };
Eugene Zelenko8157a882015-10-23 16:56:07 +0000225
Michael Sartaina7499c92013-07-01 19:45:50 +0000226 typedef std::vector<ELFSectionHeaderInfo> SectionHeaderColl;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000227 typedef SectionHeaderColl::iterator SectionHeaderCollIter;
228 typedef SectionHeaderColl::const_iterator SectionHeaderCollConstIter;
229
Stephen Wilson499b40e2011-03-30 16:07:05 +0000230 typedef std::vector<elf::ELFDynamic> DynamicSymbolColl;
231 typedef DynamicSymbolColl::iterator DynamicSymbolCollIter;
232 typedef DynamicSymbolColl::const_iterator DynamicSymbolCollConstIter;
233
Tamas Berghammer83544cf2015-04-07 10:43:50 +0000234 typedef std::map<lldb::addr_t, lldb::AddressClass> FileAddressToAddressClassMap;
Ravitheja Addepally15f89c42016-01-19 12:55:21 +0000235 typedef std::function<lldb::offset_t (lldb_private::DataExtractor &, lldb::offset_t, lldb::offset_t)> SetDataFunction;
Tamas Berghammer83544cf2015-04-07 10:43:50 +0000236
Stephen Wilsonf325ba92010-07-13 23:07:23 +0000237 /// Version of this reader common to all plugins based on this class.
238 static const uint32_t m_plugin_version = 1;
Todd Fiala4339f3a2014-03-25 19:29:09 +0000239 static const uint32_t g_core_uuid_magic;
Stephen Wilsonf325ba92010-07-13 23:07:23 +0000240
241 /// ELF file header.
242 elf::ELFHeader m_header;
243
Michael Sartaina7499c92013-07-01 19:45:50 +0000244 /// ELF build ID.
Michael Sartainc836ae72013-05-23 20:57:03 +0000245 lldb_private::UUID m_uuid;
246
Michael Sartaina7499c92013-07-01 19:45:50 +0000247 /// ELF .gnu_debuglink file and crc data if available.
248 std::string m_gnu_debuglink_file;
249 uint32_t m_gnu_debuglink_crc;
250
Stephen Wilsonf325ba92010-07-13 23:07:23 +0000251 /// Collection of program headers.
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000252 ProgramHeaderColl m_program_headers;
Stephen Wilsonf325ba92010-07-13 23:07:23 +0000253
254 /// Collection of section headers.
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000255 SectionHeaderColl m_section_headers;
Stephen Wilsonf325ba92010-07-13 23:07:23 +0000256
Stephen Wilson499b40e2011-03-30 16:07:05 +0000257 /// Collection of symbols from the dynamic table.
258 DynamicSymbolColl m_dynamic_symbols;
259
Stephen Wilsonf325ba92010-07-13 23:07:23 +0000260 /// List of file specifications corresponding to the modules (shared
261 /// libraries) on which this object file depends.
Greg Clayton7b0992d2013-04-18 22:45:39 +0000262 mutable std::unique_ptr<lldb_private::FileSpecList> m_filespec_ap;
Stephen Wilsonf325ba92010-07-13 23:07:23 +0000263
Jim Ingham672e6f52011-03-07 23:44:08 +0000264 /// Cached value of the entry point for this module.
265 lldb_private::Address m_entry_point_address;
Stephen Wilson499b40e2011-03-30 16:07:05 +0000266
Todd Fialab91de782014-06-27 16:52:49 +0000267 /// The architecture detected from parsing elf file contents.
268 lldb_private::ArchSpec m_arch_spec;
269
Tamas Berghammer83544cf2015-04-07 10:43:50 +0000270 /// The address class for each symbol in the elf file
271 FileAddressToAddressClassMap m_address_class_map;
272
Stephen Wilsonf325ba92010-07-13 23:07:23 +0000273 /// Returns a 1 based index of the given section header.
Greg Claytonc7bece562013-01-25 18:06:21 +0000274 size_t
Stephen Wilsonf325ba92010-07-13 23:07:23 +0000275 SectionIndex(const SectionHeaderCollIter &I);
276
277 /// Returns a 1 based index of the given section header.
Greg Claytonc7bece562013-01-25 18:06:21 +0000278 size_t
Stephen Wilsonf325ba92010-07-13 23:07:23 +0000279 SectionIndex(const SectionHeaderCollConstIter &I) const;
280
Todd Fiala4339f3a2014-03-25 19:29:09 +0000281 // Parses the ELF program headers.
282 static size_t
283 GetProgramHeaderInfo(ProgramHeaderColl &program_headers,
Ravitheja Addepally15f89c42016-01-19 12:55:21 +0000284 const SetDataFunction &set_data,
Todd Fiala4339f3a2014-03-25 19:29:09 +0000285 const elf::ELFHeader &header);
286
287 // Finds PT_NOTE segments and calculates their crc sum.
288 static uint32_t
289 CalculateELFNotesSegmentsCRC32(const ProgramHeaderColl& program_headers,
290 lldb_private::DataExtractor &data);
291
Stephen Wilsonf325ba92010-07-13 23:07:23 +0000292 /// Parses all section headers present in this object file and populates
293 /// m_program_headers. This method will compute the header list only once.
294 /// Returns the number of headers parsed.
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000295 size_t
Stephen Wilsonf325ba92010-07-13 23:07:23 +0000296 ParseProgramHeaders();
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000297
Stephen Wilsonf325ba92010-07-13 23:07:23 +0000298 /// Parses all section headers present in this object file and populates
299 /// m_section_headers. This method will compute the header list only once.
300 /// Returns the number of headers parsed.
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000301 size_t
Stephen Wilsonf325ba92010-07-13 23:07:23 +0000302 ParseSectionHeaders();
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000303
Todd Fialab91de782014-06-27 16:52:49 +0000304 /// Parses the elf section headers and returns the uuid, debug link name, crc, archspec.
Michael Sartaina7499c92013-07-01 19:45:50 +0000305 static size_t
306 GetSectionHeaderInfo(SectionHeaderColl &section_headers,
Ravitheja Addepally15f89c42016-01-19 12:55:21 +0000307 const SetDataFunction &set_data,
Michael Sartaina7499c92013-07-01 19:45:50 +0000308 const elf::ELFHeader &header,
309 lldb_private::UUID &uuid,
310 std::string &gnu_debuglink_file,
Todd Fialab91de782014-06-27 16:52:49 +0000311 uint32_t &gnu_debuglink_crc,
312 lldb_private::ArchSpec &arch_spec);
Michael Sartaina7499c92013-07-01 19:45:50 +0000313
Stephen Wilsonf325ba92010-07-13 23:07:23 +0000314 /// Scans the dynamic section and locates all dependent modules (shared
Greg Clayton710dd5a2011-01-08 20:28:42 +0000315 /// libraries) populating m_filespec_ap. This method will compute the
Stephen Wilsonf325ba92010-07-13 23:07:23 +0000316 /// dependent module list only once. Returns the number of dependent
317 /// modules parsed.
318 size_t
319 ParseDependentModules();
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000320
Stephen Wilson499b40e2011-03-30 16:07:05 +0000321 /// Parses the dynamic symbol table and populates m_dynamic_symbols. The
322 /// vector retains the order as found in the object file. Returns the
323 /// number of dynamic symbols parsed.
324 size_t
325 ParseDynamicSymbols();
326
Stephen Wilsonf325ba92010-07-13 23:07:23 +0000327 /// Populates m_symtab_ap will all non-dynamic linker symbols. This method
328 /// will parse the symbols only once. Returns the number of symbols parsed.
Stephen Wilson499b40e2011-03-30 16:07:05 +0000329 unsigned
Stephen Wilsonf325ba92010-07-13 23:07:23 +0000330 ParseSymbolTable(lldb_private::Symtab *symbol_table,
Stephen Wilson499b40e2011-03-30 16:07:05 +0000331 lldb::user_id_t start_id,
Greg Clayton3046e662013-07-10 01:23:25 +0000332 lldb_private::Section *symtab);
Stephen Wilsonf325ba92010-07-13 23:07:23 +0000333
Michael Sartaina7499c92013-07-01 19:45:50 +0000334 /// Helper routine for ParseSymbolTable().
335 unsigned
336 ParseSymbols(lldb_private::Symtab *symbol_table,
337 lldb::user_id_t start_id,
338 lldb_private::SectionList *section_list,
Greg Clayton3046e662013-07-10 01:23:25 +0000339 const size_t num_symbols,
Michael Sartaina7499c92013-07-01 19:45:50 +0000340 const lldb_private::DataExtractor &symtab_data,
341 const lldb_private::DataExtractor &strtab_data);
342
Stephen Wilson499b40e2011-03-30 16:07:05 +0000343 /// Scans the relocation entries and adds a set of artificial symbols to the
344 /// given symbol table for each PLT slot. Returns the number of symbols
345 /// added.
346 unsigned
347 ParseTrampolineSymbols(lldb_private::Symtab *symbol_table,
348 lldb::user_id_t start_id,
Michael Sartaina7499c92013-07-01 19:45:50 +0000349 const ELFSectionHeaderInfo *rela_hdr,
Stephen Wilson499b40e2011-03-30 16:07:05 +0000350 lldb::user_id_t section_id);
351
Andrew MacPherson17220c12014-03-05 10:12:43 +0000352 /// Relocates debug sections
353 unsigned
354 RelocateDebugSections(const elf::ELFSectionHeader *rel_hdr, lldb::user_id_t rel_id);
355
356 unsigned
357 RelocateSection(lldb_private::Symtab* symtab, const elf::ELFHeader *hdr, const elf::ELFSectionHeader *rel_hdr,
358 const elf::ELFSectionHeader *symtab_hdr, const elf::ELFSectionHeader *debug_hdr,
359 lldb_private::DataExtractor &rel_data, lldb_private::DataExtractor &symtab_data,
360 lldb_private::DataExtractor &debug_data, lldb_private::Section* rel_section);
361
362 /// Loads the section name string table into m_shstr_data. Returns the
363 /// number of bytes constituting the table.
364 size_t
365 GetSectionHeaderStringTable();
366
367 /// Utility method for looking up a section given its name. Returns the
368 /// index of the corresponding section or zero if no section with the given
369 /// name can be found (note that section indices are always 1 based, and so
370 /// section index 0 is never valid).
371 lldb::user_id_t
372 GetSectionIndexByName(const char *name);
373
374 // Returns the ID of the first section that has the given type.
375 lldb::user_id_t
376 GetSectionIndexByType(unsigned type);
377
Stephen Wilson499b40e2011-03-30 16:07:05 +0000378 /// Returns the section header with the given id or NULL.
Michael Sartaina7499c92013-07-01 19:45:50 +0000379 const ELFSectionHeaderInfo *
Stephen Wilson499b40e2011-03-30 16:07:05 +0000380 GetSectionHeaderByIndex(lldb::user_id_t id);
381
Stephen Wilsonf325ba92010-07-13 23:07:23 +0000382 /// @name ELF header dump routines
383 //@{
384 static void
385 DumpELFHeader(lldb_private::Stream *s, const elf::ELFHeader& header);
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000386
387 static void
Stephen Wilsonf325ba92010-07-13 23:07:23 +0000388 DumpELFHeader_e_ident_EI_DATA(lldb_private::Stream *s,
389 unsigned char ei_data);
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000390
391 static void
Stephen Wilsonf325ba92010-07-13 23:07:23 +0000392 DumpELFHeader_e_type(lldb_private::Stream *s, elf::elf_half e_type);
393 //@}
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000394
Stephen Wilsonf325ba92010-07-13 23:07:23 +0000395 /// @name ELF program header dump routines
396 //@{
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000397 void
Stephen Wilsonf325ba92010-07-13 23:07:23 +0000398 DumpELFProgramHeaders(lldb_private::Stream *s);
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000399
400 static void
Stephen Wilsonf325ba92010-07-13 23:07:23 +0000401 DumpELFProgramHeader(lldb_private::Stream *s,
402 const elf::ELFProgramHeader &ph);
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000403
404 static void
Stephen Wilsonf325ba92010-07-13 23:07:23 +0000405 DumpELFProgramHeader_p_type(lldb_private::Stream *s, elf::elf_word p_type);
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000406
407 static void
Stephen Wilsonf325ba92010-07-13 23:07:23 +0000408 DumpELFProgramHeader_p_flags(lldb_private::Stream *s,
409 elf::elf_word p_flags);
410 //@}
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000411
Stephen Wilsonf325ba92010-07-13 23:07:23 +0000412 /// @name ELF section header dump routines
413 //@{
414 void
415 DumpELFSectionHeaders(lldb_private::Stream *s);
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000416
Stephen Wilsonf325ba92010-07-13 23:07:23 +0000417 static void
418 DumpELFSectionHeader(lldb_private::Stream *s,
Michael Sartaina7499c92013-07-01 19:45:50 +0000419 const ELFSectionHeaderInfo& sh);
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000420
Stephen Wilsonf325ba92010-07-13 23:07:23 +0000421 static void
422 DumpELFSectionHeader_sh_type(lldb_private::Stream *s,
423 elf::elf_word sh_type);
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000424
Stephen Wilsonf325ba92010-07-13 23:07:23 +0000425 static void
426 DumpELFSectionHeader_sh_flags(lldb_private::Stream *s,
Greg Claytonc7bece562013-01-25 18:06:21 +0000427 elf::elf_xword sh_flags);
Stephen Wilsonf325ba92010-07-13 23:07:23 +0000428 //@}
429
430 /// ELF dependent module dump routine.
431 void
432 DumpDependentModules(lldb_private::Stream *s);
433
Stephen Wilson499b40e2011-03-30 16:07:05 +0000434 const elf::ELFDynamic *
435 FindDynamicSymbol(unsigned tag);
436
Stephen Wilson499b40e2011-03-30 16:07:05 +0000437 unsigned
438 PLTRelocationType();
Todd Fialab91de782014-06-27 16:52:49 +0000439
440 static lldb_private::Error
441 RefineModuleDetailsFromNote (lldb_private::DataExtractor &data, lldb_private::ArchSpec &arch_spec, lldb_private::UUID &uuid);
Ravitheja Addepally15f89c42016-01-19 12:55:21 +0000442
443
444 static lldb::offset_t
445 SetData(const lldb_private::DataExtractor &src, lldb_private::DataExtractor &dst, lldb::offset_t offset, lldb::offset_t length);
446
447 lldb::offset_t
448 SetDataWithReadMemoryFallback(lldb_private::DataExtractor &dst, lldb::offset_t offset, lldb::offset_t length);
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000449};
450
Eugene Zelenko8157a882015-10-23 16:56:07 +0000451#endif // liblldb_ObjectFileELF_h_