Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:42:54

0001 //===-- SectionLoadList.h -----------------------------------------------*- C++
0002 //-*-===//
0003 //
0004 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0005 // See https://llvm.org/LICENSE.txt for license information.
0006 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0007 //
0008 //===----------------------------------------------------------------------===//
0009 
0010 #ifndef LLDB_TARGET_SECTIONLOADLIST_H
0011 #define LLDB_TARGET_SECTIONLOADLIST_H
0012 
0013 #include <map>
0014 #include <mutex>
0015 
0016 #include "llvm/ADT/DenseMap.h"
0017 #include "lldb/Core/Section.h"
0018 #include "lldb/lldb-public.h"
0019 
0020 namespace lldb_private {
0021 
0022 class SectionLoadList {
0023 public:
0024   // Constructors and Destructors
0025   SectionLoadList() = default;
0026 
0027   SectionLoadList(const SectionLoadList &rhs);
0028 
0029   ~SectionLoadList() {
0030     // Call clear since this takes a lock and clears the section load list in
0031     // case another thread is currently using this section load list
0032     Clear();
0033   }
0034 
0035   void operator=(const SectionLoadList &rhs);
0036 
0037   bool IsEmpty() const;
0038 
0039   void Clear();
0040 
0041   lldb::addr_t GetSectionLoadAddress(const lldb::SectionSP &section_sp) const;
0042 
0043   bool ResolveLoadAddress(lldb::addr_t load_addr, Address &so_addr,
0044                           bool allow_section_end = false) const;
0045 
0046   bool SetSectionLoadAddress(const lldb::SectionSP &section_sp,
0047                              lldb::addr_t load_addr,
0048                              bool warn_multiple = false);
0049 
0050   // The old load address should be specified when unloading to ensure we get
0051   // the correct instance of the section as a shared library could be loaded at
0052   // more than one location.
0053   bool SetSectionUnloaded(const lldb::SectionSP &section_sp,
0054                           lldb::addr_t load_addr);
0055 
0056   // Unload all instances of a section. This function can be used on systems
0057   // that don't support multiple copies of the same shared library to be loaded
0058   // at the same time.
0059   size_t SetSectionUnloaded(const lldb::SectionSP &section_sp);
0060 
0061   void Dump(Stream &s, Target *target);
0062 
0063 protected:
0064   typedef std::map<lldb::addr_t, lldb::SectionSP> addr_to_sect_collection;
0065   typedef llvm::DenseMap<const Section *, lldb::addr_t> sect_to_addr_collection;
0066   addr_to_sect_collection m_addr_to_sect;
0067   sect_to_addr_collection m_sect_to_addr;
0068   mutable std::recursive_mutex m_mutex;
0069 };
0070 
0071 } // namespace lldb_private
0072 
0073 #endif // LLDB_TARGET_SECTIONLOADLIST_H