blob: 98bd9abb19321b26b060e18f063adf50af876943 [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
Kate Stoneb9c1b512016-09-06 20:57:50 +000022#include "lldb/Core/ArchSpec.h"
Chris Lattner30fdc8d2010-06-08 16:52:24 +000023#include "lldb/Symbol/ObjectFile.h"
Zachary Turner5713a052017-03-22 18:40:07 +000024#include "lldb/Utility/FileSpec.h"
25#include "lldb/Utility/UUID.h"
Kate Stoneb9c1b512016-09-06 20:57:50 +000026#include "lldb/lldb-private.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
Kate Stoneb9c1b512016-09-06 20:57:50 +000030struct ELFNote {
31 elf::elf_word n_namesz;
32 elf::elf_word n_descsz;
33 elf::elf_word n_type;
Ed Mastec113ff82013-12-02 17:49:13 +000034
Kate Stoneb9c1b512016-09-06 20:57:50 +000035 std::string n_name;
Ed Mastec113ff82013-12-02 17:49:13 +000036
Kate Stoneb9c1b512016-09-06 20:57:50 +000037 ELFNote() : n_namesz(0), n_descsz(0), n_type(0) {}
Ed Mastec113ff82013-12-02 17:49:13 +000038
Kate Stoneb9c1b512016-09-06 20:57:50 +000039 /// Parse an ELFNote entry from the given DataExtractor starting at position
40 /// \p offset.
41 ///
42 /// @param[in] data
43 /// The DataExtractor to read from.
44 ///
45 /// @param[in,out] offset
46 /// Pointer to an offset in the data. On return the offset will be
47 /// advanced by the number of bytes read.
48 ///
49 /// @return
50 /// True if the ELFRel entry was successfully read and false otherwise.
51 bool Parse(const lldb_private::DataExtractor &data, lldb::offset_t *offset);
Greg Claytonb704b692015-10-28 18:04:38 +000052
Kate Stoneb9c1b512016-09-06 20:57:50 +000053 size_t GetByteSize() const {
54 return 12 + llvm::alignTo(n_namesz, 4) + llvm::alignTo(n_descsz, 4);
55 }
Ed Mastec113ff82013-12-02 17:49:13 +000056};
57
Stephen Wilsonf325ba92010-07-13 23:07:23 +000058//------------------------------------------------------------------------------
59/// @class ObjectFileELF
60/// @brief Generic ELF object file reader.
61///
62/// This class provides a generic ELF (32/64 bit) reader plugin implementing the
63/// ObjectFile protocol.
Kate Stoneb9c1b512016-09-06 20:57:50 +000064class ObjectFileELF : public lldb_private::ObjectFile {
Chris Lattner30fdc8d2010-06-08 16:52:24 +000065public:
Kate Stoneb9c1b512016-09-06 20:57:50 +000066 ~ObjectFileELF() override;
Eugene Zelenko8157a882015-10-23 16:56:07 +000067
Kate Stoneb9c1b512016-09-06 20:57:50 +000068 //------------------------------------------------------------------
69 // Static Functions
70 //------------------------------------------------------------------
71 static void Initialize();
Chris Lattner30fdc8d2010-06-08 16:52:24 +000072
Kate Stoneb9c1b512016-09-06 20:57:50 +000073 static void Terminate();
Chris Lattner30fdc8d2010-06-08 16:52:24 +000074
Kate Stoneb9c1b512016-09-06 20:57:50 +000075 static lldb_private::ConstString GetPluginNameStatic();
Chris Lattner30fdc8d2010-06-08 16:52:24 +000076
Kate Stoneb9c1b512016-09-06 20:57:50 +000077 static const char *GetPluginDescriptionStatic();
Chris Lattner30fdc8d2010-06-08 16:52:24 +000078
Kate Stoneb9c1b512016-09-06 20:57:50 +000079 static lldb_private::ObjectFile *
80 CreateInstance(const lldb::ModuleSP &module_sp, lldb::DataBufferSP &data_sp,
81 lldb::offset_t data_offset, const lldb_private::FileSpec *file,
82 lldb::offset_t file_offset, lldb::offset_t length);
Chris Lattner30fdc8d2010-06-08 16:52:24 +000083
Kate Stoneb9c1b512016-09-06 20:57:50 +000084 static lldb_private::ObjectFile *CreateMemoryInstance(
85 const lldb::ModuleSP &module_sp, lldb::DataBufferSP &data_sp,
86 const lldb::ProcessSP &process_sp, lldb::addr_t header_addr);
Greg Claytonc9660542012-02-05 02:38:54 +000087
Kate Stoneb9c1b512016-09-06 20:57:50 +000088 static size_t GetModuleSpecifications(const lldb_private::FileSpec &file,
89 lldb::DataBufferSP &data_sp,
90 lldb::offset_t data_offset,
91 lldb::offset_t file_offset,
92 lldb::offset_t length,
93 lldb_private::ModuleSpecList &specs);
Michael Sartain9f0013d2013-05-17 00:20:21 +000094
Kate Stoneb9c1b512016-09-06 20:57:50 +000095 static bool MagicBytesMatch(lldb::DataBufferSP &data_sp, lldb::addr_t offset,
96 lldb::addr_t length);
Michael Sartain9f0013d2013-05-17 00:20:21 +000097
Kate Stoneb9c1b512016-09-06 20:57:50 +000098 //------------------------------------------------------------------
99 // PluginInterface protocol
100 //------------------------------------------------------------------
101 lldb_private::ConstString GetPluginName() override;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000102
Kate Stoneb9c1b512016-09-06 20:57:50 +0000103 uint32_t GetPluginVersion() override;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000104
Kate Stoneb9c1b512016-09-06 20:57:50 +0000105 //------------------------------------------------------------------
106 // ObjectFile Protocol.
107 //------------------------------------------------------------------
108 bool ParseHeader() override;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000109
Kate Stoneb9c1b512016-09-06 20:57:50 +0000110 bool SetLoadAddress(lldb_private::Target &target, lldb::addr_t value,
111 bool value_is_offset) override;
Steve Pucci9e02dac2014-02-06 19:02:19 +0000112
Kate Stoneb9c1b512016-09-06 20:57:50 +0000113 lldb::ByteOrder GetByteOrder() const override;
Stephen Wilsonf325ba92010-07-13 23:07:23 +0000114
Kate Stoneb9c1b512016-09-06 20:57:50 +0000115 bool IsExecutable() const override;
Jim Ingham5aee1622010-08-09 23:31:02 +0000116
Kate Stoneb9c1b512016-09-06 20:57:50 +0000117 uint32_t GetAddressByteSize() const override;
Stephen Wilsonf325ba92010-07-13 23:07:23 +0000118
Kate Stoneb9c1b512016-09-06 20:57:50 +0000119 lldb::AddressClass GetAddressClass(lldb::addr_t file_addr) override;
Todd Fialafbd703a2014-09-15 22:33:39 +0000120
Kate Stoneb9c1b512016-09-06 20:57:50 +0000121 lldb_private::Symtab *GetSymtab() override;
Stephen Wilsonf325ba92010-07-13 23:07:23 +0000122
Kate Stoneb9c1b512016-09-06 20:57:50 +0000123 bool IsStripped() override;
Greg Clayton3046e662013-07-10 01:23:25 +0000124
Kate Stoneb9c1b512016-09-06 20:57:50 +0000125 void CreateSections(lldb_private::SectionList &unified_section_list) override;
Stephen Wilsonf325ba92010-07-13 23:07:23 +0000126
Kate Stoneb9c1b512016-09-06 20:57:50 +0000127 void Dump(lldb_private::Stream *s) override;
Stephen Wilsonf325ba92010-07-13 23:07:23 +0000128
Kate Stoneb9c1b512016-09-06 20:57:50 +0000129 bool GetArchitecture(lldb_private::ArchSpec &arch) override;
Stephen Wilsonf325ba92010-07-13 23:07:23 +0000130
Kate Stoneb9c1b512016-09-06 20:57:50 +0000131 bool GetUUID(lldb_private::UUID *uuid) override;
Stephen Wilsonf325ba92010-07-13 23:07:23 +0000132
Kate Stoneb9c1b512016-09-06 20:57:50 +0000133 lldb_private::FileSpecList GetDebugSymbolFilePaths() override;
Michael Sartaina7499c92013-07-01 19:45:50 +0000134
Kate Stoneb9c1b512016-09-06 20:57:50 +0000135 uint32_t GetDependentModules(lldb_private::FileSpecList &files) override;
Stephen Wilsonf325ba92010-07-13 23:07:23 +0000136
Kate Stoneb9c1b512016-09-06 20:57:50 +0000137 lldb_private::Address
138 GetImageInfoAddress(lldb_private::Target *target) override;
Stephen Wilson2ab0a582011-01-15 00:08:44 +0000139
Kate Stoneb9c1b512016-09-06 20:57:50 +0000140 lldb_private::Address GetEntryPointAddress() override;
Ashok Thirumurthi4822d922013-07-11 20:39:00 +0000141
Kate Stoneb9c1b512016-09-06 20:57:50 +0000142 ObjectFile::Type CalculateType() override;
Ashok Thirumurthi4822d922013-07-11 20:39:00 +0000143
Kate Stoneb9c1b512016-09-06 20:57:50 +0000144 ObjectFile::Strata CalculateStrata() override;
Ashok Thirumurthi4822d922013-07-11 20:39:00 +0000145
Kate Stoneb9c1b512016-09-06 20:57:50 +0000146 // Returns number of program headers found in the ELF file.
147 size_t GetProgramHeaderCount();
148
149 // Returns the program header with the given index.
150 const elf::ELFProgramHeader *GetProgramHeaderByIndex(lldb::user_id_t id);
151
152 // Returns segment data for the given index.
153 lldb_private::DataExtractor GetSegmentDataByIndex(lldb::user_id_t id);
154
155 std::string
156 StripLinkerSymbolAnnotations(llvm::StringRef symbol_name) const override;
Pavel Labathc6ae7ea2015-03-04 10:25:22 +0000157
Stephen Wilsonf325ba92010-07-13 23:07:23 +0000158private:
Kate Stoneb9c1b512016-09-06 20:57:50 +0000159 ObjectFileELF(const lldb::ModuleSP &module_sp, lldb::DataBufferSP &data_sp,
160 lldb::offset_t data_offset, const lldb_private::FileSpec *file,
161 lldb::offset_t offset, lldb::offset_t length);
Stephen Wilsonf325ba92010-07-13 23:07:23 +0000162
Kate Stoneb9c1b512016-09-06 20:57:50 +0000163 ObjectFileELF(const lldb::ModuleSP &module_sp,
164 lldb::DataBufferSP &header_data_sp,
165 const lldb::ProcessSP &process_sp, lldb::addr_t header_addr);
Andrew MacPherson17220c12014-03-05 10:12:43 +0000166
Kate Stoneb9c1b512016-09-06 20:57:50 +0000167 typedef std::vector<elf::ELFProgramHeader> ProgramHeaderColl;
168 typedef ProgramHeaderColl::iterator ProgramHeaderCollIter;
169 typedef ProgramHeaderColl::const_iterator ProgramHeaderCollConstIter;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000170
Kate Stoneb9c1b512016-09-06 20:57:50 +0000171 struct ELFSectionHeaderInfo : public elf::ELFSectionHeader {
172 lldb_private::ConstString section_name;
173 };
Eugene Zelenko8157a882015-10-23 16:56:07 +0000174
Kate Stoneb9c1b512016-09-06 20:57:50 +0000175 typedef std::vector<ELFSectionHeaderInfo> SectionHeaderColl;
176 typedef SectionHeaderColl::iterator SectionHeaderCollIter;
177 typedef SectionHeaderColl::const_iterator SectionHeaderCollConstIter;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000178
Kate Stoneb9c1b512016-09-06 20:57:50 +0000179 typedef std::vector<elf::ELFDynamic> DynamicSymbolColl;
180 typedef DynamicSymbolColl::iterator DynamicSymbolCollIter;
181 typedef DynamicSymbolColl::const_iterator DynamicSymbolCollConstIter;
Stephen Wilson499b40e2011-03-30 16:07:05 +0000182
Kate Stoneb9c1b512016-09-06 20:57:50 +0000183 typedef std::map<lldb::addr_t, lldb::AddressClass>
184 FileAddressToAddressClassMap;
185 typedef std::function<lldb::offset_t(lldb_private::DataExtractor &,
186 lldb::offset_t, lldb::offset_t)>
187 SetDataFunction;
Tamas Berghammer83544cf2015-04-07 10:43:50 +0000188
Kate Stoneb9c1b512016-09-06 20:57:50 +0000189 /// Version of this reader common to all plugins based on this class.
190 static const uint32_t m_plugin_version = 1;
191 static const uint32_t g_core_uuid_magic;
Stephen Wilsonf325ba92010-07-13 23:07:23 +0000192
Kate Stoneb9c1b512016-09-06 20:57:50 +0000193 /// ELF file header.
194 elf::ELFHeader m_header;
Stephen Wilsonf325ba92010-07-13 23:07:23 +0000195
Kate Stoneb9c1b512016-09-06 20:57:50 +0000196 /// ELF build ID.
197 lldb_private::UUID m_uuid;
Michael Sartainc836ae72013-05-23 20:57:03 +0000198
Kate Stoneb9c1b512016-09-06 20:57:50 +0000199 /// ELF .gnu_debuglink file and crc data if available.
200 std::string m_gnu_debuglink_file;
201 uint32_t m_gnu_debuglink_crc;
Michael Sartaina7499c92013-07-01 19:45:50 +0000202
Kate Stoneb9c1b512016-09-06 20:57:50 +0000203 /// Collection of program headers.
204 ProgramHeaderColl m_program_headers;
Stephen Wilsonf325ba92010-07-13 23:07:23 +0000205
Kate Stoneb9c1b512016-09-06 20:57:50 +0000206 /// Collection of section headers.
207 SectionHeaderColl m_section_headers;
Stephen Wilsonf325ba92010-07-13 23:07:23 +0000208
Kate Stoneb9c1b512016-09-06 20:57:50 +0000209 /// Collection of symbols from the dynamic table.
210 DynamicSymbolColl m_dynamic_symbols;
Stephen Wilson499b40e2011-03-30 16:07:05 +0000211
Kate Stoneb9c1b512016-09-06 20:57:50 +0000212 /// List of file specifications corresponding to the modules (shared
213 /// libraries) on which this object file depends.
214 mutable std::unique_ptr<lldb_private::FileSpecList> m_filespec_ap;
Stephen Wilsonf325ba92010-07-13 23:07:23 +0000215
Kate Stoneb9c1b512016-09-06 20:57:50 +0000216 /// Cached value of the entry point for this module.
217 lldb_private::Address m_entry_point_address;
Stephen Wilson499b40e2011-03-30 16:07:05 +0000218
Kate Stoneb9c1b512016-09-06 20:57:50 +0000219 /// The architecture detected from parsing elf file contents.
220 lldb_private::ArchSpec m_arch_spec;
Todd Fialab91de782014-06-27 16:52:49 +0000221
Kate Stoneb9c1b512016-09-06 20:57:50 +0000222 /// The address class for each symbol in the elf file
223 FileAddressToAddressClassMap m_address_class_map;
Tamas Berghammer83544cf2015-04-07 10:43:50 +0000224
Kate Stoneb9c1b512016-09-06 20:57:50 +0000225 /// Returns a 1 based index of the given section header.
226 size_t SectionIndex(const SectionHeaderCollIter &I);
Stephen Wilsonf325ba92010-07-13 23:07:23 +0000227
Kate Stoneb9c1b512016-09-06 20:57:50 +0000228 /// Returns a 1 based index of the given section header.
229 size_t SectionIndex(const SectionHeaderCollConstIter &I) const;
Stephen Wilsonf325ba92010-07-13 23:07:23 +0000230
Kate Stoneb9c1b512016-09-06 20:57:50 +0000231 // Parses the ELF program headers.
232 static size_t GetProgramHeaderInfo(ProgramHeaderColl &program_headers,
233 const SetDataFunction &set_data,
234 const elf::ELFHeader &header);
Todd Fiala4339f3a2014-03-25 19:29:09 +0000235
Kate Stoneb9c1b512016-09-06 20:57:50 +0000236 // Finds PT_NOTE segments and calculates their crc sum.
237 static uint32_t
238 CalculateELFNotesSegmentsCRC32(const ProgramHeaderColl &program_headers,
239 lldb_private::DataExtractor &data);
Todd Fiala4339f3a2014-03-25 19:29:09 +0000240
Kate Stoneb9c1b512016-09-06 20:57:50 +0000241 /// Parses all section headers present in this object file and populates
242 /// m_program_headers. This method will compute the header list only once.
243 /// Returns the number of headers parsed.
244 size_t ParseProgramHeaders();
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000245
Kate Stoneb9c1b512016-09-06 20:57:50 +0000246 /// Parses all section headers present in this object file and populates
247 /// m_section_headers. This method will compute the header list only once.
248 /// Returns the number of headers parsed.
249 size_t ParseSectionHeaders();
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000250
Kate Stoneb9c1b512016-09-06 20:57:50 +0000251 static void ParseARMAttributes(lldb_private::DataExtractor &data,
252 uint64_t length,
253 lldb_private::ArchSpec &arch_spec);
Saleem Abdulrasoold2d15042016-04-23 16:00:15 +0000254
Kate Stoneb9c1b512016-09-06 20:57:50 +0000255 /// Parses the elf section headers and returns the uuid, debug link name, crc,
256 /// archspec.
257 static size_t GetSectionHeaderInfo(SectionHeaderColl &section_headers,
258 const SetDataFunction &set_data,
259 const elf::ELFHeader &header,
260 lldb_private::UUID &uuid,
261 std::string &gnu_debuglink_file,
262 uint32_t &gnu_debuglink_crc,
263 lldb_private::ArchSpec &arch_spec);
Michael Sartaina7499c92013-07-01 19:45:50 +0000264
Kate Stoneb9c1b512016-09-06 20:57:50 +0000265 /// Scans the dynamic section and locates all dependent modules (shared
266 /// libraries) populating m_filespec_ap. This method will compute the
267 /// dependent module list only once. Returns the number of dependent
268 /// modules parsed.
269 size_t ParseDependentModules();
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000270
Kate Stoneb9c1b512016-09-06 20:57:50 +0000271 /// Parses the dynamic symbol table and populates m_dynamic_symbols. The
272 /// vector retains the order as found in the object file. Returns the
273 /// number of dynamic symbols parsed.
274 size_t ParseDynamicSymbols();
Stephen Wilson499b40e2011-03-30 16:07:05 +0000275
Kate Stoneb9c1b512016-09-06 20:57:50 +0000276 /// Populates m_symtab_ap will all non-dynamic linker symbols. This method
277 /// will parse the symbols only once. Returns the number of symbols parsed.
278 unsigned ParseSymbolTable(lldb_private::Symtab *symbol_table,
279 lldb::user_id_t start_id,
280 lldb_private::Section *symtab);
Stephen Wilsonf325ba92010-07-13 23:07:23 +0000281
Kate Stoneb9c1b512016-09-06 20:57:50 +0000282 /// Helper routine for ParseSymbolTable().
283 unsigned ParseSymbols(lldb_private::Symtab *symbol_table,
284 lldb::user_id_t start_id,
285 lldb_private::SectionList *section_list,
286 const size_t num_symbols,
287 const lldb_private::DataExtractor &symtab_data,
288 const lldb_private::DataExtractor &strtab_data);
Michael Sartaina7499c92013-07-01 19:45:50 +0000289
Kate Stoneb9c1b512016-09-06 20:57:50 +0000290 /// Scans the relocation entries and adds a set of artificial symbols to the
291 /// given symbol table for each PLT slot. Returns the number of symbols
292 /// added.
293 unsigned ParseTrampolineSymbols(lldb_private::Symtab *symbol_table,
294 lldb::user_id_t start_id,
295 const ELFSectionHeaderInfo *rela_hdr,
296 lldb::user_id_t section_id);
Stephen Wilson499b40e2011-03-30 16:07:05 +0000297
Kate Stoneb9c1b512016-09-06 20:57:50 +0000298 void ParseUnwindSymbols(lldb_private::Symtab *symbol_table,
299 lldb_private::DWARFCallFrameInfo *eh_frame);
Tamas Berghammer6b63b142016-02-18 11:12:18 +0000300
Kate Stoneb9c1b512016-09-06 20:57:50 +0000301 /// Relocates debug sections
302 unsigned RelocateDebugSections(const elf::ELFSectionHeader *rel_hdr,
303 lldb::user_id_t rel_id);
Andrew MacPherson17220c12014-03-05 10:12:43 +0000304
Kate Stoneb9c1b512016-09-06 20:57:50 +0000305 unsigned RelocateSection(lldb_private::Symtab *symtab,
306 const elf::ELFHeader *hdr,
307 const elf::ELFSectionHeader *rel_hdr,
308 const elf::ELFSectionHeader *symtab_hdr,
309 const elf::ELFSectionHeader *debug_hdr,
310 lldb_private::DataExtractor &rel_data,
311 lldb_private::DataExtractor &symtab_data,
312 lldb_private::DataExtractor &debug_data,
313 lldb_private::Section *rel_section);
Andrew MacPherson17220c12014-03-05 10:12:43 +0000314
Kate Stoneb9c1b512016-09-06 20:57:50 +0000315 /// Loads the section name string table into m_shstr_data. Returns the
316 /// number of bytes constituting the table.
317 size_t GetSectionHeaderStringTable();
Andrew MacPherson17220c12014-03-05 10:12:43 +0000318
Kate Stoneb9c1b512016-09-06 20:57:50 +0000319 /// Utility method for looking up a section given its name. Returns the
320 /// index of the corresponding section or zero if no section with the given
321 /// name can be found (note that section indices are always 1 based, and so
322 /// section index 0 is never valid).
323 lldb::user_id_t GetSectionIndexByName(const char *name);
Andrew MacPherson17220c12014-03-05 10:12:43 +0000324
Kate Stoneb9c1b512016-09-06 20:57:50 +0000325 // Returns the ID of the first section that has the given type.
326 lldb::user_id_t GetSectionIndexByType(unsigned type);
Andrew MacPherson17220c12014-03-05 10:12:43 +0000327
Kate Stoneb9c1b512016-09-06 20:57:50 +0000328 /// Returns the section header with the given id or NULL.
329 const ELFSectionHeaderInfo *GetSectionHeaderByIndex(lldb::user_id_t id);
Stephen Wilson499b40e2011-03-30 16:07:05 +0000330
Kate Stoneb9c1b512016-09-06 20:57:50 +0000331 /// @name ELF header dump routines
332 //@{
333 static void DumpELFHeader(lldb_private::Stream *s,
334 const elf::ELFHeader &header);
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000335
Kate Stoneb9c1b512016-09-06 20:57:50 +0000336 static void DumpELFHeader_e_ident_EI_DATA(lldb_private::Stream *s,
337 unsigned char ei_data);
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000338
Kate Stoneb9c1b512016-09-06 20:57:50 +0000339 static void DumpELFHeader_e_type(lldb_private::Stream *s,
340 elf::elf_half e_type);
341 //@}
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000342
Kate Stoneb9c1b512016-09-06 20:57:50 +0000343 /// @name ELF program header dump routines
344 //@{
345 void DumpELFProgramHeaders(lldb_private::Stream *s);
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000346
Kate Stoneb9c1b512016-09-06 20:57:50 +0000347 static void DumpELFProgramHeader(lldb_private::Stream *s,
348 const elf::ELFProgramHeader &ph);
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000349
Kate Stoneb9c1b512016-09-06 20:57:50 +0000350 static void DumpELFProgramHeader_p_type(lldb_private::Stream *s,
351 elf::elf_word p_type);
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000352
Kate Stoneb9c1b512016-09-06 20:57:50 +0000353 static void DumpELFProgramHeader_p_flags(lldb_private::Stream *s,
354 elf::elf_word p_flags);
355 //@}
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000356
Kate Stoneb9c1b512016-09-06 20:57:50 +0000357 /// @name ELF section header dump routines
358 //@{
359 void DumpELFSectionHeaders(lldb_private::Stream *s);
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000360
Kate Stoneb9c1b512016-09-06 20:57:50 +0000361 static void DumpELFSectionHeader(lldb_private::Stream *s,
362 const ELFSectionHeaderInfo &sh);
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000363
Kate Stoneb9c1b512016-09-06 20:57:50 +0000364 static void DumpELFSectionHeader_sh_type(lldb_private::Stream *s,
365 elf::elf_word sh_type);
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000366
Kate Stoneb9c1b512016-09-06 20:57:50 +0000367 static void DumpELFSectionHeader_sh_flags(lldb_private::Stream *s,
368 elf::elf_xword sh_flags);
369 //@}
Stephen Wilsonf325ba92010-07-13 23:07:23 +0000370
Kate Stoneb9c1b512016-09-06 20:57:50 +0000371 /// ELF dependent module dump routine.
372 void DumpDependentModules(lldb_private::Stream *s);
Stephen Wilsonf325ba92010-07-13 23:07:23 +0000373
Kate Stoneb9c1b512016-09-06 20:57:50 +0000374 const elf::ELFDynamic *FindDynamicSymbol(unsigned tag);
Todd Fialab91de782014-06-27 16:52:49 +0000375
Kate Stoneb9c1b512016-09-06 20:57:50 +0000376 unsigned PLTRelocationType();
Ravitheja Addepally15f89c42016-01-19 12:55:21 +0000377
Kate Stoneb9c1b512016-09-06 20:57:50 +0000378 static lldb_private::Error
379 RefineModuleDetailsFromNote(lldb_private::DataExtractor &data,
380 lldb_private::ArchSpec &arch_spec,
381 lldb_private::UUID &uuid);
Ravitheja Addepally15f89c42016-01-19 12:55:21 +0000382
Kate Stoneb9c1b512016-09-06 20:57:50 +0000383 static lldb::offset_t SetData(const lldb_private::DataExtractor &src,
384 lldb_private::DataExtractor &dst,
385 lldb::offset_t offset, lldb::offset_t length);
Ravitheja Addepally15f89c42016-01-19 12:55:21 +0000386
Kate Stoneb9c1b512016-09-06 20:57:50 +0000387 lldb::offset_t SetDataWithReadMemoryFallback(lldb_private::DataExtractor &dst,
388 lldb::offset_t offset,
389 lldb::offset_t length);
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000390};
391
Eugene Zelenko8157a882015-10-23 16:56:07 +0000392#endif // liblldb_ObjectFileELF_h_