@@ -921,6 +921,11 @@ ConstString ObjectFileMachO::GetSectionNameEHFrame() {
921
921
return g_section_name_eh_frame;
922
922
}
923
923
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
+
924
929
bool ObjectFileMachO::MagicBytesMatch (DataBufferSP data_sp,
925
930
lldb::addr_t data_offset,
926
931
lldb::addr_t data_length) {
@@ -2395,15 +2400,54 @@ void ObjectFileMachO::ParseSymtab(Symtab &symtab) {
2395
2400
uint32_t memory_module_load_level = eMemoryModuleLoadLevelComplete;
2396
2401
bool is_shared_cache_image = IsSharedCacheBinary ();
2397
2402
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));
2398
2415
SectionSP linkedit_section_sp (
2399
2416
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
+ }
2400
2436
2401
2437
if (process && m_header.filetype != llvm::MachO::MH_OBJECT &&
2402
2438
!is_local_shared_cache_image) {
2403
2439
Target &target = process->GetTarget ();
2404
2440
2405
2441
memory_module_load_level = target.GetMemoryModuleLoadLevel ();
2406
2442
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
+
2407
2451
// Reading mach file from memory in a process or core file...
2408
2452
2409
2453
if (linkedit_section_sp) {
@@ -2528,30 +2572,6 @@ void ObjectFileMachO::ParseSymtab(Symtab &symtab) {
2528
2572
2529
2573
const bool have_strtab_data = strtab_data.GetByteSize () > 0 ;
2530
2574
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
-
2555
2575
const bool is_arm = (m_header.cputype == llvm::MachO::CPU_TYPE_ARM);
2556
2576
const bool always_thumb = GetArchitecture ().IsAlwaysThumbInstructions ();
2557
2577
0 commit comments