1 //===-- SectionLoadList.h -----------------------------------------------*- C++
4 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5 // See https://llvm.org/LICENSE.txt for license information.
6 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
8 //===----------------------------------------------------------------------===//
10 #ifndef liblldb_SectionLoadList_h_
11 #define liblldb_SectionLoadList_h_
16 #include "llvm/ADT/DenseMap.h"
17 #include "lldb/Core/Section.h"
18 #include "lldb/lldb-public.h"
20 namespace lldb_private {
22 class SectionLoadList {
24 // Constructors and Destructors
25 SectionLoadList() : m_addr_to_sect(), m_sect_to_addr(), m_mutex() {}
27 SectionLoadList(const SectionLoadList &rhs);
30 // Call clear since this takes a lock and clears the section load list in
31 // case another thread is currently using this section load list
35 void operator=(const SectionLoadList &rhs);
41 lldb::addr_t GetSectionLoadAddress(const lldb::SectionSP §ion_sp) const;
43 bool ResolveLoadAddress(lldb::addr_t load_addr, Address &so_addr,
44 bool allow_section_end = false) const;
46 bool SetSectionLoadAddress(const lldb::SectionSP §ion_sp,
47 lldb::addr_t load_addr,
48 bool warn_multiple = false);
50 // The old load address should be specified when unloading to ensure we get
51 // the correct instance of the section as a shared library could be loaded at
52 // more than one location.
53 bool SetSectionUnloaded(const lldb::SectionSP §ion_sp,
54 lldb::addr_t load_addr);
56 // Unload all instances of a section. This function can be used on systems
57 // that don't support multiple copies of the same shared library to be loaded
59 size_t SetSectionUnloaded(const lldb::SectionSP §ion_sp);
61 void Dump(Stream &s, Target *target);
64 typedef std::map<lldb::addr_t, lldb::SectionSP> addr_to_sect_collection;
65 typedef llvm::DenseMap<const Section *, lldb::addr_t> sect_to_addr_collection;
66 addr_to_sect_collection m_addr_to_sect;
67 sect_to_addr_collection m_sect_to_addr;
68 mutable std::recursive_mutex m_mutex;
71 } // namespace lldb_private
73 #endif // liblldb_SectionLoadList_h_