Note: This revision is very similar to D62296.
In D75756, we need getDynamicSymbolIterators() to skip first NULL symbol in .dynsym. And I believe it might be worth pointing this out in a separate patch to gather you experts' opinions.
I have checked that current code base will not be affected by this change.
dynamic_symbol_begin() |- dynamic_symbol_end(): Ok `- getDynamicSymbolIterators() |- addDynamicElfSymbols(): llvm/tools/llvm-objdump/llvm-objdump.cpp, Line 934 | Ok, NULL symbol will be omitted by Line 945-947 | StringRef Name = unwrapOrError(Symbol.getName(), Obj->getName()); | if (Name.empty()) continue; |- dumpSymbolNameFromObject(): llvm/tools/llvm-nm/llvm-nm.cpp, Line 1192 | There's no test for dumping dynamic debugging symbol. This patch helps improve llvm-nm behavior. (we should add test for this later) `- computeSymbolSizes(): llvm/lib/Object/SymbolSize.cpp, Line 52 |- OProfileJITEventListener::notifyObjectLoaded(): llvm/lib/ExecutionEngine/OProfileJIT/OProfileJITEventListener.cpp, Line 92 | Ok, NULL symbol will be omitted by Line 94-95 | if (!Sym.getType() || *Sym.getType() != SF_Function) continue; |- IntelJITEventListener::notifyObjectLoaded(): llvm/lib/ExecutionEngine/IntelJITEvents/IntelJITEventListener.cpp, Line 98 | Ok, NULL symbol will be omitted by Line 124-126 (same as previous one) |- PerfJITEventListener::notifyObjectLoaded(): llvm/lib/ExecutionEngine/PerfJITEvents/PerfJITEventListener.cpp, Line 244 | Ok, NULL symbol will be omitted by Line 254-256, (same as previous one) |- SymbolizableObjectFile::create(): llvm/lib/DebugInfo/Symbolize/SymbolizableObjectFile.cpp, Line 73 | Ok, NULL symbol will be omitted by Line 75 | res->addSymbol() | In addSymbol(), Line 167-168 | if (!Sec || (Obj && Obj->section_end() == *Sec)) return std::error_code(); |- dumpCXXData(): llvm/tools/llvm-cxxdump/llvm-cxxdump.cpp, Line 189 | Ok, NULL symbol will be omitted by Line 199-202 | object::section_iterator SecI = *SecIOrErr; | // Skip external symbols. | if (SecI == Obj->section_end()) | continue; `- printLineInfoForInput(): llvm/tools/llvm-rtdyld/llvm-rtdyld.cpp, Line 418 Ok, NULL symbol will be omitted by Line 430-477 if (Type == object::SymbolRef::ST_Function) { ... }
Ok. So seems we are going to make this function to ignore the zero symbol.
Code on the left did not work with sh_size, you are adding the logic that uses it,
but what if sh_size is broken? Here, sh_size % sizeof(Elf_Sym) != 0
means we have a corrupted section isn't?
I'd suggest to isolate error handling. For now we can probably do something like:
Do we have a test where this method is used when sh_size % sizeof(Elf_Sym) != 0?