forked from OSchip/llvm-project
[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
This commit is contained in:
parent
c1835319c9
commit
55082cddef
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue