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.
llvm-svn: 265009
diff --git a/lld/ELF/Target.cpp b/lld/ELF/Target.cpp
index 09e3ee6..f89c046 100644
--- a/lld/ELF/Target.cpp
+++ b/lld/ELF/Target.cpp
@@ -1638,9 +1638,9 @@
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));
}