The actual indirect symbol is not the one at the address of the Trie entry marked with the EXPORT_SYMBOL_FLAGS_STUB_AND_RESOLVER, it is given in the address in the “other” field in that entry.

llvm-svn: 198967
This commit is contained in:
Jim Ingham 2014-01-10 22:55:37 +00:00
parent 9b41aa7275
commit ea3ac27029
1 changed files with 42 additions and 27 deletions

View File

@ -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<TrieEntryWithOffset> trie_entries;
std::set<lldb::addr_t> resolver_addresses;
if (dyld_trie_data.GetByteSize() > 0)
{
std::vector<llvm::StringRef> 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<TrieEntryWithOffset> trie_entries;
std::set<lldb::addr_t> resolver_addresses;
if (dyld_trie_data.GetByteSize() > 0)
{
std::vector<llvm::StringRef> 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)
{