Print the bad value and required alignment for unaligned relocations

Reviewers: ruiu, grimar

Reviewed By: ruiu

Subscribers: emaste, javed.absar, llvm-commits

Differential Revision: https://reviews.llvm.org/D40963

llvm-svn: 320147
This commit is contained in:
Alexander Richardson 2017-12-08 14:53:14 +00:00
parent cead41d42f
commit f5ef4e5616
4 changed files with 8 additions and 7 deletions

View File

@ -169,7 +169,8 @@ template <unsigned N>
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

View File

@ -39,7 +39,7 @@ foo4:
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

View File

@ -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

View File

@ -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: