Skip to content

Commit aeb3081

Browse files
authored
Merge pull request #3941 from jasonmolenda/r88802629-manual-load-address-computation-fix
Alt mechanism to find the first loadable seg in a Mach-O binary
2 parents 698e047 + 085a705 commit aeb3081

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6261,6 +6261,15 @@ Section *ObjectFileMachO::GetMachHeaderSection() {
62616261
if (section->GetFileOffset() == 0 && SectionIsLoadable(section))
62626262
return section;
62636263
}
6264+
6265+
// We may have a binary in the shared cache that has a non-zero
6266+
// file address for its first segment, traditionally the __TEXT segment.
6267+
// Search for it by name and return it as our next best guess.
6268+
SectionSP text_segment_sp =
6269+
GetSectionList()->FindSectionByName(GetSegmentNameTEXT());
6270+
if (text_segment_sp.get() && SectionIsLoadable(text_segment_sp.get()))
6271+
return text_segment_sp.get();
6272+
62646273
return nullptr;
62656274
}
62666275

0 commit comments

Comments
 (0)