[PATCH] llvm-symbolizer: teach it about PowerPC64 ELF function descriptors

Alexey Samsonov vonosmas at gmail.com
Wed Nov 5 18:29:50 PST 2014


Thank you for working on this! Please make sure to add a test case in LLVM testsuite as well (it should go to somewhere like test/tools/llvm-symbolizer). Probably the test case would be a tiny powerpc64 binary with no debug info, so that we can ensure we fetch the function name from symbol table correctly.

================
Comment at: tools/llvm-symbolizer/LLVMSymbolize.cpp:49
@@ +48,3 @@
+  // Find the .opd (function descriptor) section if any, for PowerPC64 ELF.
+  for (section_iterator Section : Module->sections()) {
+    StringRef Name;
----------------
Consider the following approach: if Module->getArch() is Triple::ppc64 (should we also treat Triple::ppc64le?), and you have an .opd section, create a DataExtractor. Then you can pass this DataExtractor down to addSymbol() as an optional argument, and fetch the actual addresses of functions there. It looks weird to create DataExtractor for each and every of thousands of symbols.

================
Comment at: tools/llvm-symbolizer/LLVMSymbolize.cpp:95
@@ +94,3 @@
+      uint32_t Offset = SymbolAddress - SymbolSection->getAddress();
+      SymbolAddress = DE.getUnsigned(&Offset, Module->getBytesInAddress());
+      if (SymbolAddress == 0)
----------------
You can use DataExtractor::getAddress() instead. Consider using isValidOffsetForDataOfSize to verify that the offset into .opd is valid.

================
Comment at: tools/llvm-symbolizer/LLVMSymbolize.h:134
@@ -133,1 +133,3 @@
+  // The .opd (function descriptor) section if any, for PowerPC64 ELF.
+  section_iterator OpdSection;
 };
----------------
This member doesn't look to be required - Functions and Objects maps are built in the constructor, and you only need this section in "addSymbol" implementation.

http://reviews.llvm.org/D6110






More information about the llvm-commits mailing list