1f325ba9dSStephen Wilson //===-- ObjectFileELF.h --------------------------------------- -*- C++ -*-===//
230fdc8d8SChris Lattner //
330fdc8d8SChris Lattner //                     The LLVM Compiler Infrastructure
430fdc8d8SChris Lattner //
530fdc8d8SChris Lattner // This file is distributed under the University of Illinois Open Source
630fdc8d8SChris Lattner // License. See LICENSE.TXT for details.
730fdc8d8SChris Lattner //
830fdc8d8SChris Lattner //===----------------------------------------------------------------------===//
930fdc8d8SChris Lattner 
1030fdc8d8SChris Lattner #ifndef liblldb_ObjectFileELF_h_
1130fdc8d8SChris Lattner #define liblldb_ObjectFileELF_h_
1230fdc8d8SChris Lattner 
1330fdc8d8SChris Lattner #include <stdint.h>
1430fdc8d8SChris Lattner #include <vector>
1530fdc8d8SChris Lattner 
1630fdc8d8SChris Lattner #include "lldb/lldb-private.h"
1753239f00SGreg Clayton #include "lldb/Host/FileSpec.h"
1830fdc8d8SChris Lattner #include "lldb/Symbol/ObjectFile.h"
19c836ae7dSMichael Sartain #include "lldb/Core/UUID.h"
20b91de786STodd Fiala #include "lldb/Core/ArchSpec.h"
2130fdc8d8SChris Lattner 
22f325ba9dSStephen Wilson #include "ELFHeader.h"
2330fdc8d8SChris Lattner 
24c113ff8cSEd Maste struct ELFNote
25c113ff8cSEd Maste {
26c113ff8cSEd Maste     elf::elf_word n_namesz;
27c113ff8cSEd Maste     elf::elf_word n_descsz;
28c113ff8cSEd Maste     elf::elf_word n_type;
29c113ff8cSEd Maste 
30c113ff8cSEd Maste     std::string n_name;
31c113ff8cSEd Maste 
32c113ff8cSEd Maste     ELFNote() : n_namesz(0), n_descsz(0), n_type(0)
33c113ff8cSEd Maste     {
34c113ff8cSEd Maste     }
35c113ff8cSEd Maste 
36c113ff8cSEd Maste     /// Parse an ELFNote entry from the given DataExtractor starting at position
37c113ff8cSEd Maste     /// \p offset.
38c113ff8cSEd Maste     ///
39c113ff8cSEd Maste     /// @param[in] data
40c113ff8cSEd Maste     ///    The DataExtractor to read from.
41c113ff8cSEd Maste     ///
42c113ff8cSEd Maste     /// @param[in,out] offset
43c113ff8cSEd Maste     ///    Pointer to an offset in the data.  On return the offset will be
44c113ff8cSEd Maste     ///    advanced by the number of bytes read.
45c113ff8cSEd Maste     ///
46c113ff8cSEd Maste     /// @return
47c113ff8cSEd Maste     ///    True if the ELFRel entry was successfully read and false otherwise.
48c113ff8cSEd Maste     bool
49c113ff8cSEd Maste     Parse(const lldb_private::DataExtractor &data, lldb::offset_t *offset);
50c113ff8cSEd Maste };
51c113ff8cSEd Maste 
52f325ba9dSStephen Wilson //------------------------------------------------------------------------------
53f325ba9dSStephen Wilson /// @class ObjectFileELF
54f325ba9dSStephen Wilson /// @brief Generic ELF object file reader.
55f325ba9dSStephen Wilson ///
56f325ba9dSStephen Wilson /// This class provides a generic ELF (32/64 bit) reader plugin implementing the
57f325ba9dSStephen Wilson /// ObjectFile protocol.
5830fdc8d8SChris Lattner class ObjectFileELF :
5930fdc8d8SChris Lattner     public lldb_private::ObjectFile
6030fdc8d8SChris Lattner {
6130fdc8d8SChris Lattner public:
6230fdc8d8SChris Lattner     //------------------------------------------------------------------
6330fdc8d8SChris Lattner     // Static Functions
6430fdc8d8SChris Lattner     //------------------------------------------------------------------
6530fdc8d8SChris Lattner     static void
6630fdc8d8SChris Lattner     Initialize();
6730fdc8d8SChris Lattner 
6830fdc8d8SChris Lattner     static void
6930fdc8d8SChris Lattner     Terminate();
7030fdc8d8SChris Lattner 
7157abc5d6SGreg Clayton     static lldb_private::ConstString
7230fdc8d8SChris Lattner     GetPluginNameStatic();
7330fdc8d8SChris Lattner 
7430fdc8d8SChris Lattner     static const char *
7530fdc8d8SChris Lattner     GetPluginDescriptionStatic();
7630fdc8d8SChris Lattner 
7730fdc8d8SChris Lattner     static lldb_private::ObjectFile *
78e72dfb32SGreg Clayton     CreateInstance(const lldb::ModuleSP &module_sp,
795ce9c565SGreg Clayton                    lldb::DataBufferSP& data_sp,
805ce9c565SGreg Clayton                    lldb::offset_t data_offset,
8130fdc8d8SChris Lattner                    const lldb_private::FileSpec* file,
825ce9c565SGreg Clayton                    lldb::offset_t file_offset,
835ce9c565SGreg Clayton                    lldb::offset_t length);
8430fdc8d8SChris Lattner 
85c9660546SGreg Clayton     static lldb_private::ObjectFile *
86e72dfb32SGreg Clayton     CreateMemoryInstance (const lldb::ModuleSP &module_sp,
87c9660546SGreg Clayton                           lldb::DataBufferSP& data_sp,
88c9660546SGreg Clayton                           const lldb::ProcessSP &process_sp,
89c9660546SGreg Clayton                           lldb::addr_t header_addr);
90c9660546SGreg Clayton 
91f4d6de6aSGreg Clayton     static size_t
92f4d6de6aSGreg Clayton     GetModuleSpecifications (const lldb_private::FileSpec& file,
93f4d6de6aSGreg Clayton                              lldb::DataBufferSP& data_sp,
94f4d6de6aSGreg Clayton                              lldb::offset_t data_offset,
95f4d6de6aSGreg Clayton                              lldb::offset_t file_offset,
96f4d6de6aSGreg Clayton                              lldb::offset_t length,
97f4d6de6aSGreg Clayton                              lldb_private::ModuleSpecList &specs);
989f0013d8SMichael Sartain 
999f0013d8SMichael Sartain     static bool
1009f0013d8SMichael Sartain     MagicBytesMatch (lldb::DataBufferSP& data_sp,
1019f0013d8SMichael Sartain                      lldb::addr_t offset,
1029f0013d8SMichael Sartain                      lldb::addr_t length);
1039f0013d8SMichael Sartain 
10430fdc8d8SChris Lattner     //------------------------------------------------------------------
105f325ba9dSStephen Wilson     // PluginInterface protocol
10630fdc8d8SChris Lattner     //------------------------------------------------------------------
1076d06d905SGreg Clayton     lldb_private::ConstString
1086d06d905SGreg Clayton     GetPluginName() override;
10930fdc8d8SChris Lattner 
1106d06d905SGreg Clayton     uint32_t
1116d06d905SGreg Clayton     GetPluginVersion() override;
112f325ba9dSStephen Wilson 
113f325ba9dSStephen Wilson     //------------------------------------------------------------------
114f325ba9dSStephen Wilson     // ObjectFile Protocol.
115f325ba9dSStephen Wilson     //------------------------------------------------------------------
11630fdc8d8SChris Lattner     virtual
11730fdc8d8SChris Lattner     ~ObjectFileELF();
11830fdc8d8SChris Lattner 
1196d06d905SGreg Clayton     bool
1206d06d905SGreg Clayton     ParseHeader() override;
12130fdc8d8SChris Lattner 
1226d06d905SGreg Clayton     bool
123751caf65SGreg Clayton     SetLoadAddress (lldb_private::Target &target,
124751caf65SGreg Clayton                     lldb::addr_t value,
1256d06d905SGreg Clayton                     bool value_is_offset) override;
1269e02dacdSSteve Pucci 
1276d06d905SGreg Clayton     lldb::ByteOrder
1286d06d905SGreg Clayton     GetByteOrder() const override;
12930fdc8d8SChris Lattner 
1306d06d905SGreg Clayton     bool
1316d06d905SGreg Clayton     IsExecutable () const override;
1325aee162fSJim Ingham 
1336d06d905SGreg Clayton     uint32_t
1346d06d905SGreg Clayton     GetAddressByteSize() const override;
13530fdc8d8SChris Lattner 
1366d06d905SGreg Clayton     lldb::AddressClass
1376d06d905SGreg Clayton     GetAddressClass (lldb::addr_t file_addr) override;
138fbd703adSTodd Fiala 
1396d06d905SGreg Clayton     lldb_private::Symtab *
1406d06d905SGreg Clayton     GetSymtab() override;
14130fdc8d8SChris Lattner 
1426d06d905SGreg Clayton     lldb_private::Symbol *
1436d06d905SGreg Clayton     ResolveSymbolForAddress(const lldb_private::Address& so_addr, bool verify_unique) override;
14435729bb1SAshok Thirumurthi 
1456d06d905SGreg Clayton     bool
1466d06d905SGreg Clayton     IsStripped () override;
1473046e668SGreg Clayton 
1486d06d905SGreg Clayton     void
1496d06d905SGreg Clayton     CreateSections (lldb_private::SectionList &unified_section_list) override;
15030fdc8d8SChris Lattner 
1516d06d905SGreg Clayton     void
1526d06d905SGreg Clayton     Dump(lldb_private::Stream *s) override;
15330fdc8d8SChris Lattner 
1546d06d905SGreg Clayton     bool
1556d06d905SGreg Clayton     GetArchitecture (lldb_private::ArchSpec &arch) override;
15630fdc8d8SChris Lattner 
1576d06d905SGreg Clayton     bool
1586d06d905SGreg Clayton     GetUUID(lldb_private::UUID* uuid) override;
15930fdc8d8SChris Lattner 
1606d06d905SGreg Clayton     lldb_private::FileSpecList
1616d06d905SGreg Clayton     GetDebugSymbolFilePaths() override;
162a7499c98SMichael Sartain 
1636d06d905SGreg Clayton     uint32_t
1646d06d905SGreg Clayton     GetDependentModules(lldb_private::FileSpecList& files) override;
16530fdc8d8SChris Lattner 
1666d06d905SGreg Clayton     lldb_private::Address
1676d06d905SGreg Clayton     GetImageInfoAddress(lldb_private::Target *target) override;
1682ab0a585SStephen Wilson 
1696d06d905SGreg Clayton     lldb_private::Address
1706d06d905SGreg Clayton     GetEntryPointAddress () override;
1719e00b6a6SGreg Clayton 
1726d06d905SGreg Clayton     ObjectFile::Type
1736d06d905SGreg Clayton     CalculateType() override;
1749e00b6a6SGreg Clayton 
1756d06d905SGreg Clayton     ObjectFile::Strata
1766d06d905SGreg Clayton     CalculateStrata() override;
177672e6f59SJim Ingham 
1784822d926SAshok Thirumurthi     // Returns number of program headers found in the ELF file.
1794822d926SAshok Thirumurthi     size_t
1804822d926SAshok Thirumurthi     GetProgramHeaderCount();
1814822d926SAshok Thirumurthi 
1824822d926SAshok Thirumurthi     // Returns the program header with the given index.
1834822d926SAshok Thirumurthi     const elf::ELFProgramHeader *
1844822d926SAshok Thirumurthi     GetProgramHeaderByIndex(lldb::user_id_t id);
1854822d926SAshok Thirumurthi 
1864822d926SAshok Thirumurthi     // Returns segment data for the given index.
1874822d926SAshok Thirumurthi     lldb_private::DataExtractor
1884822d926SAshok Thirumurthi     GetSegmentDataByIndex(lldb::user_id_t id);
1894822d926SAshok Thirumurthi 
190c6ae7eaaSPavel Labath     std::string
191c6ae7eaaSPavel Labath     StripLinkerSymbolAnnotations(llvm::StringRef symbol_name) const override;
192c6ae7eaaSPavel Labath 
193f325ba9dSStephen Wilson private:
194e72dfb32SGreg Clayton     ObjectFileELF(const lldb::ModuleSP &module_sp,
1955ce9c565SGreg Clayton                   lldb::DataBufferSP& data_sp,
1965ce9c565SGreg Clayton                   lldb::offset_t data_offset,
197f325ba9dSStephen Wilson                   const lldb_private::FileSpec* file,
1985ce9c565SGreg Clayton                   lldb::offset_t offset,
1995ce9c565SGreg Clayton                   lldb::offset_t length);
20030fdc8d8SChris Lattner 
20117220c18SAndrew MacPherson     ObjectFileELF (const lldb::ModuleSP &module_sp,
202*f2561846STamas Berghammer                    lldb::DataBufferSP& header_data_sp,
20317220c18SAndrew MacPherson                    const lldb::ProcessSP &process_sp,
20417220c18SAndrew MacPherson                    lldb::addr_t header_addr);
20517220c18SAndrew MacPherson 
206f325ba9dSStephen Wilson     typedef std::vector<elf::ELFProgramHeader>  ProgramHeaderColl;
20730fdc8d8SChris Lattner     typedef ProgramHeaderColl::iterator         ProgramHeaderCollIter;
20830fdc8d8SChris Lattner     typedef ProgramHeaderColl::const_iterator   ProgramHeaderCollConstIter;
20930fdc8d8SChris Lattner 
210a7499c98SMichael Sartain     struct ELFSectionHeaderInfo : public elf::ELFSectionHeader
211a7499c98SMichael Sartain     {
212a7499c98SMichael Sartain         lldb_private::ConstString section_name;
213a7499c98SMichael Sartain     };
214a7499c98SMichael Sartain     typedef std::vector<ELFSectionHeaderInfo>   SectionHeaderColl;
21530fdc8d8SChris Lattner     typedef SectionHeaderColl::iterator         SectionHeaderCollIter;
21630fdc8d8SChris Lattner     typedef SectionHeaderColl::const_iterator   SectionHeaderCollConstIter;
21730fdc8d8SChris Lattner 
218499b40e8SStephen Wilson     typedef std::vector<elf::ELFDynamic>        DynamicSymbolColl;
219499b40e8SStephen Wilson     typedef DynamicSymbolColl::iterator         DynamicSymbolCollIter;
220499b40e8SStephen Wilson     typedef DynamicSymbolColl::const_iterator   DynamicSymbolCollConstIter;
221499b40e8SStephen Wilson 
22283544cf6STamas Berghammer     typedef std::map<lldb::addr_t, lldb::AddressClass> FileAddressToAddressClassMap;
22383544cf6STamas Berghammer 
224f325ba9dSStephen Wilson     /// Version of this reader common to all plugins based on this class.
225f325ba9dSStephen Wilson     static const uint32_t m_plugin_version = 1;
2264339f3a4STodd Fiala     static const uint32_t g_core_uuid_magic;
227f325ba9dSStephen Wilson 
228f325ba9dSStephen Wilson     /// ELF file header.
229f325ba9dSStephen Wilson     elf::ELFHeader m_header;
230f325ba9dSStephen Wilson 
231a7499c98SMichael Sartain     /// ELF build ID.
232c836ae7dSMichael Sartain     lldb_private::UUID m_uuid;
233c836ae7dSMichael Sartain 
234a7499c98SMichael Sartain     /// ELF .gnu_debuglink file and crc data if available.
235a7499c98SMichael Sartain     std::string m_gnu_debuglink_file;
236a7499c98SMichael Sartain     uint32_t m_gnu_debuglink_crc;
237a7499c98SMichael Sartain 
238f325ba9dSStephen Wilson     /// Collection of program headers.
23930fdc8d8SChris Lattner     ProgramHeaderColl m_program_headers;
240f325ba9dSStephen Wilson 
241f325ba9dSStephen Wilson     /// Collection of section headers.
24230fdc8d8SChris Lattner     SectionHeaderColl m_section_headers;
243f325ba9dSStephen Wilson 
244499b40e8SStephen Wilson     /// Collection of symbols from the dynamic table.
245499b40e8SStephen Wilson     DynamicSymbolColl m_dynamic_symbols;
246499b40e8SStephen Wilson 
247f325ba9dSStephen Wilson     /// List of file specifications corresponding to the modules (shared
248f325ba9dSStephen Wilson     /// libraries) on which this object file depends.
2497b0992d9SGreg Clayton     mutable std::unique_ptr<lldb_private::FileSpecList> m_filespec_ap;
250f325ba9dSStephen Wilson 
251672e6f59SJim Ingham     /// Cached value of the entry point for this module.
252672e6f59SJim Ingham     lldb_private::Address  m_entry_point_address;
253672e6f59SJim Ingham 
254b91de786STodd Fiala     /// The architecture detected from parsing elf file contents.
255b91de786STodd Fiala     lldb_private::ArchSpec m_arch_spec;
256b91de786STodd Fiala 
25783544cf6STamas Berghammer     /// The address class for each symbol in the elf file
25883544cf6STamas Berghammer     FileAddressToAddressClassMap m_address_class_map;
25983544cf6STamas Berghammer 
260f325ba9dSStephen Wilson     /// Returns a 1 based index of the given section header.
261c7bece56SGreg Clayton     size_t
262f325ba9dSStephen Wilson     SectionIndex(const SectionHeaderCollIter &I);
263f325ba9dSStephen Wilson 
264f325ba9dSStephen Wilson     /// Returns a 1 based index of the given section header.
265c7bece56SGreg Clayton     size_t
266f325ba9dSStephen Wilson     SectionIndex(const SectionHeaderCollConstIter &I) const;
267f325ba9dSStephen Wilson 
2684339f3a4STodd Fiala     // Parses the ELF program headers.
2694339f3a4STodd Fiala     static size_t
2704339f3a4STodd Fiala     GetProgramHeaderInfo(ProgramHeaderColl &program_headers,
2714339f3a4STodd Fiala                          lldb_private::DataExtractor &data,
2724339f3a4STodd Fiala                          const elf::ELFHeader &header);
2734339f3a4STodd Fiala 
2744339f3a4STodd Fiala     // Finds PT_NOTE segments and calculates their crc sum.
2754339f3a4STodd Fiala     static uint32_t
2764339f3a4STodd Fiala     CalculateELFNotesSegmentsCRC32(const ProgramHeaderColl& program_headers,
2774339f3a4STodd Fiala                                    lldb_private::DataExtractor &data);
2784339f3a4STodd Fiala 
279f325ba9dSStephen Wilson     /// Parses all section headers present in this object file and populates
280f325ba9dSStephen Wilson     /// m_program_headers.  This method will compute the header list only once.
281f325ba9dSStephen Wilson     /// Returns the number of headers parsed.
28230fdc8d8SChris Lattner     size_t
283f325ba9dSStephen Wilson     ParseProgramHeaders();
28430fdc8d8SChris Lattner 
285f325ba9dSStephen Wilson     /// Parses all section headers present in this object file and populates
286f325ba9dSStephen Wilson     /// m_section_headers.  This method will compute the header list only once.
287f325ba9dSStephen Wilson     /// Returns the number of headers parsed.
28830fdc8d8SChris Lattner     size_t
289f325ba9dSStephen Wilson     ParseSectionHeaders();
29030fdc8d8SChris Lattner 
291b91de786STodd Fiala     /// Parses the elf section headers and returns the uuid, debug link name, crc, archspec.
292a7499c98SMichael Sartain     static size_t
293a7499c98SMichael Sartain     GetSectionHeaderInfo(SectionHeaderColl &section_headers,
294a7499c98SMichael Sartain                          lldb_private::DataExtractor &data,
295a7499c98SMichael Sartain                          const elf::ELFHeader &header,
296a7499c98SMichael Sartain                          lldb_private::UUID &uuid,
297a7499c98SMichael Sartain                          std::string &gnu_debuglink_file,
298b91de786STodd Fiala                          uint32_t &gnu_debuglink_crc,
299b91de786STodd Fiala                          lldb_private::ArchSpec &arch_spec);
300a7499c98SMichael Sartain 
301f325ba9dSStephen Wilson     /// Scans the dynamic section and locates all dependent modules (shared
302710dd5aeSGreg Clayton     /// libraries) populating m_filespec_ap.  This method will compute the
303f325ba9dSStephen Wilson     /// dependent module list only once.  Returns the number of dependent
304f325ba9dSStephen Wilson     /// modules parsed.
305f325ba9dSStephen Wilson     size_t
306f325ba9dSStephen Wilson     ParseDependentModules();
30730fdc8d8SChris Lattner 
308499b40e8SStephen Wilson     /// Parses the dynamic symbol table and populates m_dynamic_symbols.  The
309499b40e8SStephen Wilson     /// vector retains the order as found in the object file.  Returns the
310499b40e8SStephen Wilson     /// number of dynamic symbols parsed.
311499b40e8SStephen Wilson     size_t
312499b40e8SStephen Wilson     ParseDynamicSymbols();
313499b40e8SStephen Wilson 
314f325ba9dSStephen Wilson     /// Populates m_symtab_ap will all non-dynamic linker symbols.  This method
315f325ba9dSStephen Wilson     /// will parse the symbols only once.  Returns the number of symbols parsed.
316499b40e8SStephen Wilson     unsigned
317f325ba9dSStephen Wilson     ParseSymbolTable(lldb_private::Symtab *symbol_table,
318499b40e8SStephen Wilson                      lldb::user_id_t start_id,
3193046e668SGreg Clayton                      lldb_private::Section *symtab);
320f325ba9dSStephen Wilson 
321a7499c98SMichael Sartain     /// Helper routine for ParseSymbolTable().
322a7499c98SMichael Sartain     unsigned
323a7499c98SMichael Sartain     ParseSymbols(lldb_private::Symtab *symbol_table,
324a7499c98SMichael Sartain                  lldb::user_id_t start_id,
325a7499c98SMichael Sartain                  lldb_private::SectionList *section_list,
3263046e668SGreg Clayton                  const size_t num_symbols,
327a7499c98SMichael Sartain                  const lldb_private::DataExtractor &symtab_data,
328a7499c98SMichael Sartain                  const lldb_private::DataExtractor &strtab_data);
329a7499c98SMichael Sartain 
330499b40e8SStephen Wilson     /// Scans the relocation entries and adds a set of artificial symbols to the
331499b40e8SStephen Wilson     /// given symbol table for each PLT slot.  Returns the number of symbols
332499b40e8SStephen Wilson     /// added.
333499b40e8SStephen Wilson     unsigned
334499b40e8SStephen Wilson     ParseTrampolineSymbols(lldb_private::Symtab *symbol_table,
335499b40e8SStephen Wilson                            lldb::user_id_t start_id,
336a7499c98SMichael Sartain                            const ELFSectionHeaderInfo *rela_hdr,
337499b40e8SStephen Wilson                            lldb::user_id_t section_id);
338499b40e8SStephen Wilson 
33917220c18SAndrew MacPherson     /// Relocates debug sections
34017220c18SAndrew MacPherson     unsigned
34117220c18SAndrew MacPherson     RelocateDebugSections(const elf::ELFSectionHeader *rel_hdr, lldb::user_id_t rel_id);
34217220c18SAndrew MacPherson 
34317220c18SAndrew MacPherson     unsigned
34417220c18SAndrew MacPherson     RelocateSection(lldb_private::Symtab* symtab, const elf::ELFHeader *hdr, const elf::ELFSectionHeader *rel_hdr,
34517220c18SAndrew MacPherson                     const elf::ELFSectionHeader *symtab_hdr, const elf::ELFSectionHeader *debug_hdr,
34617220c18SAndrew MacPherson                     lldb_private::DataExtractor &rel_data, lldb_private::DataExtractor &symtab_data,
34717220c18SAndrew MacPherson                     lldb_private::DataExtractor &debug_data, lldb_private::Section* rel_section);
34817220c18SAndrew MacPherson 
34917220c18SAndrew MacPherson     /// Loads the section name string table into m_shstr_data.  Returns the
35017220c18SAndrew MacPherson     /// number of bytes constituting the table.
35117220c18SAndrew MacPherson     size_t
35217220c18SAndrew MacPherson     GetSectionHeaderStringTable();
35317220c18SAndrew MacPherson 
35417220c18SAndrew MacPherson     /// Utility method for looking up a section given its name.  Returns the
35517220c18SAndrew MacPherson     /// index of the corresponding section or zero if no section with the given
35617220c18SAndrew MacPherson     /// name can be found (note that section indices are always 1 based, and so
35717220c18SAndrew MacPherson     /// section index 0 is never valid).
35817220c18SAndrew MacPherson     lldb::user_id_t
35917220c18SAndrew MacPherson     GetSectionIndexByName(const char *name);
36017220c18SAndrew MacPherson 
36117220c18SAndrew MacPherson     // Returns the ID of the first section that has the given type.
36217220c18SAndrew MacPherson     lldb::user_id_t
36317220c18SAndrew MacPherson     GetSectionIndexByType(unsigned type);
36417220c18SAndrew MacPherson 
365499b40e8SStephen Wilson     /// Returns the section header with the given id or NULL.
366a7499c98SMichael Sartain     const ELFSectionHeaderInfo *
367499b40e8SStephen Wilson     GetSectionHeaderByIndex(lldb::user_id_t id);
368499b40e8SStephen Wilson 
369f325ba9dSStephen Wilson     /// @name  ELF header dump routines
370f325ba9dSStephen Wilson     //@{
37130fdc8d8SChris Lattner     static void
372f325ba9dSStephen Wilson     DumpELFHeader(lldb_private::Stream *s, const elf::ELFHeader& header);
37330fdc8d8SChris Lattner 
37430fdc8d8SChris Lattner     static void
37530fdc8d8SChris Lattner     DumpELFHeader_e_ident_EI_DATA(lldb_private::Stream *s,
376f325ba9dSStephen Wilson                                   unsigned char ei_data);
37730fdc8d8SChris Lattner 
378f325ba9dSStephen Wilson     static void
379f325ba9dSStephen Wilson     DumpELFHeader_e_type(lldb_private::Stream *s, elf::elf_half e_type);
380f325ba9dSStephen Wilson     //@}
381f325ba9dSStephen Wilson 
382f325ba9dSStephen Wilson     /// @name ELF program header dump routines
383f325ba9dSStephen Wilson     //@{
38430fdc8d8SChris Lattner     void
38530fdc8d8SChris Lattner     DumpELFProgramHeaders(lldb_private::Stream *s);
38630fdc8d8SChris Lattner 
38730fdc8d8SChris Lattner     static void
38830fdc8d8SChris Lattner     DumpELFProgramHeader(lldb_private::Stream *s,
389f325ba9dSStephen Wilson                          const elf::ELFProgramHeader &ph);
39030fdc8d8SChris Lattner 
39130fdc8d8SChris Lattner     static void
392f325ba9dSStephen Wilson     DumpELFProgramHeader_p_type(lldb_private::Stream *s, elf::elf_word p_type);
39330fdc8d8SChris Lattner 
39430fdc8d8SChris Lattner     static void
39530fdc8d8SChris Lattner     DumpELFProgramHeader_p_flags(lldb_private::Stream *s,
396f325ba9dSStephen Wilson                                  elf::elf_word p_flags);
397f325ba9dSStephen Wilson     //@}
39830fdc8d8SChris Lattner 
399f325ba9dSStephen Wilson     /// @name ELF section header dump routines
400f325ba9dSStephen Wilson     //@{
40130fdc8d8SChris Lattner     void
40230fdc8d8SChris Lattner     DumpELFSectionHeaders(lldb_private::Stream *s);
40330fdc8d8SChris Lattner 
40430fdc8d8SChris Lattner     static void
40530fdc8d8SChris Lattner     DumpELFSectionHeader(lldb_private::Stream *s,
406a7499c98SMichael Sartain                          const ELFSectionHeaderInfo& sh);
40730fdc8d8SChris Lattner 
40830fdc8d8SChris Lattner     static void
40930fdc8d8SChris Lattner     DumpELFSectionHeader_sh_type(lldb_private::Stream *s,
410f325ba9dSStephen Wilson                                  elf::elf_word sh_type);
41130fdc8d8SChris Lattner 
41230fdc8d8SChris Lattner     static void
41330fdc8d8SChris Lattner     DumpELFSectionHeader_sh_flags(lldb_private::Stream *s,
414c7bece56SGreg Clayton                                   elf::elf_xword sh_flags);
415f325ba9dSStephen Wilson     //@}
41630fdc8d8SChris Lattner 
417f325ba9dSStephen Wilson     /// ELF dependent module dump routine.
418f325ba9dSStephen Wilson     void
419f325ba9dSStephen Wilson     DumpDependentModules(lldb_private::Stream *s);
42030fdc8d8SChris Lattner 
421499b40e8SStephen Wilson     const elf::ELFDynamic *
422499b40e8SStephen Wilson     FindDynamicSymbol(unsigned tag);
423499b40e8SStephen Wilson 
424499b40e8SStephen Wilson     unsigned
425499b40e8SStephen Wilson     PLTRelocationType();
426b91de786STodd Fiala 
427b91de786STodd Fiala     static lldb_private::Error
428b91de786STodd Fiala     RefineModuleDetailsFromNote (lldb_private::DataExtractor &data, lldb_private::ArchSpec &arch_spec, lldb_private::UUID &uuid);
42930fdc8d8SChris Lattner };
43030fdc8d8SChris Lattner 
43130fdc8d8SChris Lattner #endif // #ifndef liblldb_ObjectFileELF_h_
432