Add basic support for ELF32-ppc relocations to llvm-dwarfdump.
authorBenjamin Kramer <benny.kra@googlemail.com>
Sat, 18 May 2013 16:00:35 +0000 (16:00 +0000)
committerBenjamin Kramer <benny.kra@googlemail.com>
Sat, 18 May 2013 16:00:35 +0000 (16:00 +0000)
Should help the ppc32 buildbot.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@182194 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Object/ELF.h
include/llvm/Object/RelocVisitor.h

index 22ca201be124e60e587b174ace46955fd550a66a..5a26decd95e58d7c946710fec3d2022285f83b8f 100644 (file)
@@ -2697,6 +2697,8 @@ StringRef ELFObjectFile<ELFT>::getFileFormatName() const {
       return "ELF32-hexagon";
     case ELF::EM_MIPS:
       return "ELF32-mips";
+    case ELF::EM_PPC:
+      return "ELF32-ppc";
     default:
       return "ELF32-unknown";
     }
index 69ce5cffc3cf71b916aeea8875446cb28549f779..52e4d6f98f17b49350ef80745e2df9ce64bed1fa 100644 (file)
@@ -85,6 +85,14 @@ public:
         HasError = true;
         return RelocToApply();
       }
+    } else if (FileFormat == "ELF32-ppc") {
+      switch (RelocType) {
+      case llvm::ELF::R_PPC_ADDR32:
+        return visitELF_PPC_ADDR32(R, Value);
+      default:
+        HasError = true;
+        return RelocToApply();
+      }
     } else if (FileFormat == "ELF32-mips") {
       switch (RelocType) {
       case llvm::ELF::R_MIPS_32:
@@ -210,6 +218,13 @@ private:
     return RelocToApply(Res, 4);
   }
 
+  /// PPC32 ELF
+  RelocToApply visitELF_PPC_ADDR32(RelocationRef R, uint64_t Value) {
+    int64_t Addend = getAddend32BE(R);
+    uint32_t Res = (Value + Addend) & 0xFFFFFFFF;
+    return RelocToApply(Res, 4);
+  }
+
   /// MIPS ELF
   RelocToApply visitELF_MIPS_32(RelocationRef R, uint64_t Value) {
     int64_t Addend;