tberghammer retitled this revision from "Unconditionally accept symbol sizes 
from .dynsym" to "Unconditionally accept symbol sizes from elf".
tberghammer updated the summary for this revision.
tberghammer updated this revision to Diff 44981.
tberghammer added a comment.

I disabled the symbol size calculation for ELF and it worked for all 
configuration I tested (Linux x86_64/i386, clang-3.5/gcc-4.8.4) so I think we 
should go ahead with this solution. We can look for something different if we 
hit any issue.


http://reviews.llvm.org/D16186

Files:
  include/lldb/Symbol/Symbol.h
  source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
  source/Symbol/Symbol.cpp
  source/Symbol/Symtab.cpp

Index: source/Symbol/Symtab.cpp
===================================================================
--- source/Symbol/Symtab.cpp
+++ 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;
 }
 
Index: source/Symbol/Symbol.cpp
===================================================================
--- source/Symbol/Symbol.cpp
+++ source/Symbol/Symbol.cpp
@@ -737,3 +737,10 @@
     }
     return false;
 }
+
+bool
+Symbol::ContainsFileAddress (lldb::addr_t file_addr) const
+{
+    return m_addr_range.ContainsFileAddress(file_addr);
+}
+
Index: source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
===================================================================
--- source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
+++ source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
@@ -2295,16 +2295,18 @@
                 symbol_section_sp,  // Section in which this symbol is defined or null.
                 symbol_value,       // Offset in section or symbol value.
                 symbol.st_size),    // Size in bytes of this symbol.
-            symbol.st_size != 0,    // Size is valid if it is not 0
+            true,                   // Symbol size is valid
             has_suffix,             // Contains linker annotations?
             flags);                 // Symbol flags.
         symtab->AddSymbol(dc_symbol);
     }
     return i;
 }
 
 unsigned
-ObjectFileELF::ParseSymbolTable(Symtab *symbol_table, user_id_t start_id, lldb_private::Section *symtab)
+ObjectFileELF::ParseSymbolTable(Symtab *symbol_table,
+                                user_id_t start_id,
+                                lldb_private::Section *symtab)
 {
     if (symtab->GetObjectFile() != this)
     {
Index: include/lldb/Symbol/Symbol.h
===================================================================
--- include/lldb/Symbol/Symbol.h
+++ include/lldb/Symbol/Symbol.h
@@ -383,6 +383,9 @@
                     bool prefer_file_cache,
                     Stream &strm);
 
+    bool
+    ContainsFileAddress (lldb::addr_t file_addr) const;
+
 protected:
     // This is the internal guts of ResolveReExportedSymbol, it assumes reexport_name is not null, and that module_spec
     // is valid.  We track the modules we've already seen to make sure we don't get caught in a cycle.
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to