Skip to content

Alt mechanism to find the first loadable seg in a Mach-O binary #3941

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6261,6 +6261,15 @@ Section *ObjectFileMachO::GetMachHeaderSection() {
if (section->GetFileOffset() == 0 && SectionIsLoadable(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;
}

Expand Down