Skip to content

Commit 9a4d2a3

Browse files
authored
Merge pull request #19919 from mikeash/remotemirrors-macho-parsing
[RemoteMirrors] Fix the computation of the section start address in readMachOSections
2 parents 36786a0 + 8624325 commit 9a4d2a3

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

include/swift/Reflection/ReflectionContext.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,9 +154,11 @@ class ReflectionContext
154154
SectAddress + (I * sizeof(typename T::Section)));
155155
if (strncmp(S->sectname, Name.c_str(), strlen(Name.c_str())) != 0)
156156
continue;
157-
auto SecStart = Start + S->offset;
157+
auto Slide = ImageStart.getAddressData() - Command->vmaddr;
158+
auto RemoteSecStart = S->addr + Slide;
159+
auto LocalSecStart = RemoteSecStart - ImageStart.getAddressData() + Start;
158160
auto SecSize = S->size;
159-
return {{SecStart, SecStart + SecSize}, 0};
161+
return {{LocalSecStart, LocalSecStart + SecSize}, 0};
160162
}
161163
return {{nullptr, nullptr}, 0};
162164
};

0 commit comments

Comments
 (0)