[Lldb-commits] [lldb] Add support for reading the dynamic symbol table from PT_DYNAMIC (PR #112596)

Jacob Lalonde via lldb-commits lldb-commits at lists.llvm.org
Wed Oct 16 15:02:36 PDT 2024


================
@@ -2990,18 +2992,34 @@ void ObjectFileELF::ParseSymtab(Symtab &lldb_symtab) {
   // section, nomatter if .symtab was already parsed or not. This is because
   // minidebuginfo normally removes the .symtab symbols which have their
   // matching .dynsym counterparts.
+  bool found_dynsym = false;
   if (!symtab ||
       GetSectionList()->FindSectionByName(ConstString(".gnu_debugdata"))) {
     Section *dynsym =
         section_list->FindSectionByType(eSectionTypeELFDynamicSymbols, true)
             .get();
     if (dynsym) {
+      found_dynsym = true;
       auto [num_symbols, address_class_map] =
           ParseSymbolTable(&lldb_symtab, symbol_id, dynsym);
       symbol_id += num_symbols;
       m_address_class_map.merge(address_class_map);
     }
   }
+  if (!found_dynsym) {
----------------
Jlalond wrote:

We added this bool, but why can't this be the else to `if (dynsym)`? We have two very similar sounding variables here. I think we can simplify this to 

`Section *dynsym = !symtab || GetSection()->... ? section_list->FindSection(..) : nullptr;`
and then we have a simple if else

https://github.com/llvm/llvm-project/pull/112596


More information about the lldb-commits mailing list