[PATCH] D14943: [ELF] Factor out relocation checks into separate functions.

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 25 10:33:53 PST 2015


ruiu accepted this revision.
ruiu added a comment.

LGTM with these fixes.


================
Comment at: ELF/Target.cpp:59
@@ +58,3 @@
+
+template <unsigned N> static void checkAlignment(uint64_t V, uint32_t Type) {
+  uint64_t Mask = (1 << N) - 1;
----------------
We usually represent an alignment by its value and not in the form of log2, so for consistency,

  uint64_t Mask = N - 1;

or

  if ((V & (N - 1)) == 0)

================
Comment at: ELF/Target.cpp:615
@@ -595,5 +614,3 @@
   case R_PPC64_ADDR14: {
-    if ((SA & 3) != 0)
-      error("Improper alignment for relocation R_PPC64_ADDR14");
-
+    checkAlignment<2>(SA, Type);
     // Preserve the AA/LK bits in the branch instruction
----------------
So this becomes

  checkAlignment<4>

================
Comment at: ELF/Target.cpp:818
@@ -810,4 +817,3 @@
   case R_AARCH64_LD64_GOT_LO12_NC:
-    if (SA & 0x7)
-      error("Relocation R_AARCH64_LD64_GOT_LO12_NC not aligned");
+    checkAlignment<3>(SA, Type);
     // No overflow check needed.
----------------
checkAlignment<8>


http://reviews.llvm.org/D14943





More information about the llvm-commits mailing list