[Lldb-commits] [PATCH] D150239: ObjectFileMachO: Prioritize the TEXT segment as the mach header segment, regardless of the order the segments appear in the file
Jason Molenda via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Wed May 10 16:42:58 PDT 2023
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf9759d0cb6dc: Prioritize using a segment with the name TEXT instead off fileoff 0 (authored by jasonmolenda).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D150239/new/
https://reviews.llvm.org/D150239
Files:
lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
Index: lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
===================================================================
--- lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
+++ lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
@@ -6059,6 +6059,16 @@
SectionList *section_list = GetSectionList();
if (!section_list)
return nullptr;
+
+ // Some binaries can have a TEXT segment with a non-zero file offset.
+ // Binaries in the shared cache are one example. Some hand-generated
+ // binaries may not be laid out in the normal TEXT,DATA,LC_SYMTAB order
+ // in the file, even though they're laid out correctly in vmaddr terms.
+ SectionSP text_segment_sp =
+ section_list->FindSectionByName(GetSegmentNameTEXT());
+ if (text_segment_sp.get() && SectionIsLoadable(text_segment_sp.get()))
+ return text_segment_sp.get();
+
const size_t num_sections = section_list->GetSize();
for (size_t sect_idx = 0; sect_idx < num_sections; ++sect_idx) {
Section *section = section_list->GetSectionAtIndex(sect_idx).get();
@@ -6066,14 +6076,6 @@
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;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D150239.521157.patch
Type: text/x-patch
Size: 1565 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20230510/eb453a12/attachment.bin>
More information about the lldb-commits
mailing list