summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target/SystemZ/MCTargetDesc/SystemZMCAsmBackend.cpp
diff options
context:
space:
mode:
authorUlrich Weigand <ulrich.weigand@de.ibm.com>2016-12-01 17:10:27 +0000
committerUlrich Weigand <ulrich.weigand@de.ibm.com>2016-12-01 17:10:27 +0000
commit55082cddefbe7f4b7808bfcdfe0e7666713c99a4 (patch)
tree2e4671f27856b32ba3e6b16301fca299f3759b62 /llvm/lib/Target/SystemZ/MCTargetDesc/SystemZMCAsmBackend.cpp
parentc1835319c93b4ff6d67b084ef538d727e0b04d47 (diff)
downloadbcm5719-llvm-55082cddefbe7f4b7808bfcdfe0e7666713c99a4.tar.gz
bcm5719-llvm-55082cddefbe7f4b7808bfcdfe0e7666713c99a4.zip
[SystemZ] Fix applyFixup for 12-bit fixups
Now that we have fixups that only fill parts of a byte, it turns out we have to mask off the bits outside the fixup area when applying them. Failing to do so caused invalid object code to be emitted for bprp with a negative 12-bit displacement. llvm-svn: 288374
Diffstat (limited to 'llvm/lib/Target/SystemZ/MCTargetDesc/SystemZMCAsmBackend.cpp')
-rw-r--r--llvm/lib/Target/SystemZ/MCTargetDesc/SystemZMCAsmBackend.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/llvm/lib/Target/SystemZ/MCTargetDesc/SystemZMCAsmBackend.cpp b/llvm/lib/Target/SystemZ/MCTargetDesc/SystemZMCAsmBackend.cpp
index 5a340955d06..1f3cdde1d74 100644
--- a/llvm/lib/Target/SystemZ/MCTargetDesc/SystemZMCAsmBackend.cpp
+++ b/llvm/lib/Target/SystemZ/MCTargetDesc/SystemZMCAsmBackend.cpp
@@ -94,12 +94,14 @@ void SystemZMCAsmBackend::applyFixup(const MCFixup &Fixup, char *Data,
bool IsPCRel) const {
MCFixupKind Kind = Fixup.getKind();
unsigned Offset = Fixup.getOffset();
- unsigned Size = (getFixupKindInfo(Kind).TargetSize + 7) / 8;
+ unsigned BitSize = getFixupKindInfo(Kind).TargetSize;
+ unsigned Size = (BitSize + 7) / 8;
assert(Offset + Size <= DataSize && "Invalid fixup offset!");
// Big-endian insertion of Size bytes.
Value = extractBitsForFixup(Kind, Value);
+ Value &= ((uint64_t)1 << BitSize) - 1;
unsigned ShiftValue = (Size * 8) - 8;
for (unsigned I = 0; I != Size; ++I) {
Data[Offset + I] |= uint8_t(Value >> ShiftValue);
OpenPOWER on IntegriCloud