1 //===-- NativeProcessELF.h ------------------------------------ -*- C++ -*-===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 9 #ifndef liblldb_NativeProcessELF_H_ 10 #define liblldb_NativeProcessELF_H_ 11 12 #include "Plugins/Process/Utility/AuxVector.h" 13 #include "lldb/Host/common/NativeProcessProtocol.h" 14 #include "llvm/BinaryFormat/ELF.h" 15 16 namespace lldb_private { 17 18 /// \class NativeProcessELF 19 /// Abstract class that extends \a NativeProcessProtocol with ELF specific 20 /// logic. Meant to be subclassed by ELF based NativeProcess* implementations. 21 class NativeProcessELF : public NativeProcessProtocol { 22 using NativeProcessProtocol::NativeProcessProtocol; 23 24 protected: 25 template <typename T> struct ELFLinkMap { 26 T l_addr; 27 T l_name; 28 T l_ld; 29 T l_next; 30 T l_prev; 31 }; 32 33 llvm::Optional<uint64_t> GetAuxValue(enum AuxVector::EntryType type); 34 35 lldb::addr_t GetSharedLibraryInfoAddress() override; 36 37 template <typename ELF_EHDR, typename ELF_PHDR, typename ELF_DYN> 38 lldb::addr_t GetELFImageInfoAddress(); 39 40 llvm::Expected<std::vector<SVR4LibraryInfo>> 41 GetLoadedSVR4Libraries() override; 42 43 template <typename T> 44 llvm::Expected<SVR4LibraryInfo> 45 ReadSVR4LibraryInfo(lldb::addr_t link_map_addr); 46 47 std::unique_ptr<AuxVector> m_aux_vector; 48 llvm::Optional<lldb::addr_t> m_shared_library_info_addr; 49 }; 50 51 // Explicitly declare the two 32/64 bit templates that NativeProcessELF.cpp will 52 // define. This allows us to keep the template definition here and usable 53 // elsewhere. 54 extern template lldb::addr_t NativeProcessELF::GetELFImageInfoAddress< 55 llvm::ELF::Elf32_Ehdr, llvm::ELF::Elf32_Phdr, llvm::ELF::Elf32_Dyn>(); 56 extern template lldb::addr_t NativeProcessELF::GetELFImageInfoAddress< 57 llvm::ELF::Elf64_Ehdr, llvm::ELF::Elf64_Phdr, llvm::ELF::Elf64_Dyn>(); 58 59 } // namespace lldb_private 60 61 #endif 62