[Lldb-commits] [lldb] b0dc2fa - [lldb] Don't persist the LINKEDIT slide in the indirect symbol offset
Jonas Devlieghere via lldb-commits
lldb-commits at lists.llvm.org
Wed Mar 23 16:40:01 PDT 2022
Author: Jonas Devlieghere
Date: 2022-03-23T16:39:53-07:00
New Revision: b0dc2fae602579114525353c8403d6e6d128ad73
URL: https://github.com/llvm/llvm-project/commit/b0dc2fae602579114525353c8403d6e6d128ad73
DIFF: https://github.com/llvm/llvm-project/commit/b0dc2fae602579114525353c8403d6e6d128ad73.diff
LOG: [lldb] Don't persist the LINKEDIT slide in the indirect symbol offset
The current code increment the indirect symbol offset with the LINKEDIT
slide every time ObjectFileMachO::ParseSymtab is called.
This resulted in a crash when calling add-dsym which causes us to
potentially re-parse the original binary's symbol table. There's a
separate question about whether we should re-parse the symbol table at
all which was fixed by D114288. Regardless, copying the load command is
cheap enough that this is still the right thing to do.
rdar://72337717
Differential revision: https://reviews.llvm.org/D122349
Added:
Modified:
lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
Removed:
################################################################################
diff --git a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
index d728978c3e3aa..e28c65e95410a 100644
--- a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
+++ b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
@@ -2214,6 +2214,7 @@ void ObjectFileMachO::ParseSymtab(Symtab &symtab) {
llvm::MachO::linkedit_data_command function_starts_load_command = {0, 0, 0, 0};
llvm::MachO::linkedit_data_command exports_trie_load_command = {0, 0, 0, 0};
llvm::MachO::dyld_info_command dyld_info = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+ llvm::MachO::dysymtab_command dysymtab = m_dysymtab;
// The data element of type bool indicates that this entry is thumb
// code.
typedef AddressDataArray<lldb::addr_t, bool, 100> FunctionStarts;
@@ -2394,12 +2395,12 @@ void ObjectFileMachO::ParseSymtab(Symtab &symtab) {
ReadMemory(process_sp, symoff_addr, nlist_data_byte_size));
if (nlist_data_sp)
nlist_data.SetData(nlist_data_sp, 0, nlist_data_sp->GetByteSize());
- if (m_dysymtab.nindirectsyms != 0) {
+ if (dysymtab.nindirectsyms != 0) {
const addr_t indirect_syms_addr = linkedit_load_addr +
- m_dysymtab.indirectsymoff -
+ dysymtab.indirectsymoff -
linkedit_file_offset;
DataBufferSP indirect_syms_data_sp(ReadMemory(
- process_sp, indirect_syms_addr, m_dysymtab.nindirectsyms * 4));
+ process_sp, indirect_syms_addr, dysymtab.nindirectsyms * 4));
if (indirect_syms_data_sp)
indirect_symbol_index_data.SetData(
indirect_syms_data_sp, 0,
@@ -2452,7 +2453,7 @@ void ObjectFileMachO::ParseSymtab(Symtab &symtab) {
symtab_load_command.symoff += linkedit_slide;
symtab_load_command.stroff += linkedit_slide;
dyld_info.export_off += linkedit_slide;
- m_dysymtab.indirectsymoff += linkedit_slide;
+ dysymtab.indirectsymoff += linkedit_slide;
function_starts_load_command.dataoff += linkedit_slide;
exports_trie_load_command.dataoff += linkedit_slide;
}
@@ -2474,9 +2475,9 @@ void ObjectFileMachO::ParseSymtab(Symtab &symtab) {
exports_trie_load_command.datasize);
}
- if (m_dysymtab.nindirectsyms != 0) {
- indirect_symbol_index_data.SetData(m_data, m_dysymtab.indirectsymoff,
- m_dysymtab.nindirectsyms * 4);
+ if (dysymtab.nindirectsyms != 0) {
+ indirect_symbol_index_data.SetData(m_data, dysymtab.indirectsymoff,
+ dysymtab.nindirectsyms * 4);
}
if (function_starts_load_command.cmd) {
function_starts_data.SetData(m_data, function_starts_load_command.dataoff,
More information about the lldb-commits
mailing list