summaryrefslogtreecommitdiff
path: root/lldb/source/Target/SectionLoadList.cpp
diff options
context:
space:
mode:
authorJason Molenda <jason@molenda.com>2022-09-27 16:17:22 -0700
committerJason Molenda <jason@molenda.com>2022-09-27 16:20:26 -0700
commit1fee25629d9d3f33cc618cb2b61cdf3823bfd092 (patch)
tree9f3a0b1c125c5f1a19d07d8b56dfd6831dae4fee /lldb/source/Target/SectionLoadList.cpp
parent0195d13232205d30041d164f803d7b03adc9eff8 (diff)
Clear old section-to-addr entry when loading Section at new addr
SectionLoadList has a section-to-address map (m_sect_to_addr) and an address-to-section map (m_addr_to_sect). When the load address of a section is updated, the old entry from m_addr_to_sect would never be cleared, resulting in incorrect address-to-section address lookups from that point forward. Differential Revision: https://reviews.llvm.org/D130534 rdar://97308773
Diffstat (limited to 'lldb/source/Target/SectionLoadList.cpp')
-rw-r--r--lldb/source/Target/SectionLoadList.cpp12
1 files changed, 11 insertions, 1 deletions
diff --git a/lldb/source/Target/SectionLoadList.cpp b/lldb/source/Target/SectionLoadList.cpp
index 03160ee10dd8..a78ca3360f2e 100644
--- a/lldb/source/Target/SectionLoadList.cpp
+++ b/lldb/source/Target/SectionLoadList.cpp
@@ -116,8 +116,18 @@ bool SectionLoadList::SetSectionLoadAddress(const lldb::SectionSP &section,
}
}
ats_pos->second = section;
- } else
+ } else {
+ // Remove the old address->section entry, if
+ // there is one.
+ for (const auto &entry : m_addr_to_sect) {
+ if (entry.second == section) {
+ const auto &it_pos = m_addr_to_sect.find(entry.first);
+ m_addr_to_sect.erase(it_pos);
+ break;
+ }
+ }
m_addr_to_sect[load_addr] = section;
+ }
return true; // Changed
} else {