@@ -921,6 +921,11 @@ ConstString ObjectFileMachO::GetSectionNameEHFrame() {
921921 return g_section_name_eh_frame;
922922}
923923
924+ ConstString ObjectFileMachO::GetSectionNameLLDBNoNlist () {
925+ static ConstString g_section_name_lldb_no_nlist (" __lldb_no_nlist" );
926+ return g_section_name_lldb_no_nlist;
927+ }
928+
924929bool ObjectFileMachO::MagicBytesMatch (DataBufferSP data_sp,
925930 lldb::addr_t data_offset,
926931 lldb::addr_t data_length) {
@@ -2399,15 +2404,54 @@ void ObjectFileMachO::ParseSymtab(Symtab &symtab) {
23992404 uint32_t memory_module_load_level = eMemoryModuleLoadLevelComplete;
24002405 bool is_shared_cache_image = IsSharedCacheBinary ();
24012406 bool is_local_shared_cache_image = is_shared_cache_image && !IsInMemory ();
2407+
2408+ ConstString g_segment_name_TEXT = GetSegmentNameTEXT ();
2409+ ConstString g_segment_name_DATA = GetSegmentNameDATA ();
2410+ ConstString g_segment_name_DATA_DIRTY = GetSegmentNameDATA_DIRTY ();
2411+ ConstString g_segment_name_DATA_CONST = GetSegmentNameDATA_CONST ();
2412+ ConstString g_segment_name_OBJC = GetSegmentNameOBJC ();
2413+ ConstString g_section_name_eh_frame = GetSectionNameEHFrame ();
2414+ ConstString g_section_name_lldb_no_nlist = GetSectionNameLLDBNoNlist ();
2415+ SectionSP text_section_sp (
2416+ section_list->FindSectionByName (g_segment_name_TEXT));
2417+ SectionSP data_section_sp (
2418+ section_list->FindSectionByName (g_segment_name_DATA));
24022419 SectionSP linkedit_section_sp (
24032420 section_list->FindSectionByName (GetSegmentNameLINKEDIT ()));
2421+ SectionSP data_dirty_section_sp (
2422+ section_list->FindSectionByName (g_segment_name_DATA_DIRTY));
2423+ SectionSP data_const_section_sp (
2424+ section_list->FindSectionByName (g_segment_name_DATA_CONST));
2425+ SectionSP objc_section_sp (
2426+ section_list->FindSectionByName (g_segment_name_OBJC));
2427+ SectionSP eh_frame_section_sp;
2428+ SectionSP lldb_no_nlist_section_sp;
2429+ if (text_section_sp.get ()) {
2430+ eh_frame_section_sp = text_section_sp->GetChildren ().FindSectionByName (
2431+ g_section_name_eh_frame);
2432+ lldb_no_nlist_section_sp = text_section_sp->GetChildren ().FindSectionByName (
2433+ g_section_name_lldb_no_nlist);
2434+ } else {
2435+ eh_frame_section_sp =
2436+ section_list->FindSectionByName (g_section_name_eh_frame);
2437+ lldb_no_nlist_section_sp =
2438+ section_list->FindSectionByName (g_section_name_lldb_no_nlist);
2439+ }
24042440
24052441 if (process && m_header.filetype != llvm::MachO::MH_OBJECT &&
24062442 !is_local_shared_cache_image) {
24072443 Target &target = process->GetTarget ();
24082444
24092445 memory_module_load_level = target.GetMemoryModuleLoadLevel ();
24102446
2447+ // If __TEXT,__lldb_no_nlist section is present in this binary,
2448+ // and we're reading it out of memory, do not read any of the
2449+ // nlist entries. They are not needed in lldb and it may be
2450+ // expensive to load these. This is to handle a dylib consisting
2451+ // of only metadata, no code, but it has many nlist entries.
2452+ if (lldb_no_nlist_section_sp)
2453+ memory_module_load_level = eMemoryModuleLoadLevelMinimal;
2454+
24112455 // Reading mach file from memory in a process or core file...
24122456
24132457 if (linkedit_section_sp) {
@@ -2532,30 +2576,6 @@ void ObjectFileMachO::ParseSymtab(Symtab &symtab) {
25322576
25332577 const bool have_strtab_data = strtab_data.GetByteSize () > 0 ;
25342578
2535- ConstString g_segment_name_TEXT = GetSegmentNameTEXT ();
2536- ConstString g_segment_name_DATA = GetSegmentNameDATA ();
2537- ConstString g_segment_name_DATA_DIRTY = GetSegmentNameDATA_DIRTY ();
2538- ConstString g_segment_name_DATA_CONST = GetSegmentNameDATA_CONST ();
2539- ConstString g_segment_name_OBJC = GetSegmentNameOBJC ();
2540- ConstString g_section_name_eh_frame = GetSectionNameEHFrame ();
2541- SectionSP text_section_sp (
2542- section_list->FindSectionByName (g_segment_name_TEXT));
2543- SectionSP data_section_sp (
2544- section_list->FindSectionByName (g_segment_name_DATA));
2545- SectionSP data_dirty_section_sp (
2546- section_list->FindSectionByName (g_segment_name_DATA_DIRTY));
2547- SectionSP data_const_section_sp (
2548- section_list->FindSectionByName (g_segment_name_DATA_CONST));
2549- SectionSP objc_section_sp (
2550- section_list->FindSectionByName (g_segment_name_OBJC));
2551- SectionSP eh_frame_section_sp;
2552- if (text_section_sp.get ())
2553- eh_frame_section_sp = text_section_sp->GetChildren ().FindSectionByName (
2554- g_section_name_eh_frame);
2555- else
2556- eh_frame_section_sp =
2557- section_list->FindSectionByName (g_section_name_eh_frame);
2558-
25592579 const bool is_arm = (m_header.cputype == llvm::MachO::CPU_TYPE_ARM);
25602580 const bool always_thumb = GetArchitecture ().IsAlwaysThumbInstructions ();
25612581
0 commit comments