[llvm] r241040 - Move function to the only file that uses it.

Rafael Espindola rafael.espindola at gmail.com
Mon Jun 29 20:41:26 PDT 2015


Author: rafael
Date: Mon Jun 29 22:41:26 2015
New Revision: 241040

URL: http://llvm.org/viewvc/llvm-project?rev=241040&view=rev
Log:
Move function to the only file that uses it.

Modified:
    llvm/trunk/include/llvm/Object/MachO.h
    llvm/trunk/include/llvm/Object/ObjectFile.h
    llvm/trunk/lib/Object/MachOObjectFile.cpp
    llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp

Modified: llvm/trunk/include/llvm/Object/MachO.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/MachO.h?rev=241040&r1=241039&r2=241040&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Object/MachO.h (original)
+++ llvm/trunk/include/llvm/Object/MachO.h Mon Jun 29 22:41:26 2015
@@ -244,7 +244,6 @@ public:
   std::error_code
   getRelocationTypeName(DataRefImpl Rel,
                         SmallVectorImpl<char> &Result) const override;
-  bool getRelocationHidden(DataRefImpl Rel) const override;
   uint8_t getRelocationLength(DataRefImpl Rel) const;
 
   // MachO specific.

Modified: llvm/trunk/include/llvm/Object/ObjectFile.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/ObjectFile.h?rev=241040&r1=241039&r2=241040&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Object/ObjectFile.h (original)
+++ llvm/trunk/include/llvm/Object/ObjectFile.h Mon Jun 29 22:41:26 2015
@@ -55,11 +55,6 @@ public:
   symbol_iterator getSymbol() const;
   uint64_t getType() const;
 
-  /// @brief Indicates whether this relocation should hidden when listing
-  /// relocations, usually because it is the trailing part of a multipart
-  /// relocation that will be printed as part of the leading relocation.
-  bool getHidden() const;
-
   /// @brief Get a string that represents the type of this relocation.
   ///
   /// This is for display purposes only.
@@ -246,7 +241,6 @@ protected:
   virtual std::error_code
   getRelocationTypeName(DataRefImpl Rel,
                         SmallVectorImpl<char> &Result) const = 0;
-  virtual bool getRelocationHidden(DataRefImpl Rel) const { return false; }
 
 public:
   uint64_t getCommonSymbolSize(DataRefImpl Symb) const {
@@ -468,10 +462,6 @@ RelocationRef::getTypeName(SmallVectorIm
   return OwningObject->getRelocationTypeName(RelocationPimpl, Result);
 }
 
-inline bool RelocationRef::getHidden() const {
-  return OwningObject->getRelocationHidden(RelocationPimpl);
-}
-
 inline DataRefImpl RelocationRef::getRawDataRefImpl() const {
   return RelocationPimpl;
 }

Modified: llvm/trunk/lib/Object/MachOObjectFile.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/MachOObjectFile.cpp?rev=241040&r1=241039&r2=241040&view=diff
==============================================================================
--- llvm/trunk/lib/Object/MachOObjectFile.cpp (original)
+++ llvm/trunk/lib/Object/MachOObjectFile.cpp Mon Jun 29 22:41:26 2015
@@ -770,30 +770,6 @@ MachOObjectFile::getRelocationTypeName(D
   return std::error_code();
 }
 
-bool MachOObjectFile::getRelocationHidden(DataRefImpl Rel) const {
-  unsigned Arch = getArch();
-  uint64_t Type = getRelocationType(Rel);
-
-  // On arches that use the generic relocations, GENERIC_RELOC_PAIR
-  // is always hidden.
-  if (Arch == Triple::x86 || Arch == Triple::arm || Arch == Triple::ppc) {
-    if (Type == MachO::GENERIC_RELOC_PAIR)
-      return true;
-  } else if (Arch == Triple::x86_64) {
-    // On x86_64, X86_64_RELOC_UNSIGNED is hidden only when it follows
-    // an X86_64_RELOC_SUBTRACTOR.
-    if (Type == MachO::X86_64_RELOC_UNSIGNED && Rel.d.a > 0) {
-      DataRefImpl RelPrev = Rel;
-      RelPrev.d.a--;
-      uint64_t PrevType = getRelocationType(RelPrev);
-      if (PrevType == MachO::X86_64_RELOC_SUBTRACTOR)
-        return true;
-    }
-  }
-
-  return false;
-}
-
 uint8_t MachOObjectFile::getRelocationLength(DataRefImpl Rel) const {
   MachO::any_relocation_info RE = getRelocation(Rel);
   return getAnyRelocationLength(RE);

Modified: llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp?rev=241040&r1=241039&r2=241040&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp (original)
+++ llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp Mon Jun 29 22:41:26 2015
@@ -692,6 +692,39 @@ static std::error_code getRelocationValu
   return getRelocationValueString(MachO, Rel, Result);
 }
 
+/// @brief Indicates whether this relocation should hidden when listing
+/// relocations, usually because it is the trailing part of a multipart
+/// relocation that will be printed as part of the leading relocation.
+static bool getHidden(RelocationRef RelRef) {
+  const ObjectFile *Obj = RelRef.getObject();
+  auto *MachO = dyn_cast<MachOObjectFile>(Obj);
+  if (!MachO)
+    return false;
+
+  unsigned Arch = MachO->getArch();
+  DataRefImpl Rel = RelRef.getRawDataRefImpl();
+  uint64_t Type = MachO->getRelocationType(Rel);
+
+  // On arches that use the generic relocations, GENERIC_RELOC_PAIR
+  // is always hidden.
+  if (Arch == Triple::x86 || Arch == Triple::arm || Arch == Triple::ppc) {
+    if (Type == MachO::GENERIC_RELOC_PAIR)
+      return true;
+  } else if (Arch == Triple::x86_64) {
+    // On x86_64, X86_64_RELOC_UNSIGNED is hidden only when it follows
+    // an X86_64_RELOC_SUBTRACTOR.
+    if (Type == MachO::X86_64_RELOC_UNSIGNED && Rel.d.a > 0) {
+      DataRefImpl RelPrev = Rel;
+      RelPrev.d.a--;
+      uint64_t PrevType = MachO->getRelocationType(RelPrev);
+      if (PrevType == MachO::X86_64_RELOC_SUBTRACTOR)
+        return true;
+    }
+  }
+
+  return false;
+}
+
 static void DisassembleObject(const ObjectFile *Obj, bool InlineRelocs) {
   const Target *TheTarget = getTarget(Obj);
   // getTarget() will have already issued a diagnostic if necessary, so
@@ -888,7 +921,7 @@ static void DisassembleObject(const Obje
 
         // Print relocation for instruction.
         while (rel_cur != rel_end) {
-          bool hidden = rel_cur->getHidden();
+          bool hidden = getHidden(*rel_cur);
           uint64_t addr = rel_cur->getOffset();
           SmallString<16> name;
           SmallString<32> val;
@@ -928,7 +961,7 @@ void llvm::PrintRelocations(const Object
       continue;
     outs() << "RELOCATION RECORDS FOR [" << secname << "]:\n";
     for (const RelocationRef &Reloc : Section.relocations()) {
-      bool hidden = Reloc.getHidden();
+      bool hidden = getHidden(Reloc);
       uint64_t address = Reloc.getOffset();
       SmallString<32> relocname;
       SmallString<32> valuestr;





More information about the llvm-commits mailing list