Unconditionally accept symbol sizes from elf
The ELF symbol table always contain the size of the symbols so we
don't have to try to guess them based on the address of the next
symbol (it is needed for mach-o).
The change fixes an issue when a symbol is removed after a 0 size
symbol (e.g. because the second one is not public) what previously
caused the symbol lookup algorithm to end up with showing the 0 size
symbol even for the later addresses (what are not part of any symbol).
That symbol lookup error can confuse the user and also confuses the
current stack unwinder.
Differential revision: http://reviews.llvm.org/D16186
llvm-svn: 258040
diff --git a/lldb/source/Symbol/Symtab.cpp b/lldb/source/Symbol/Symtab.cpp
index b20504a..31db572 100644
--- a/lldb/source/Symbol/Symtab.cpp
+++ b/lldb/source/Symbol/Symtab.cpp
@@ -971,9 +971,11 @@
if (end_section_file_addr > symbol_file_addr)
{
Symbol &symbol = m_symbols[entry.data];
-
- symbol.SetByteSize(end_section_file_addr - symbol_file_addr);
- symbol.SetSizeIsSynthesized(true);
+ if (!symbol.GetByteSizeIsValid())
+ {
+ symbol.SetByteSize(end_section_file_addr - symbol_file_addr);
+ symbol.SetSizeIsSynthesized(true);
+ }
}
}
}
@@ -1039,18 +1041,15 @@
return info.match_symbol;
}
- const size_t symbol_byte_size = info.match_symbol->GetByteSize();
-
- if (symbol_byte_size == 0)
+ if (!info.match_symbol->GetByteSizeIsValid())
{
- // We weren't able to find the size of the symbol so lets just go
- // with that match we found in our search...
+ // The matched symbol dosn't have a valid byte size so lets just go with that match...
return info.match_symbol;
}
// We were able to figure out a symbol size so lets make sure our
// offset puts "file_addr" in the symbol's address range.
- if (info.match_offset < symbol_byte_size)
+ if (info.match_offset < info.match_symbol->GetByteSize())
return info.match_symbol;
}
return nullptr;
@@ -1066,7 +1065,11 @@
const FileRangeToIndexMap::Entry *entry = m_file_addr_to_index.FindEntryThatContains(file_addr);
if (entry)
- return SymbolAtIndex(entry->data);
+ {
+ Symbol* symbol = SymbolAtIndex(entry->data);
+ if (symbol->ContainsFileAddress(file_addr))
+ return symbol;
+ }
return nullptr;
}