Revert "[NFC] Refactor symbol table parsing."
This reverts commit 951b107eed.
Buildbots were failing, there is a deadlock in /Users/gclayton/Documents/src/llvm/clean/llvm-project/lldb/test/Shell/SymbolFile/DWARF/DW_AT_range-DW_FORM_sec_offset.s when ELF files try to relocate things.
This commit is contained in:
@@ -1311,6 +1311,22 @@ AddressClass ObjectFileMachO::GetAddressClass(lldb::addr_t file_addr) {
|
||||
return AddressClass::eUnknown;
|
||||
}
|
||||
|
||||
Symtab *ObjectFileMachO::GetSymtab() {
|
||||
ModuleSP module_sp(GetModule());
|
||||
if (module_sp) {
|
||||
std::lock_guard<std::recursive_mutex> guard(module_sp->GetMutex());
|
||||
if (m_symtab_up == nullptr) {
|
||||
ElapsedTime elapsed(module_sp->GetSymtabParseTime());
|
||||
m_symtab_up = std::make_unique<Symtab>(this);
|
||||
std::lock_guard<std::recursive_mutex> symtab_guard(
|
||||
m_symtab_up->GetMutex());
|
||||
ParseSymtab();
|
||||
m_symtab_up->Finalize();
|
||||
}
|
||||
}
|
||||
return m_symtab_up.get();
|
||||
}
|
||||
|
||||
bool ObjectFileMachO::IsStripped() {
|
||||
if (m_dysymtab.cmd == 0) {
|
||||
ModuleSP module_sp(GetModule());
|
||||
@@ -2217,12 +2233,12 @@ ParseNList(DataExtractor &nlist_data, lldb::offset_t &nlist_data_offset,
|
||||
|
||||
enum { DebugSymbols = true, NonDebugSymbols = false };
|
||||
|
||||
void ObjectFileMachO::ParseSymtab(Symtab &symtab) {
|
||||
size_t ObjectFileMachO::ParseSymtab() {
|
||||
LLDB_SCOPED_TIMERF("ObjectFileMachO::ParseSymtab () module = %s",
|
||||
m_file.GetFilename().AsCString(""));
|
||||
ModuleSP module_sp(GetModule());
|
||||
if (!module_sp)
|
||||
return;
|
||||
return 0;
|
||||
|
||||
Progress progress(llvm::formatv("Parsing symbol table for {0}",
|
||||
m_file.GetFilename().AsCString("<Unknown>")));
|
||||
@@ -2272,7 +2288,7 @@ void ObjectFileMachO::ParseSymtab(Symtab &symtab) {
|
||||
// Read in the rest of the symtab load command
|
||||
if (m_data.GetU32(&offset, &symtab_load_command.symoff, 4) ==
|
||||
nullptr) // fill in symoff, nsyms, stroff, strsize fields
|
||||
return;
|
||||
return 0;
|
||||
break;
|
||||
|
||||
case LC_DYLD_INFO:
|
||||
@@ -2331,11 +2347,12 @@ void ObjectFileMachO::ParseSymtab(Symtab &symtab) {
|
||||
}
|
||||
|
||||
if (!symtab_load_command.cmd)
|
||||
return;
|
||||
return 0;
|
||||
|
||||
Symtab *symtab = m_symtab_up.get();
|
||||
SectionList *section_list = GetSectionList();
|
||||
if (section_list == nullptr)
|
||||
return;
|
||||
return 0;
|
||||
|
||||
const uint32_t addr_byte_size = m_data.GetAddressByteSize();
|
||||
const ByteOrder byte_order = m_data.GetByteOrder();
|
||||
@@ -2472,7 +2489,7 @@ void ObjectFileMachO::ParseSymtab(Symtab &symtab) {
|
||||
|
||||
// We shouldn't have exports data from both the LC_DYLD_INFO command
|
||||
// AND the LC_DYLD_EXPORTS_TRIE command in the same binary:
|
||||
lldbassert(!((dyld_info.export_size > 0)
|
||||
lldbassert(!((dyld_info.export_size > 0)
|
||||
&& (exports_trie_load_command.datasize > 0)));
|
||||
if (dyld_info.export_size > 0) {
|
||||
dyld_trie_data.SetData(m_data, dyld_info.export_off,
|
||||
@@ -2864,10 +2881,10 @@ void ObjectFileMachO::ParseSymtab(Symtab &symtab) {
|
||||
|
||||
// The normal nlist code cannot correctly size the Symbols
|
||||
// array, we need to allocate it here.
|
||||
sym = symtab.Resize(
|
||||
sym = symtab->Resize(
|
||||
symtab_load_command.nsyms + m_dysymtab.nindirectsyms +
|
||||
unmapped_local_symbols_found - m_dysymtab.nlocalsym);
|
||||
num_syms = symtab.GetNumSymbols();
|
||||
num_syms = symtab->GetNumSymbols();
|
||||
|
||||
nlist_data_offset =
|
||||
local_symbols_info.nlistOffset +
|
||||
@@ -2999,7 +3016,7 @@ void ObjectFileMachO::ParseSymtab(Symtab &symtab) {
|
||||
// original
|
||||
// STAB entry so we don't have
|
||||
// to hunt for it later
|
||||
symtab.SymbolAtIndex(N_FUN_indexes.back())
|
||||
symtab->SymbolAtIndex(N_FUN_indexes.back())
|
||||
->SetByteSize(nlist.n_value);
|
||||
N_FUN_indexes.pop_back();
|
||||
// We don't really need the end function STAB as
|
||||
@@ -3079,7 +3096,7 @@ void ObjectFileMachO::ParseSymtab(Symtab &symtab) {
|
||||
// index of this N_SO so that we can always skip
|
||||
// the entire N_SO if we need to navigate more
|
||||
// quickly at the source level when parsing STABS
|
||||
symbol_ptr = symtab.SymbolAtIndex(N_SO_index);
|
||||
symbol_ptr = symtab->SymbolAtIndex(N_SO_index);
|
||||
symbol_ptr->SetByteSize(sym_idx);
|
||||
symbol_ptr->SetSizeIsSibling(true);
|
||||
}
|
||||
@@ -3186,7 +3203,7 @@ void ObjectFileMachO::ParseSymtab(Symtab &symtab) {
|
||||
// quickly at the source level when parsing STABS
|
||||
if (!N_INCL_indexes.empty()) {
|
||||
symbol_ptr =
|
||||
symtab.SymbolAtIndex(N_INCL_indexes.back());
|
||||
symtab->SymbolAtIndex(N_INCL_indexes.back());
|
||||
symbol_ptr->SetByteSize(sym_idx + 1);
|
||||
symbol_ptr->SetSizeIsSibling(true);
|
||||
N_INCL_indexes.pop_back();
|
||||
@@ -3251,7 +3268,7 @@ void ObjectFileMachO::ParseSymtab(Symtab &symtab) {
|
||||
nlist.n_value);
|
||||
if (!N_BRAC_indexes.empty()) {
|
||||
symbol_ptr =
|
||||
symtab.SymbolAtIndex(N_BRAC_indexes.back());
|
||||
symtab->SymbolAtIndex(N_BRAC_indexes.back());
|
||||
symbol_ptr->SetByteSize(sym_idx + 1);
|
||||
symbol_ptr->SetSizeIsSibling(true);
|
||||
N_BRAC_indexes.pop_back();
|
||||
@@ -3289,7 +3306,7 @@ void ObjectFileMachO::ParseSymtab(Symtab &symtab) {
|
||||
// parsing STABS
|
||||
if (!N_COMM_indexes.empty()) {
|
||||
symbol_ptr =
|
||||
symtab.SymbolAtIndex(N_COMM_indexes.back());
|
||||
symtab->SymbolAtIndex(N_COMM_indexes.back());
|
||||
symbol_ptr->SetByteSize(sym_idx + 1);
|
||||
symbol_ptr->SetSizeIsSibling(true);
|
||||
N_COMM_indexes.pop_back();
|
||||
@@ -3789,8 +3806,8 @@ void ObjectFileMachO::ParseSymtab(Symtab &symtab) {
|
||||
// symbols, create it now.
|
||||
if (sym == nullptr) {
|
||||
sym =
|
||||
symtab.Resize(symtab_load_command.nsyms + m_dysymtab.nindirectsyms);
|
||||
num_syms = symtab.GetNumSymbols();
|
||||
symtab->Resize(symtab_load_command.nsyms + m_dysymtab.nindirectsyms);
|
||||
num_syms = symtab->GetNumSymbols();
|
||||
}
|
||||
|
||||
if (unmapped_local_symbols_found) {
|
||||
@@ -3924,7 +3941,7 @@ void ObjectFileMachO::ParseSymtab(Symtab &symtab) {
|
||||
if (!N_FUN_indexes.empty()) {
|
||||
// Copy the size of the function into the original STAB entry
|
||||
// so we don't have to hunt for it later
|
||||
symtab.SymbolAtIndex(N_FUN_indexes.back())
|
||||
symtab->SymbolAtIndex(N_FUN_indexes.back())
|
||||
->SetByteSize(nlist.n_value);
|
||||
N_FUN_indexes.pop_back();
|
||||
// We don't really need the end function STAB as it contains
|
||||
@@ -3998,7 +4015,7 @@ void ObjectFileMachO::ParseSymtab(Symtab &symtab) {
|
||||
// N_SO so that we can always skip the entire N_SO if we need
|
||||
// to navigate more quickly at the source level when parsing
|
||||
// STABS
|
||||
symbol_ptr = symtab.SymbolAtIndex(N_SO_index);
|
||||
symbol_ptr = symtab->SymbolAtIndex(N_SO_index);
|
||||
symbol_ptr->SetByteSize(sym_idx);
|
||||
symbol_ptr->SetSizeIsSibling(true);
|
||||
}
|
||||
@@ -4092,7 +4109,7 @@ void ObjectFileMachO::ParseSymtab(Symtab &symtab) {
|
||||
// N_EINCL so that we can always skip the entire symbol if we need
|
||||
// to navigate more quickly at the source level when parsing STABS
|
||||
if (!N_INCL_indexes.empty()) {
|
||||
symbol_ptr = symtab.SymbolAtIndex(N_INCL_indexes.back());
|
||||
symbol_ptr = symtab->SymbolAtIndex(N_INCL_indexes.back());
|
||||
symbol_ptr->SetByteSize(sym_idx + 1);
|
||||
symbol_ptr->SetSizeIsSibling(true);
|
||||
N_INCL_indexes.pop_back();
|
||||
@@ -4151,7 +4168,7 @@ void ObjectFileMachO::ParseSymtab(Symtab &symtab) {
|
||||
// quickly at the source level when parsing STABS
|
||||
symbol_section = section_info.GetSection(nlist.n_sect, nlist.n_value);
|
||||
if (!N_BRAC_indexes.empty()) {
|
||||
symbol_ptr = symtab.SymbolAtIndex(N_BRAC_indexes.back());
|
||||
symbol_ptr = symtab->SymbolAtIndex(N_BRAC_indexes.back());
|
||||
symbol_ptr->SetByteSize(sym_idx + 1);
|
||||
symbol_ptr->SetSizeIsSibling(true);
|
||||
N_BRAC_indexes.pop_back();
|
||||
@@ -4185,7 +4202,7 @@ void ObjectFileMachO::ParseSymtab(Symtab &symtab) {
|
||||
// we need to navigate more quickly at the source level when
|
||||
// parsing STABS
|
||||
if (!N_COMM_indexes.empty()) {
|
||||
symbol_ptr = symtab.SymbolAtIndex(N_COMM_indexes.back());
|
||||
symbol_ptr = symtab->SymbolAtIndex(N_COMM_indexes.back());
|
||||
symbol_ptr->SetByteSize(sym_idx + 1);
|
||||
symbol_ptr->SetSizeIsSibling(true);
|
||||
N_COMM_indexes.pop_back();
|
||||
@@ -4641,7 +4658,7 @@ void ObjectFileMachO::ParseSymtab(Symtab &symtab) {
|
||||
|
||||
if (num_syms < sym_idx + trie_symbol_table_augment_count) {
|
||||
num_syms = sym_idx + trie_symbol_table_augment_count;
|
||||
sym = symtab.Resize(num_syms);
|
||||
sym = symtab->Resize(num_syms);
|
||||
}
|
||||
uint32_t synthetic_sym_id = symtab_load_command.nsyms;
|
||||
|
||||
@@ -4690,7 +4707,7 @@ void ObjectFileMachO::ParseSymtab(Symtab &symtab) {
|
||||
if (num_synthetic_function_symbols > 0) {
|
||||
if (num_syms < sym_idx + num_synthetic_function_symbols) {
|
||||
num_syms = sym_idx + num_synthetic_function_symbols;
|
||||
sym = symtab.Resize(num_syms);
|
||||
sym = symtab->Resize(num_syms);
|
||||
}
|
||||
for (i = 0; i < function_starts_count; ++i) {
|
||||
const FunctionStarts::Entry *func_start_entry =
|
||||
@@ -4745,7 +4762,7 @@ void ObjectFileMachO::ParseSymtab(Symtab &symtab) {
|
||||
// symbols.
|
||||
if (sym_idx < num_syms) {
|
||||
num_syms = sym_idx;
|
||||
sym = symtab.Resize(num_syms);
|
||||
sym = symtab->Resize(num_syms);
|
||||
}
|
||||
|
||||
// Now synthesize indirect symbols
|
||||
@@ -4790,11 +4807,11 @@ void ObjectFileMachO::ParseSymtab(Symtab &symtab) {
|
||||
if (index_pos != end_index_pos) {
|
||||
// We have a remapping from the original nlist index to a
|
||||
// current symbol index, so just look this up by index
|
||||
stub_symbol = symtab.SymbolAtIndex(index_pos->second);
|
||||
stub_symbol = symtab->SymbolAtIndex(index_pos->second);
|
||||
} else {
|
||||
// We need to lookup a symbol using the original nlist symbol
|
||||
// index since this index is coming from the S_SYMBOL_STUBS
|
||||
stub_symbol = symtab.FindSymbolByID(stub_sym_id);
|
||||
stub_symbol = symtab->FindSymbolByID(stub_sym_id);
|
||||
}
|
||||
|
||||
if (stub_symbol) {
|
||||
@@ -4817,7 +4834,7 @@ void ObjectFileMachO::ParseSymtab(Symtab &symtab) {
|
||||
// Make a synthetic symbol to describe the trampoline stub
|
||||
Mangled stub_symbol_mangled_name(stub_symbol->GetMangled());
|
||||
if (sym_idx >= num_syms) {
|
||||
sym = symtab.Resize(++num_syms);
|
||||
sym = symtab->Resize(++num_syms);
|
||||
stub_symbol = nullptr; // this pointer no longer valid
|
||||
}
|
||||
sym[sym_idx].SetID(synthetic_sym_id++);
|
||||
@@ -4856,7 +4873,7 @@ void ObjectFileMachO::ParseSymtab(Symtab &symtab) {
|
||||
indirect_symbol_names.end()) {
|
||||
// Make a synthetic symbol to describe re-exported symbol.
|
||||
if (sym_idx >= num_syms)
|
||||
sym = symtab.Resize(++num_syms);
|
||||
sym = symtab->Resize(++num_syms);
|
||||
sym[sym_idx].SetID(synthetic_sym_id++);
|
||||
sym[sym_idx].GetMangled() = Mangled(e.entry.name);
|
||||
sym[sym_idx].SetType(eSymbolTypeReExported);
|
||||
@@ -4871,6 +4888,18 @@ void ObjectFileMachO::ParseSymtab(Symtab &symtab) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// StreamFile s(stdout, false);
|
||||
// s.Printf ("Symbol table before CalculateSymbolSizes():\n");
|
||||
// symtab->Dump(&s, NULL, eSortOrderNone);
|
||||
// Set symbol byte sizes correctly since mach-o nlist entries don't have
|
||||
// sizes
|
||||
symtab->CalculateSymbolSizes();
|
||||
|
||||
// s.Printf ("Symbol table after CalculateSymbolSizes():\n");
|
||||
// symtab->Dump(&s, NULL, eSortOrderNone);
|
||||
|
||||
return symtab->GetNumSymbols();
|
||||
}
|
||||
|
||||
void ObjectFileMachO::Dump(Stream *s) {
|
||||
|
||||
Reference in New Issue
Block a user