[LLDB][ELF] Load both, .symtab and .dynsym sections
Summary: This change ensures that the .dynsym section will be parsed even when there's already is a .symtab. It is motivated because of minidebuginfo (https://sourceware.org/gdb/current/onlinedocs/gdb/MiniDebugInfo.html#MiniDebugInfo). There it says: Keep all the function symbols not already in the dynamic symbol table. That means the .symtab embedded inside the .gnu_debugdata does NOT contain the symbols from .dynsym. But in order to put a breakpoint on all symbols we need to load both. I hope this makes sense. My other patch D66791 implements support for minidebuginfo, that's why I need this change. Reviewers: labath, espindola, alexshap Subscribers: JDevlieghere, emaste, arichardson, MaskRay, lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D67390 llvm-svn: 371599
This commit is contained in:
@@ -2647,21 +2647,31 @@ Symtab *ObjectFileELF::GetSymtab() {
|
||||
// smaller version of the symtab that only contains global symbols. The
|
||||
// information found in the dynsym is therefore also found in the symtab,
|
||||
// while the reverse is not necessarily true.
|
||||
// One exception to the above rule is when we have minidebuginfo embedded
|
||||
// into a compressed .gnu_debugdata section. This section contains a .symtab
|
||||
// from which all symbols already contained in the .dynsym are stripped.
|
||||
Section *symtab =
|
||||
section_list->FindSectionByType(eSectionTypeELFSymbolTable, true).get();
|
||||
if (!symtab) {
|
||||
// The symtab section is non-allocable and can be stripped, so if it
|
||||
// doesn't exist then use the dynsym section which should always be
|
||||
// there.
|
||||
symtab =
|
||||
section_list->FindSectionByType(eSectionTypeELFDynamicSymbols, true)
|
||||
.get();
|
||||
}
|
||||
if (symtab) {
|
||||
m_symtab_up.reset(new Symtab(symtab->GetObjectFile()));
|
||||
symbol_id += ParseSymbolTable(m_symtab_up.get(), symbol_id, symtab);
|
||||
}
|
||||
|
||||
// The symtab section is non-allocable and can be stripped, while the dynsym
|
||||
// section which should always be always be there. If both exist we load
|
||||
// both to support the minidebuginfo case. Otherwise we just load the dynsym
|
||||
// section.
|
||||
Section *dynsym =
|
||||
section_list->FindSectionByType(eSectionTypeELFDynamicSymbols, true)
|
||||
.get();
|
||||
if (dynsym) {
|
||||
if (!m_symtab_up) {
|
||||
auto sec = symtab ? symtab : dynsym;
|
||||
m_symtab_up.reset(new Symtab(sec->GetObjectFile()));
|
||||
}
|
||||
symbol_id += ParseSymbolTable(m_symtab_up.get(), symbol_id, dynsym);
|
||||
}
|
||||
|
||||
// DT_JMPREL
|
||||
// If present, this entry's d_ptr member holds the address of
|
||||
// relocation
|
||||
|
||||
Reference in New Issue
Block a user