[lld] r265009 - Fix the alignment check.
Rafael Espindola via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 31 05:09:36 PDT 2016
Author: rafael
Date: Thu Mar 31 07:09:36 2016
New Revision: 265009
URL: http://llvm.org/viewvc/llvm-project?rev=265009&view=rev
Log:
Fix the alignment check.
We have to check the final value that is written.
I don't think this has any real word implications (unless something
supports unaligned instructions), but unblocks simplifying the handling
of PC relative relocations.
Added:
lld/trunk/test/ELF/Inputs/mips-align-err.s
lld/trunk/test/ELF/mips-align-err.s
Modified:
lld/trunk/ELF/Target.cpp
Modified: lld/trunk/ELF/Target.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Target.cpp?rev=265009&r1=265008&r2=265009&view=diff
==============================================================================
--- lld/trunk/ELF/Target.cpp (original)
+++ lld/trunk/ELF/Target.cpp Thu Mar 31 07:09:36 2016
@@ -1638,9 +1638,9 @@ static void applyMipsPcReloc(uint8_t *Lo
uint64_t SA) {
uint32_t Mask = 0xffffffff >> (32 - BSIZE);
uint32_t Instr = read32<E>(Loc);
- if (SHIFT > 0)
- checkAlignment<(1 << SHIFT)>(SA, Type);
int64_t V = SA - P;
+ if (SHIFT > 0)
+ checkAlignment<(1 << SHIFT)>(V, Type);
checkInt<BSIZE + SHIFT>(V, Type);
write32<E>(Loc, (Instr & ~Mask) | ((V >> SHIFT) & Mask));
}
Added: lld/trunk/test/ELF/Inputs/mips-align-err.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/Inputs/mips-align-err.s?rev=265009&view=auto
==============================================================================
--- lld/trunk/test/ELF/Inputs/mips-align-err.s (added)
+++ lld/trunk/test/ELF/Inputs/mips-align-err.s Thu Mar 31 07:09:36 2016
@@ -0,0 +1,2 @@
+ .global _foo
+_foo:
Added: lld/trunk/test/ELF/mips-align-err.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/mips-align-err.s?rev=265009&view=auto
==============================================================================
--- lld/trunk/test/ELF/mips-align-err.s (added)
+++ lld/trunk/test/ELF/mips-align-err.s Thu Mar 31 07:09:36 2016
@@ -0,0 +1,12 @@
+# REQUIRES: mips
+# RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux %s -o %t.o \
+# RUN: -mcpu=mips32r6
+# 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: improper alignment for relocation R_MIPS_PC16
+
+ .globl __start
+__start:
+.zero 1
+ beqc $5, $6, _foo # R_MIPS_PC16
More information about the llvm-commits
mailing list