Get Section from resolved_addr in Target::ReadMemory

Landing this fix for Augusto Noronha.  The code is getting the
Section from 'addr' passed in, but it may have been expressed as
a load address when it was created and Target::ReadMemory tries to
convert it to a Section+offset if that's now possible; use the
Section found from that cleanup if it exists.

Differential Revision: https://reviews.llvm.org/D100850
This commit is contained in:
Jason Molenda 2021-04-20 12:07:24 -07:00
parent 9816d43cff
commit f2da1f68d8

View file

@ -1756,7 +1756,7 @@ size_t Target::ReadMemory(const Address &addr, void *dst, size_t dst_len,
bool is_readonly = false;
// Read from file cache if read-only section.
if (!force_live_memory && resolved_addr.IsSectionOffset()) {
SectionSP section_sp(addr.GetSection());
SectionSP section_sp(resolved_addr.GetSection());
if (section_sp) {
auto permissions = Flags(section_sp->GetPermissions());
is_readonly = !permissions.Test(ePermissionsWritable) &&