Skip to content

Commit f329ebf

Browse files
committed
[lldb] Prevent early exit for weak symbol found in IRExecutionUnit::FindInSymbols
`LoadAddressResolver::Resolve` returns zero for weak symbols. However `FindInSymbols` does multiple searches (each starting with `FindSymbolsWithNameAndType`), and a resolved address of zero from one step of the search should not conclude the search. This change continues the searching for a symbol by only performing an early exit when a concrete address is found. This was identified by an objc class which is available only in newer OSes. Such classes are weak linked. Expressions involving this class were failing, because the search first found the weak linked symbol. rdar://161406615
1 parent f4370fb commit f329ebf

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

lldb/source/Expression/IRExecutionUnit.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -822,23 +822,26 @@ IRExecutionUnit::FindInSymbols(const std::vector<ConstString> &names,
822822
sc.module_sp->FindSymbolsWithNameAndType(name, lldb::eSymbolTypeAny,
823823
sc_list);
824824
if (auto load_addr = resolver.Resolve(sc_list))
825-
return *load_addr;
825+
if (!symbol_was_missing_weak)
826+
return *load_addr;
826827
}
827828

828829
{
829830
SymbolContextList sc_list;
830831
m_preferred_modules.FindSymbolsWithNameAndType(name, lldb::eSymbolTypeAny,
831832
sc_list);
832833
if (auto load_addr = resolver.Resolve(sc_list))
833-
return *load_addr;
834+
if (!symbol_was_missing_weak)
835+
return *load_addr;
834836
}
835837

836838
{
837839
SymbolContextList sc_list;
838840
non_local_images.FindSymbolsWithNameAndType(name, lldb::eSymbolTypeAny,
839841
sc_list);
840842
if (auto load_addr = resolver.Resolve(sc_list))
841-
return *load_addr;
843+
if (!symbol_was_missing_weak)
844+
return *load_addr;
842845
}
843846

844847
lldb::addr_t best_internal_load_address =

0 commit comments

Comments
 (0)