@@ -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) {
@@ -2395,15 +2400,54 @@ void ObjectFileMachO::ParseSymtab(Symtab &symtab) {
23952400 uint32_t memory_module_load_level = eMemoryModuleLoadLevelComplete;
23962401 bool is_shared_cache_image = IsSharedCacheBinary ();
23972402 bool is_local_shared_cache_image = is_shared_cache_image && !IsInMemory ();
2403+
2404+ ConstString g_segment_name_TEXT = GetSegmentNameTEXT ();
2405+ ConstString g_segment_name_DATA = GetSegmentNameDATA ();
2406+ ConstString g_segment_name_DATA_DIRTY = GetSegmentNameDATA_DIRTY ();
2407+ ConstString g_segment_name_DATA_CONST = GetSegmentNameDATA_CONST ();
2408+ ConstString g_segment_name_OBJC = GetSegmentNameOBJC ();
2409+ ConstString g_section_name_eh_frame = GetSectionNameEHFrame ();
2410+ ConstString g_section_name_lldb_no_nlist = GetSectionNameLLDBNoNlist ();
2411+ SectionSP text_section_sp (
2412+ section_list->FindSectionByName (g_segment_name_TEXT));
2413+ SectionSP data_section_sp (
2414+ section_list->FindSectionByName (g_segment_name_DATA));
23982415 SectionSP linkedit_section_sp (
23992416 section_list->FindSectionByName (GetSegmentNameLINKEDIT ()));
2417+ SectionSP data_dirty_section_sp (
2418+ section_list->FindSectionByName (g_segment_name_DATA_DIRTY));
2419+ SectionSP data_const_section_sp (
2420+ section_list->FindSectionByName (g_segment_name_DATA_CONST));
2421+ SectionSP objc_section_sp (
2422+ section_list->FindSectionByName (g_segment_name_OBJC));
2423+ SectionSP eh_frame_section_sp;
2424+ SectionSP lldb_no_nlist_section_sp;
2425+ if (text_section_sp.get ()) {
2426+ eh_frame_section_sp = text_section_sp->GetChildren ().FindSectionByName (
2427+ g_section_name_eh_frame);
2428+ lldb_no_nlist_section_sp = text_section_sp->GetChildren ().FindSectionByName (
2429+ g_section_name_lldb_no_nlist);
2430+ } else {
2431+ eh_frame_section_sp =
2432+ section_list->FindSectionByName (g_section_name_eh_frame);
2433+ lldb_no_nlist_section_sp =
2434+ section_list->FindSectionByName (g_section_name_lldb_no_nlist);
2435+ }
24002436
24012437 if (process && m_header.filetype != llvm::MachO::MH_OBJECT &&
24022438 !is_local_shared_cache_image) {
24032439 Target &target = process->GetTarget ();
24042440
24052441 memory_module_load_level = target.GetMemoryModuleLoadLevel ();
24062442
2443+ // If __TEXT,__lldb_no_nlist section is present in this binary,
2444+ // and we're reading it out of memory, do not read any of the
2445+ // nlist entries. They are not needed in lldb and it may be
2446+ // expensive to load these. This is to handle a dylib consisting
2447+ // of only metadata, no code, but it has many nlist entries.
2448+ if (lldb_no_nlist_section_sp)
2449+ memory_module_load_level = eMemoryModuleLoadLevelMinimal;
2450+
24072451 // Reading mach file from memory in a process or core file...
24082452
24092453 if (linkedit_section_sp) {
@@ -2528,30 +2572,6 @@ void ObjectFileMachO::ParseSymtab(Symtab &symtab) {
25282572
25292573 const bool have_strtab_data = strtab_data.GetByteSize () > 0 ;
25302574
2531- ConstString g_segment_name_TEXT = GetSegmentNameTEXT ();
2532- ConstString g_segment_name_DATA = GetSegmentNameDATA ();
2533- ConstString g_segment_name_DATA_DIRTY = GetSegmentNameDATA_DIRTY ();
2534- ConstString g_segment_name_DATA_CONST = GetSegmentNameDATA_CONST ();
2535- ConstString g_segment_name_OBJC = GetSegmentNameOBJC ();
2536- ConstString g_section_name_eh_frame = GetSectionNameEHFrame ();
2537- SectionSP text_section_sp (
2538- section_list->FindSectionByName (g_segment_name_TEXT));
2539- SectionSP data_section_sp (
2540- section_list->FindSectionByName (g_segment_name_DATA));
2541- SectionSP data_dirty_section_sp (
2542- section_list->FindSectionByName (g_segment_name_DATA_DIRTY));
2543- SectionSP data_const_section_sp (
2544- section_list->FindSectionByName (g_segment_name_DATA_CONST));
2545- SectionSP objc_section_sp (
2546- section_list->FindSectionByName (g_segment_name_OBJC));
2547- SectionSP eh_frame_section_sp;
2548- if (text_section_sp.get ())
2549- eh_frame_section_sp = text_section_sp->GetChildren ().FindSectionByName (
2550- g_section_name_eh_frame);
2551- else
2552- eh_frame_section_sp =
2553- section_list->FindSectionByName (g_section_name_eh_frame);
2554-
25552575 const bool is_arm = (m_header.cputype == llvm::MachO::CPU_TYPE_ARM);
25562576 const bool always_thumb = GetArchitecture ().IsAlwaysThumbInstructions ();
25572577
0 commit comments