From a93b45f00fbef37751ca3746bcf54c58b9fcaf23 Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Sun, 17 Jul 2005 23:44:43 +0000 Subject: [PATCH] Understood why static symbols are not found (we can't without reading the concerned shared object's file, which probably is a bit overkill) and added respective comments. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13725 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/debug/SymbolLookup.cpp | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/kits/debug/SymbolLookup.cpp b/src/kits/debug/SymbolLookup.cpp index 4621292a6a..6db1a2c380 100644 --- a/src/kits/debug/SymbolLookup.cpp +++ b/src/kits/debug/SymbolLookup.cpp @@ -179,6 +179,13 @@ status_t SymbolLookup::LookupSymbolAddress(addr_t address, addr_t *_baseAddress, const char **_symbolName, const char **_imageName, bool *_exactMatch) { + // Note, that this function doesn't find all symbols that we would like + // to find. E.g. static functions do not appear in the symbol table + // as function symbols, but each one seems to be a separate section. + // Therefore, to get completely satisfying results, we would need to scan + // the shared object's section headers, if we don't find the a matching + // symbol. + TRACE(("SymbolLookup::LookupSymbolAddress(%p)\n", (void*)address)); // get the image for the address @@ -205,10 +212,19 @@ SymbolLookup::LookupSymbolAddress(addr_t address, addr_t *_baseAddress, for (int32 j = Read(hashBuckets[i]); j != STN_UNDEF; j = Read(hashChains[j])) { + const struct Elf32_Sym *symbol = &Read(image->syms[j]); - // skip invalid symbols - if (symbol->st_value == 0 + // The symbol table contains not only symbols referring to functions + // and data symbols within the shared object, but also referenced + // symbols of other shared objects, as well as section and file + // references. We ignore everything but function and data symbols + // that have an st_value != 0 (0 seems to be an indication for a + // symbol defined elsewhere -- couldn't verify that in the specs + // though). + if ((ELF32_ST_TYPE(symbol->st_info) != STT_FUNC + && ELF32_ST_TYPE(symbol->st_info) != STT_OBJECT) + || symbol->st_value == 0 || symbol->st_value + symbol->st_size + textRegion->delta > textRegion->vmstart + textRegion->size) { continue;