tberghammer created this revision.
tberghammer added a reviewer: clayborg.
tberghammer added a subscriber: lldb-commits.
Herald added a subscriber: aemerson.

Add empty symbols to symtab for skipped symbols

LLDB skips several special purpose symbols during symtab parsing (e.g.:
arm/aarch64 mapping symbols) because we don't use them in later stages.
This CL changes the behavior to add an empty symbol to the symtab for
each skipped symbol to preserve the symbol indexes between the symtab in
the object file and LLDBs representation (it is needed because the
relocations are referencing the symbols by index).

http://reviews.llvm.org/D14536

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
@@ -2019,12 +2019,18 @@
         // No need to add non-section symbols that have no names
         if (symbol.getType() != STT_SECTION &&
             (symbol_name == NULL || symbol_name[0] == '\0'))
+        {
+            symtab->AddSymbol(Symbol());
             continue;
+        }
 
         // Skipping oatdata and oatexec sections if it is requested. See 
details above the
         // definition of skip_oatdata_oatexec for the reasons.
         if (skip_oatdata_oatexec && (::strcmp(symbol_name, "oatdata") == 0 || 
::strcmp(symbol_name, "oatexec") == 0))
+        {
+            symtab->AddSymbol(Symbol());
             continue;
+        }
 
         SectionSP symbol_section_sp;
         SymbolType symbol_type = eSymbolTypeInvalid;
@@ -2141,7 +2147,10 @@
                         }
                     }
                     if (mapping_symbol)
+                    {
+                        symtab->AddSymbol(Symbol());
                         continue;
+                    }
                 }
             }
             else if (arch.GetMachine() == llvm::Triple::aarch64)
@@ -2164,7 +2173,10 @@
                         }
                     }
                     if (mapping_symbol)
+                    {
+                        symtab->AddSymbol(Symbol());
                         continue;
+                    }
                 }
             }
 


Index: source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
===================================================================
--- source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
+++ source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
@@ -2019,12 +2019,18 @@
         // No need to add non-section symbols that have no names
         if (symbol.getType() != STT_SECTION &&
             (symbol_name == NULL || symbol_name[0] == '\0'))
+        {
+            symtab->AddSymbol(Symbol());
             continue;
+        }
 
         // Skipping oatdata and oatexec sections if it is requested. See details above the
         // definition of skip_oatdata_oatexec for the reasons.
         if (skip_oatdata_oatexec && (::strcmp(symbol_name, "oatdata") == 0 || ::strcmp(symbol_name, "oatexec") == 0))
+        {
+            symtab->AddSymbol(Symbol());
             continue;
+        }
 
         SectionSP symbol_section_sp;
         SymbolType symbol_type = eSymbolTypeInvalid;
@@ -2141,7 +2147,10 @@
                         }
                     }
                     if (mapping_symbol)
+                    {
+                        symtab->AddSymbol(Symbol());
                         continue;
+                    }
                 }
             }
             else if (arch.GetMachine() == llvm::Triple::aarch64)
@@ -2164,7 +2173,10 @@
                         }
                     }
                     if (mapping_symbol)
+                    {
+                        symtab->AddSymbol(Symbol());
                         continue;
+                    }
                 }
             }
 
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to