File tree Expand file tree Collapse file tree 1 file changed +10
-8
lines changed
lldb/source/Plugins/ObjectFile/Mach-O Expand file tree Collapse file tree 1 file changed +10
-8
lines changed Original file line number Diff line number Diff line change @@ -6141,21 +6141,23 @@ Section *ObjectFileMachO::GetMachHeaderSection() {
6141
6141
SectionList *section_list = GetSectionList ();
6142
6142
if (!section_list)
6143
6143
return nullptr ;
6144
+
6145
+ // Some binaries can have a TEXT segment with a non-zero file offset.
6146
+ // Binaries in the shared cache are one example. Some hand-generated
6147
+ // binaries may not be laid out in the normal TEXT,DATA,LC_SYMTAB order
6148
+ // in the file, even though they're laid out correctly in vmaddr terms.
6149
+ SectionSP text_segment_sp =
6150
+ section_list->FindSectionByName (GetSegmentNameTEXT ());
6151
+ if (text_segment_sp.get () && SectionIsLoadable (text_segment_sp.get ()))
6152
+ return text_segment_sp.get ();
6153
+
6144
6154
const size_t num_sections = section_list->GetSize ();
6145
6155
for (size_t sect_idx = 0 ; sect_idx < num_sections; ++sect_idx) {
6146
6156
Section *section = section_list->GetSectionAtIndex (sect_idx).get ();
6147
6157
if (section->GetFileOffset () == 0 && SectionIsLoadable (section))
6148
6158
return section;
6149
6159
}
6150
6160
6151
- // We may have a binary in the shared cache that has a non-zero
6152
- // file address for its first segment, traditionally the __TEXT segment.
6153
- // Search for it by name and return it as our next best guess.
6154
- SectionSP text_segment_sp =
6155
- GetSectionList ()->FindSectionByName (GetSegmentNameTEXT ());
6156
- if (text_segment_sp.get () && SectionIsLoadable (text_segment_sp.get ()))
6157
- return text_segment_sp.get ();
6158
-
6159
6161
return nullptr ;
6160
6162
}
6161
6163
You can’t perform that action at this time.
0 commit comments