Skip to content

Commit 82af988

Browse files
committed
Revert "[lldb][Mach-O] Don't read symbol table of specially marked binary (#129967)"
This reverts commit 397696b. This breaks the macOS CI bots, I need to use $LDFLAGS in the $LD invocation when building the dylib to get the dylibs to build on the CI bots. But I've added "-lno-nlists -lhas-nlists" to the LDFLAGS for the main binary in the same directory, so using LDFLAGS will result in a compile error for the dylibs. I'll need to build the dylibs in a subdir with a different Makefile, will reland with that change in a bit.
1 parent cec36e2 commit 82af988

File tree

8 files changed

+24
-202
lines changed

8 files changed

+24
-202
lines changed

lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp

Lines changed: 24 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -918,11 +918,6 @@ ConstString ObjectFileMachO::GetSectionNameEHFrame() {
918918
return g_section_name_eh_frame;
919919
}
920920

921-
ConstString ObjectFileMachO::GetSectionNameLLDBNoNlist() {
922-
static ConstString g_section_name_lldb_no_nlist("__lldb_no_nlist");
923-
return g_section_name_lldb_no_nlist;
924-
}
925-
926921
bool ObjectFileMachO::MagicBytesMatch(DataBufferSP data_sp,
927922
lldb::addr_t data_offset,
928923
lldb::addr_t data_length) {
@@ -2399,54 +2394,15 @@ void ObjectFileMachO::ParseSymtab(Symtab &symtab) {
23992394
uint32_t memory_module_load_level = eMemoryModuleLoadLevelComplete;
24002395
bool is_shared_cache_image = IsSharedCacheBinary();
24012396
bool is_local_shared_cache_image = is_shared_cache_image && !IsInMemory();
2402-
2403-
ConstString g_segment_name_TEXT = GetSegmentNameTEXT();
2404-
ConstString g_segment_name_DATA = GetSegmentNameDATA();
2405-
ConstString g_segment_name_DATA_DIRTY = GetSegmentNameDATA_DIRTY();
2406-
ConstString g_segment_name_DATA_CONST = GetSegmentNameDATA_CONST();
2407-
ConstString g_segment_name_OBJC = GetSegmentNameOBJC();
2408-
ConstString g_section_name_eh_frame = GetSectionNameEHFrame();
2409-
ConstString g_section_name_lldb_no_nlist = GetSectionNameLLDBNoNlist();
2410-
SectionSP text_section_sp(
2411-
section_list->FindSectionByName(g_segment_name_TEXT));
2412-
SectionSP data_section_sp(
2413-
section_list->FindSectionByName(g_segment_name_DATA));
24142397
SectionSP linkedit_section_sp(
24152398
section_list->FindSectionByName(GetSegmentNameLINKEDIT()));
2416-
SectionSP data_dirty_section_sp(
2417-
section_list->FindSectionByName(g_segment_name_DATA_DIRTY));
2418-
SectionSP data_const_section_sp(
2419-
section_list->FindSectionByName(g_segment_name_DATA_CONST));
2420-
SectionSP objc_section_sp(
2421-
section_list->FindSectionByName(g_segment_name_OBJC));
2422-
SectionSP eh_frame_section_sp;
2423-
SectionSP lldb_no_nlist_section_sp;
2424-
if (text_section_sp.get()) {
2425-
eh_frame_section_sp = text_section_sp->GetChildren().FindSectionByName(
2426-
g_section_name_eh_frame);
2427-
lldb_no_nlist_section_sp = text_section_sp->GetChildren().FindSectionByName(
2428-
g_section_name_lldb_no_nlist);
2429-
} else {
2430-
eh_frame_section_sp =
2431-
section_list->FindSectionByName(g_section_name_eh_frame);
2432-
lldb_no_nlist_section_sp =
2433-
section_list->FindSectionByName(g_section_name_lldb_no_nlist);
2434-
}
24352399

24362400
if (process && m_header.filetype != llvm::MachO::MH_OBJECT &&
24372401
!is_local_shared_cache_image) {
24382402
Target &target = process->GetTarget();
24392403

24402404
memory_module_load_level = target.GetMemoryModuleLoadLevel();
24412405

2442-
// If __TEXT,__lldb_no_nlist section is present in this binary,
2443-
// and we're reading it out of memory, do not read any of the
2444-
// nlist entries. They are not needed in lldb and it may be
2445-
// expensive to load these. This is to handle a dylib consisting
2446-
// of only metadata, no code, but it has many nlist entries.
2447-
if (lldb_no_nlist_section_sp)
2448-
memory_module_load_level = eMemoryModuleLoadLevelMinimal;
2449-
24502406
// Reading mach file from memory in a process or core file...
24512407

24522408
if (linkedit_section_sp) {
@@ -2570,6 +2526,30 @@ void ObjectFileMachO::ParseSymtab(Symtab &symtab) {
25702526

25712527
const bool have_strtab_data = strtab_data.GetByteSize() > 0;
25722528

2529+
ConstString g_segment_name_TEXT = GetSegmentNameTEXT();
2530+
ConstString g_segment_name_DATA = GetSegmentNameDATA();
2531+
ConstString g_segment_name_DATA_DIRTY = GetSegmentNameDATA_DIRTY();
2532+
ConstString g_segment_name_DATA_CONST = GetSegmentNameDATA_CONST();
2533+
ConstString g_segment_name_OBJC = GetSegmentNameOBJC();
2534+
ConstString g_section_name_eh_frame = GetSectionNameEHFrame();
2535+
SectionSP text_section_sp(
2536+
section_list->FindSectionByName(g_segment_name_TEXT));
2537+
SectionSP data_section_sp(
2538+
section_list->FindSectionByName(g_segment_name_DATA));
2539+
SectionSP data_dirty_section_sp(
2540+
section_list->FindSectionByName(g_segment_name_DATA_DIRTY));
2541+
SectionSP data_const_section_sp(
2542+
section_list->FindSectionByName(g_segment_name_DATA_CONST));
2543+
SectionSP objc_section_sp(
2544+
section_list->FindSectionByName(g_segment_name_OBJC));
2545+
SectionSP eh_frame_section_sp;
2546+
if (text_section_sp.get())
2547+
eh_frame_section_sp = text_section_sp->GetChildren().FindSectionByName(
2548+
g_section_name_eh_frame);
2549+
else
2550+
eh_frame_section_sp =
2551+
section_list->FindSectionByName(g_section_name_eh_frame);
2552+
25732553
const bool is_arm = (m_header.cputype == llvm::MachO::CPU_TYPE_ARM);
25742554
const bool always_thumb = GetArchitecture().IsAlwaysThumbInstructions();
25752555

lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,6 @@ class ObjectFileMachO : public lldb_private::ObjectFile {
286286
static lldb_private::ConstString GetSegmentNameDWARF();
287287
static lldb_private::ConstString GetSegmentNameLLVM_COV();
288288
static lldb_private::ConstString GetSectionNameEHFrame();
289-
static lldb_private::ConstString GetSectionNameLLDBNoNlist();
290289

291290
llvm::MachO::dysymtab_command m_dysymtab;
292291
std::vector<llvm::MachO::section_64> m_mach_sections;

lldb/test/API/macosx/no-nlist-memory-module/Makefile

Lines changed: 0 additions & 19 deletions
This file was deleted.

lldb/test/API/macosx/no-nlist-memory-module/TestNoNlistsDylib.py

Lines changed: 0 additions & 71 deletions
This file was deleted.

lldb/test/API/macosx/no-nlist-memory-module/has-nlists.c

Lines changed: 0 additions & 1 deletion
This file was deleted.

lldb/test/API/macosx/no-nlist-memory-module/main.c

Lines changed: 0 additions & 62 deletions
This file was deleted.

lldb/test/API/macosx/no-nlist-memory-module/no-nlist-sect.s

Lines changed: 0 additions & 3 deletions
This file was deleted.

lldb/test/API/macosx/no-nlist-memory-module/no-nlists.c

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)