From: Ulrich Weigand Date: Thu, 1 Dec 2016 17:10:27 +0000 (+0000) Subject: [SystemZ] Fix applyFixup for 12-bit fixups X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a9d6e8b6eedb45d0539814aeeb37ed19b759c0c5;p=llvm [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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@288374 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Target/SystemZ/MCTargetDesc/SystemZMCAsmBackend.cpp b/lib/Target/SystemZ/MCTargetDesc/SystemZMCAsmBackend.cpp index 5a340955d06..1f3cdde1d74 100644 --- a/lib/Target/SystemZ/MCTargetDesc/SystemZMCAsmBackend.cpp +++ b/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);