[PATCH] D40963: Print the bad value and required alignment for unaligned relocations

Alexander Richardson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 7 09:08:26 PST 2017


arichardson created this revision.
Herald added subscribers: llvm-commits, javed.absar, emaste.

Repository:
  rLLD LLVM Linker

https://reviews.llvm.org/D40963

Files:
  ELF/Target.h
  test/ELF/aarch64-lo12-alignment.s
  test/ELF/aarch64-load-alignment.s
  test/ELF/mips-align-err.s


Index: test/ELF/mips-align-err.s
===================================================================
--- test/ELF/mips-align-err.s
+++ test/ELF/mips-align-err.s
@@ -4,7 +4,7 @@
 # RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux \
 # RUN:         -mcpu=mips32r6 %S/Inputs/mips-align-err.s -o %t2.o
 # RUN: not ld.lld %t.o %t2.o -o %t.exe 2>&1 | FileCheck %s
-# CHECK: {{.*}}:(.text+0x1): improper alignment for relocation R_MIPS_PC16
+# CHECK: {{.*}}:(.text+0x1): improper alignment for relocation R_MIPS_PC16: 0xB is not aligned to 4 bytes
 
         .globl  __start
 __start:
Index: test/ELF/aarch64-load-alignment.s
===================================================================
--- test/ELF/aarch64-load-alignment.s
+++ test/ELF/aarch64-load-alignment.s
@@ -3,7 +3,7 @@
 # RUN: llvm-mc -filetype=obj -triple=aarch64-linux-none %s -o %t.o
 # RUN: not ld.lld -shared %t.o -o %t 2>&1 | FileCheck %s
 
-# CHECK: improper alignment for relocation R_AARCH64_LD_PREL_LO19
+# CHECK: improper alignment for relocation R_AARCH64_LD_PREL_LO19: 0x10005 is not aligned to 4 bytes
 
   ldr x8, patatino
   .data
Index: test/ELF/aarch64-lo12-alignment.s
===================================================================
--- test/ELF/aarch64-lo12-alignment.s
+++ test/ELF/aarch64-lo12-alignment.s
@@ -39,7 +39,7 @@
 foo8:
  .space 8
 
-// CHECK: improper alignment for relocation R_AARCH64_LDST16_ABS_LO12_NC
-// CHECK-NEXT: improper alignment for relocation R_AARCH64_LDST32_ABS_LO12_NC
-// CHECK-NEXT: improper alignment for relocation R_AARCH64_LDST64_ABS_LO12_NC
-// CHECK-NEXT: improper alignment for relocation R_AARCH64_LDST128_ABS_LO12_NC
+// CHECK: improper alignment for relocation R_AARCH64_LDST16_ABS_LO12_NC: 0x30001 is not aligned to 2 bytes
+// CHECK-NEXT: improper alignment for relocation R_AARCH64_LDST32_ABS_LO12_NC: 0x30002 is not aligned to 4 bytes
+// CHECK-NEXT: improper alignment for relocation R_AARCH64_LDST64_ABS_LO12_NC: 0x30004 is not aligned to 8 bytes
+// CHECK-NEXT: improper alignment for relocation R_AARCH64_LDST128_ABS_LO12_NC: 0x30008 is not aligned to 16 bytes
Index: ELF/Target.h
===================================================================
--- ELF/Target.h
+++ ELF/Target.h
@@ -169,7 +169,8 @@
 static void checkAlignment(uint8_t *Loc, uint64_t V, RelType Type) {
   if ((V & (N - 1)) != 0)
     error(getErrorLocation(Loc) + "improper alignment for relocation " +
-          lld::toString(Type));
+          lld::toString(Type) + ": 0x" + llvm::utohexstr(V) +
+          " is not aligned to " + Twine(N) + " bytes");
 }
 } // namespace elf
 } // namespace lld


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D40963.125976.patch
Type: text/x-patch
Size: 2609 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171207/a86211a1/attachment.bin>


More information about the llvm-commits mailing list