[PATCH] D40963: Print the bad value and required alignment for unaligned relocations
Rafael Avila de Espindola via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 7 09:40:30 PST 2017
LGTM.
Thanks
Alexander Richardson via Phabricator via llvm-commits
<llvm-commits at lists.llvm.org> writes:
> 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
>
>
> 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
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
More information about the llvm-commits
mailing list