[llvm] r184072 - AArch64: print relocation addends if present on AArch64

Tim Northover tnorthover at apple.com
Sun Jun 16 20:03:07 PDT 2013


Author: tnorthover
Date: Sun Jun 16 22:03:06 2013
New Revision: 184072

URL: http://llvm.org/viewvc/llvm-project?rev=184072&view=rev
Log:
AArch64: print relocation addends if present on AArch64

llvm-objdump should provide some way of printing out the addends present in the
.rela sections for debugging purposes if nothing else.

Added:
    llvm/trunk/test/MC/AArch64/elf-reloc-addend.s
Modified:
    llvm/trunk/include/llvm/Object/ELF.h

Modified: llvm/trunk/include/llvm/Object/ELF.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/ELF.h?rev=184072&r1=184071&r2=184072&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Object/ELF.h (original)
+++ llvm/trunk/include/llvm/Object/ELF.h Sun Jun 16 22:03:06 2013
@@ -2270,7 +2270,16 @@ error_code ELFObjectFile<ELFT>::getReloc
       res = "Unknown";
     }
     break;
-  case ELF::EM_AARCH64:
+  case ELF::EM_AARCH64: {
+    std::string fmtbuf;
+    raw_string_ostream fmt(fmtbuf);
+    fmt << symname;
+    if (addend != 0)
+      fmt << (addend < 0 ? "" : "+") << addend;
+    fmt.flush();
+    Result.append(fmtbuf.begin(), fmtbuf.end());
+    break;
+  }
   case ELF::EM_ARM:
   case ELF::EM_HEXAGON:
     res = symname;

Added: llvm/trunk/test/MC/AArch64/elf-reloc-addend.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/AArch64/elf-reloc-addend.s?rev=184072&view=auto
==============================================================================
--- llvm/trunk/test/MC/AArch64/elf-reloc-addend.s (added)
+++ llvm/trunk/test/MC/AArch64/elf-reloc-addend.s Sun Jun 16 22:03:06 2013
@@ -0,0 +1,8 @@
+// RUN: llvm-mc -triple=aarch64-linux-gnu -filetype=obj -o - %s | llvm-objdump -triple=aarch64-linux-gnu -r - | FileCheck %s
+
+	add x0, x4, #:lo12:sym
+// CHECK: 0 R_AARCH64_ADD_ABS_LO12_NC sym
+	add x3, x5, #:lo12:sym+1
+// CHECK: 4 R_AARCH64_ADD_ABS_LO12_NC sym+1
+	add x3, x5, #:lo12:sym-1
+// CHECK: 8 R_AARCH64_ADD_ABS_LO12_NC sym-1





More information about the llvm-commits mailing list