From ea3ac27029077bc61ef8c1575ff3043eb9203efb Mon Sep 17 00:00:00 2001 From: Jim Ingham Date: Fri, 10 Jan 2014 22:55:37 +0000 Subject: [PATCH] =?utf8?q?The=20actual=20indirect=20symbol=20is=20not=20th?= =?utf8?q?e=20one=20at=20the=20address=20of=20the=20Trie=20entry=20marked?= =?utf8?q?=20with=20the=20EXPORT=5FSYMBOL=5FFLAGS=5FSTUB=5FAND=5FRESOLVER,?= =?utf8?q?=20it=20is=20given=20in=20the=20address=20in=20the=20=E2=80=9Cot?= =?utf8?q?her=E2=80=9D=20field=20in=20that=20entry.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit llvm-svn: 198967 --- .../ObjectFile/Mach-O/ObjectFileMachO.cpp | 69 +++++++++++-------- 1 file changed, 42 insertions(+), 27 deletions(-) diff --git a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp index eccc90ff5b17..7a34515c02fa 100644 --- a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp +++ b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp @@ -1569,8 +1569,9 @@ ParseTrieEntries (DataExtractor &data, e.entry.address = data.GetULEB128(&offset); if ( e.entry.flags & EXPORT_SYMBOL_FLAGS_STUB_AND_RESOLVER ) { - resolver_addresses.insert(e.entry.address); + //resolver_addresses.insert(e.entry.address); e.entry.other = data.GetULEB128(&offset); + resolver_addresses.insert(e.entry.other); } else e.entry.other = 0; @@ -2004,6 +2005,31 @@ ObjectFileMachO::ParseSymtab () std::string memory_symbol_name; uint32_t unmapped_local_symbols_found = 0; + std::vector trie_entries; + std::set resolver_addresses; + + if (dyld_trie_data.GetByteSize() > 0) + { + std::vector nameSlices; + ParseTrieEntries (dyld_trie_data, + 0, + nameSlices, + resolver_addresses, + trie_entries); + + ConstString text_segment_name ("__TEXT"); + SectionSP text_segment_sp = GetSectionList()->FindSectionByName(text_segment_name); + if (text_segment_sp) + { + const lldb::addr_t text_segment_file_addr = text_segment_sp->GetFileAddress(); + if (text_segment_file_addr != LLDB_INVALID_ADDRESS) + { + for (auto &e : trie_entries) + e.entry.address += text_segment_file_addr; + } + } + } + #if defined (__APPLE__) && defined (__arm__) // Some recent builds of the dyld_shared_cache (hereafter: DSC) have been optimized by moving LOCAL @@ -2839,10 +2865,17 @@ ObjectFileMachO::ParseSymtab () // into the N_FUN flags to avoid duplicate symbols in the symbol table sym[pos->second].SetExternal(sym[sym_idx].IsExternal()); sym[pos->second].SetFlags (nlist.n_type << 16 | nlist.n_desc); + if (resolver_addresses.find(nlist.n_value) != resolver_adresses.end()) + sym[pos->second].SetType (eSymbolTypeResolver); sym[sym_idx].Clear(); continue; } } + else + { + if (resolver_addresses.find(nlist.n_value) != resolver_adresses.end()) + sym[sym_idx].SetType (eSymbolTypeResolver); + } } else if (type == eSymbolTypeData) { @@ -2919,7 +2952,7 @@ ObjectFileMachO::ParseSymtab () // Must reset this in case it was mutated above! nlist_data_offset = 0; #endif - + if (nlist_data.GetByteSize() > 0) { @@ -3584,10 +3617,17 @@ ObjectFileMachO::ParseSymtab () // into the N_FUN flags to avoid duplicate symbols in the symbol table sym[pos->second].SetExternal(sym[sym_idx].IsExternal()); sym[pos->second].SetFlags (nlist.n_type << 16 | nlist.n_desc); + if (resolver_addresses.find(nlist.n_value) != resolver_addresses.end()) + sym[pos->second].SetType (eSymbolTypeResolver); sym[sym_idx].Clear(); continue; } } + else + { + if (resolver_addresses.find(nlist.n_value) != resolver_addresses.end()) + sym[sym_idx].SetType (eSymbolTypeResolver); + } } else if (type == eSymbolTypeData) { @@ -3736,31 +3776,6 @@ ObjectFileMachO::ParseSymtab () sym = symtab->Resize (num_syms); } - std::vector trie_entries; - std::set resolver_addresses; - - if (dyld_trie_data.GetByteSize() > 0) - { - std::vector nameSlices; - ParseTrieEntries (dyld_trie_data, - 0, - nameSlices, - resolver_addresses, - trie_entries); - - ConstString text_segment_name ("__TEXT"); - SectionSP text_segment_sp = GetSectionList()->FindSectionByName(text_segment_name); - if (text_segment_sp) - { - const lldb::addr_t text_segment_file_addr = text_segment_sp->GetFileAddress(); - if (text_segment_file_addr != LLDB_INVALID_ADDRESS) - { - for (auto &e : trie_entries) - e.entry.address += text_segment_file_addr; - } - } - } - // Now synthesize indirect symbols if (m_dysymtab.nindirectsyms != 0) { -- 2.34.1