summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTamas Berghammer <tberghammer@google.com>2015-07-30 12:38:18 +0000
committerTamas Berghammer <tberghammer@google.com>2015-07-30 12:38:18 +0000
commitd00438e8f0d6c98e56b01c26147cb3d79df46ccb (patch)
tree831fc9a74c6261a4d7f8fb6626d6ec8316a3ba45
parent77fb0a3dcf19df35533840e096a26fb7e5e18f9b (diff)
downloadbcm5719-llvm-d00438e8f0d6c98e56b01c26147cb3d79df46ccb.tar.gz
bcm5719-llvm-d00438e8f0d6c98e56b01c26147cb3d79df46ccb.zip
Fix issues with separate symbolfile handling
Differential revision: http://reviews.llvm.org/D11595 llvm-svn: 243637
-rw-r--r--lldb/source/Core/Module.cpp3
-rw-r--r--lldb/source/Host/common/Symbols.cpp10
-rw-r--r--lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp41
-rw-r--r--lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp1
4 files changed, 40 insertions, 15 deletions
diff --git a/lldb/source/Core/Module.cpp b/lldb/source/Core/Module.cpp
index 0000e61b836..cc8a59003b1 100644
--- a/lldb/source/Core/Module.cpp
+++ b/lldb/source/Core/Module.cpp
@@ -1500,6 +1500,9 @@ Module::SetSymbolFileFileSpec (const FileSpec &file)
// we don't have to do anything.
return;
}
+
+ // Cleare the current symtab as we are going to replace it with a new one
+ obj_file->ClearSymtab();
// The symbol file might be a directory bundle ("/tmp/a.out.dSYM") instead
// of a full path to the symbol file within the bundle
diff --git a/lldb/source/Host/common/Symbols.cpp b/lldb/source/Host/common/Symbols.cpp
index f24423da6f9..76e28449f96 100644
--- a/lldb/source/Host/common/Symbols.cpp
+++ b/lldb/source/Host/common/Symbols.cpp
@@ -175,7 +175,7 @@ LocateExecutableSymbolFileDsym (const ModuleSpec &module_spec)
"LocateExecutableSymbolFileDsym (file = %s, arch = %s, uuid = %p)",
exec_fspec ? exec_fspec->GetFilename().AsCString ("<NULL>") : "<NULL>",
arch ? arch->GetArchitectureName() : "<NULL>",
- (void*)uuid);
+ (const void*)uuid);
FileSpec symbol_fspec;
// First try and find the dSYM in the same directory as the executable or in
@@ -198,7 +198,7 @@ Symbols::LocateExecutableObjectFile (const ModuleSpec &module_spec)
"LocateExecutableObjectFile (file = %s, arch = %s, uuid = %p)",
exec_fspec ? exec_fspec->GetFilename().AsCString ("<NULL>") : "<NULL>",
arch ? arch->GetArchitectureName() : "<NULL>",
- (void*)uuid);
+ (const void*)uuid);
FileSpec objfile_fspec;
ModuleSpecList module_specs;
@@ -219,7 +219,11 @@ Symbols::LocateExecutableObjectFile (const ModuleSpec &module_spec)
FileSpec
Symbols::LocateExecutableSymbolFile (const ModuleSpec &module_spec)
{
- const char *symbol_filename = module_spec.GetSymbolFileSpec().GetFilename().AsCString();
+ FileSpec symbol_file_spec = module_spec.GetSymbolFileSpec();
+ if (symbol_file_spec.IsAbsolute() && symbol_file_spec.Exists())
+ return symbol_file_spec;
+
+ const char *symbol_filename = symbol_file_spec.GetFilename().AsCString();
if (symbol_filename && symbol_filename[0])
{
FileSpecList debug_file_search_paths (Target::GetDefaultDebugFileSearchPaths());
diff --git a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
index a3a1113ffc8..6cfc23a30b9 100644
--- a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
+++ b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
@@ -905,8 +905,17 @@ ObjectFileELF::GetAddressByteSize() const
AddressClass
ObjectFileELF::GetAddressClass (addr_t file_addr)
{
- auto res = ObjectFile::GetAddressClass (file_addr);
+ Symtab* symtab = GetSymtab();
+ if (!symtab)
+ return eAddressClassUnknown;
+
+ // The address class is determined based on the symtab. Ask it from the object file what
+ // contains the symtab information.
+ ObjectFile* symtab_objfile = symtab->GetObjectFile();
+ if (symtab_objfile != nullptr && symtab_objfile != this)
+ return symtab_objfile->GetAddressClass(file_addr);
+ auto res = ObjectFile::GetAddressClass (file_addr);
if (res != eAddressClassCode)
return res;
@@ -1976,7 +1985,6 @@ ObjectFileELF::ParseSymbols (Symtab *symtab,
m_address_class_map[symbol.st_value] = eAddressClassData;
}
}
-
continue;
}
}
@@ -2031,9 +2039,13 @@ ObjectFileELF::ParseSymbols (Symtab *symtab,
}
}
- // If the symbol section we've found has no data (SHT_NOBITS), then check the module section
- // list. This can happen if we're parsing the debug file and it has no .text section, for example.
- if (symbol_section_sp && (symbol_section_sp->GetFileSize() == 0))
+ // symbol_value_offset may contain 0 for ARM symbols or -1 for
+ // THUMB symbols. See above for more details.
+ uint64_t symbol_value = symbol.st_value + symbol_value_offset;
+ if (symbol_section_sp && CalculateType() != ObjectFile::Type::eTypeObjectFile)
+ symbol_value -= symbol_section_sp->GetFileAddress();
+
+ if (symbol_section_sp)
{
ModuleSP module_sp(GetModule());
if (module_sp)
@@ -2051,11 +2063,6 @@ ObjectFileELF::ParseSymbols (Symtab *symtab,
}
}
- // symbol_value_offset may contain 0 for ARM symbols or -1 for
- // THUMB symbols. See above for more details.
- uint64_t symbol_value = symbol.st_value + symbol_value_offset;
- if (symbol_section_sp && CalculateType() != ObjectFile::Type::eTypeObjectFile)
- symbol_value -= symbol_section_sp->GetFileAddress();
bool is_global = symbol.getBinding() == STB_GLOBAL;
uint32_t flags = symbol.st_other << 8 | symbol.st_info | additional_flags;
bool is_mangled = symbol_name ? (symbol_name[0] == '_' && symbol_name[1] == 'Z') : false;
@@ -2563,8 +2570,6 @@ ObjectFileELF::GetSymtab()
uint64_t symbol_id = 0;
lldb_private::Mutex::Locker locker(module_sp->GetMutex());
- m_symtab_ap.reset(new Symtab(this));
-
// Sharable objects and dynamic executables usually have 2 distinct symbol
// tables, one named ".symtab", and the other ".dynsym". The dynsym is a smaller
// version of the symtab that only contains global symbols. The information found
@@ -2578,7 +2583,10 @@ ObjectFileELF::GetSymtab()
symtab = section_list->FindSectionByType (eSectionTypeELFDynamicSymbols, true).get();
}
if (symtab)
+ {
+ m_symtab_ap.reset(new Symtab(symtab->GetObjectFile()));
symbol_id += ParseSymbolTable (m_symtab_ap.get(), symbol_id, symtab);
+ }
// DT_JMPREL
// If present, this entry's d_ptr member holds the address of relocation
@@ -2598,10 +2606,19 @@ ObjectFileELF::GetSymtab()
user_id_t reloc_id = reloc_section->GetID();
const ELFSectionHeaderInfo *reloc_header = GetSectionHeaderByIndex(reloc_id);
assert(reloc_header);
+
+ if (m_symtab_ap == nullptr)
+ m_symtab_ap.reset(new Symtab(reloc_section->GetObjectFile()));
ParseTrampolineSymbols (m_symtab_ap.get(), symbol_id, reloc_header, reloc_id);
}
}
+
+ // If we still don't have any symtab then create an empty instance to avoid do the section
+ // lookup next time.
+ if (m_symtab_ap == nullptr)
+ m_symtab_ap.reset(new Symtab(this));
+
m_symtab_ap->CalculateSymbolSizes();
}
diff --git a/lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp b/lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp
index d535078c189..c861d62b03f 100644
--- a/lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp
+++ b/lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp
@@ -115,6 +115,7 @@ SymbolFileSymtab::CalculateAbilities ()
if (symtab->AppendSymbolIndexesWithType(eSymbolTypeCode, Symtab::eDebugNo, Symtab::eVisibilityAny, m_code_indexes))
{
symtab->SortSymbolIndexesByValue(m_code_indexes, true);
+ abilities |= Functions;
}
if (symtab->AppendSymbolIndexesWithType(eSymbolTypeData, m_data_indexes))
OpenPOWER on IntegriCloud