1351290Sdim//===-- NativeProcessELF.h ------------------------------------ -*- C++ -*-===//
2351290Sdim//
3351290Sdim// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4351290Sdim// See https://llvm.org/LICENSE.txt for license information.
5351290Sdim// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6351290Sdim//
7351290Sdim//===----------------------------------------------------------------------===//
8351290Sdim
9351290Sdim#ifndef liblldb_NativeProcessELF_H_
10351290Sdim#define liblldb_NativeProcessELF_H_
11351290Sdim
12351290Sdim#include "Plugins/Process/Utility/AuxVector.h"
13351290Sdim#include "lldb/Host/common/NativeProcessProtocol.h"
14351290Sdim#include "llvm/BinaryFormat/ELF.h"
15351290Sdim
16351290Sdimnamespace lldb_private {
17351290Sdim
18351290Sdim/// \class NativeProcessELF
19351290Sdim/// Abstract class that extends \a NativeProcessProtocol with ELF specific
20351290Sdim/// logic. Meant to be subclassed by ELF based NativeProcess* implementations.
21351290Sdimclass NativeProcessELF : public NativeProcessProtocol {
22351290Sdim  using NativeProcessProtocol::NativeProcessProtocol;
23351290Sdim
24351290Sdimprotected:
25351290Sdim  template <typename T> struct ELFLinkMap {
26351290Sdim    T l_addr;
27351290Sdim    T l_name;
28351290Sdim    T l_ld;
29351290Sdim    T l_next;
30351290Sdim    T l_prev;
31351290Sdim  };
32351290Sdim
33351290Sdim  llvm::Optional<uint64_t> GetAuxValue(enum AuxVector::EntryType type);
34351290Sdim
35351290Sdim  lldb::addr_t GetSharedLibraryInfoAddress() override;
36351290Sdim
37351290Sdim  template <typename ELF_EHDR, typename ELF_PHDR, typename ELF_DYN>
38351290Sdim  lldb::addr_t GetELFImageInfoAddress();
39351290Sdim
40360784Sdim  llvm::Expected<std::vector<SVR4LibraryInfo>>
41360784Sdim  GetLoadedSVR4Libraries() override;
42360784Sdim
43360784Sdim  template <typename T>
44360784Sdim  llvm::Expected<SVR4LibraryInfo>
45360784Sdim  ReadSVR4LibraryInfo(lldb::addr_t link_map_addr);
46360784Sdim
47351290Sdim  std::unique_ptr<AuxVector> m_aux_vector;
48351290Sdim  llvm::Optional<lldb::addr_t> m_shared_library_info_addr;
49351290Sdim};
50351290Sdim
51351290Sdim} // namespace lldb_private
52351290Sdim
53351290Sdim#endif