forked from OSchip/llvm-project
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
This commit is contained in:
parent
b85cfe208f
commit
4a394367c1
|
@ -6102,6 +6102,15 @@ Section *ObjectFileMachO::GetMachHeaderSection() {
|
||||||
if (section->GetFileOffset() == 0 && SectionIsLoadable(section))
|
if (section->GetFileOffset() == 0 && SectionIsLoadable(section))
|
||||||
return section;
|
return section;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// We may have a binary in the shared cache that has a non-zero
|
||||||
|
// file address for its first segment, traditionally the __TEXT segment.
|
||||||
|
// Search for it by name and return it as our next best guess.
|
||||||
|
SectionSP text_segment_sp =
|
||||||
|
GetSectionList()->FindSectionByName(GetSegmentNameTEXT());
|
||||||
|
if (text_segment_sp.get() && SectionIsLoadable(text_segment_sp.get()))
|
||||||
|
return text_segment_sp.get();
|
||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue