[PATCH] D11839: Adding SymbolRef::getSectionName for getting a textual section name for the symbol. Updating llvm-objdump to use this

Rafael Ávila de Espíndola via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 7 11:55:25 PDT 2015


rafael added a comment.

Is there some intended use other than the human friendly dump that llvm-objdump does?

An absolute symbol is not in a section named *ABS*. That is just what llvm-objdump prints in place of the section name for absolute symbols.

For the hexagon case. What does gnu objdump do?


================
Comment at: include/llvm/Object/ELFObjectFile.h:58
@@ -57,2 +57,3 @@
   virtual ErrorOr<int64_t> getRelocationAddend(DataRefImpl Rel) const = 0;
+  std::string NameFromPRCNumber(uint32_t Index) const;
 public:
----------------
Functions should be a verb and start with a lowercase letter. How about getNameFromPRCNumber?

What is PRC?

================
Comment at: include/llvm/Object/ELFObjectFile.h:533
@@ +532,3 @@
+ELFObjectFile<ELFT>::getSymbolSectionName(DataRefImpl Symb) const {
+  auto Symbol = getSymbol(Symb);
+  uint32_t Index = Symbol->st_shndx;
----------------
I don't think we use auto in cases like this.

================
Comment at: lib/Object/MachOObjectFile.cpp:473
@@ +472,3 @@
+ErrorOr<std::string> MachOObjectFile::getSymbolSectionName(DataRefImpl Symb) const {
+  auto Result = ObjectFile::getSymbolSectionName(Symb);
+  if(!Result)
----------------
Don't use auto in here.

================
Comment at: lib/Object/MachOObjectFile.cpp:483
@@ -470,1 +482,3 @@
+  StringRef SegmentName = getSectionFinalSegmentName(DR);
+  return SegmentName.str() + "," + *Result;
 }
----------------
This looks a bit odd. The segment is not part of the section name.

It is double odd because this would be the only function adding the segment name.

================
Comment at: lib/Object/ObjectFile.cpp:64
@@ +63,3 @@
+  bool Common = Flags & SymbolRef::SF_Common;
+  if(Error)
+    return Error;
----------------
Move this earlier, just after the call that produces the error.

You can also fuse it with the if

if (std::error_code EC = ...)
  return EC;



Repository:
  rL LLVM

http://reviews.llvm.org/D11839





More information about the llvm-commits mailing list