[Lldb-commits] [PATCH] Strip ELF symbol versions from symbol names
Pavel Labath
labath at google.com
Wed Feb 25 10:02:52 PST 2015
Hi clayborg, emaste, zturner,
The following issue occurs when loading glibc with debug symbols:
- since the file now has both .symtab and .dynsym sections, LLDB decides to load symbols from
.symtab, assuming that this is a superset of .dynsym.
- this is not entirely true when ELF symbol versions come into play
- For example, .symtab on glibc contains symbols 'memcpy@@GLIBC_2.14' and 'memcpy at GLIBC_2.2.5',
but it does not contain the symbol 'memcpy'
- when we attempt to evaluate an expression referencing 'memcpy' we fail, as we cannot resolve
the symbol.
This patch resolves this problem with stripping the version suffix from the default symbols
(containing '@@').
http://reviews.llvm.org/D7884
Files:
source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
Index: source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
===================================================================
--- source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
+++ source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
@@ -1897,6 +1897,16 @@
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;
+ // ELF symbol names can contain version specifications, in the form 'name at VERSION'.
+ // Default symbols have a '@@VERSION' suffix. Here we strip the default version
+ // specifications, so the symbols can be found with a 'name' lookup on the symbol table.
+ std::string symbol_name_str;
+ if (const char *version = strstr(symbol_name, "@@"))
+ {
+ symbol_name_str.assign (symbol_name, version-symbol_name);
+ symbol_name = symbol_name_str.c_str();
+ }
+
Symbol dc_symbol(
i + start_id, // ID is the original symbol table index.
symbol_name, // Symbol name.
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D7884.20687.patch
Type: text/x-patch
Size: 1114 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20150225/e52cb894/attachment.bin>
More information about the lldb-commits
mailing list