Skip to content

Commit 085a705

Browse files
committed
Alt mechanism to find the first loadable seg in a Mach-O binary
ObjectFileMachO, for a couple of special binaries at the initial launch, needs to find segment load addresses before the Target's SectionLoadList has been initialized. The calculation to find the first segment, which is at the same address as the mach header, was not correct if the binary was in the Darwin shared cache. Update the logic to handle that case. Differential Revision: https://reviews.llvm.org/D119602 rdar://88802629 (cherry picked from commit 4a39436)
1 parent 698e047 commit 085a705

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)