Cleanup in the Darwin end. No functionality change.
authorBill Wendling <isanbard@gmail.com>
Tue, 7 Dec 2010 23:11:00 +0000 (23:11 +0000)
committerBill Wendling <isanbard@gmail.com>
Tue, 7 Dec 2010 23:11:00 +0000 (23:11 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121198 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/ARM/ARMAsmBackend.cpp

index 81bc8f18d0fa9e3897e8aa9ce038b5a572870666..96a5548134b0b912abbfcd67fc6d43fc65e8720a 100644 (file)
@@ -165,9 +165,8 @@ public:
 void ELFARMAsmBackend::ApplyFixup(const MCFixup &Fixup, char *Data,
                                   unsigned DataSize, uint64_t Value) const {
   unsigned NumBytes = 4;        // FIXME: 2 for Thumb
-
   Value = adjustFixupValue(Fixup.getKind(), Value);
-  if (!Value) return;           // No need to encode nothing.
+  if (!Value) return;           // Doesn't change encoding.
 
   unsigned Offset = Fixup.getOffset();
   assert(Offset % NumBytes == 0 && "Offset mod NumBytes is nonzero!");
@@ -207,6 +206,7 @@ public:
   }
 };
 
+/// getFixupKindNumBytes - The number of bytes the fixup may change.
 static unsigned getFixupKindNumBytes(unsigned Kind) {
   switch (Kind) {
   default:
@@ -227,13 +227,15 @@ void DarwinARMAsmBackend::ApplyFixup(const MCFixup &Fixup, char *Data,
                                      unsigned DataSize, uint64_t Value) const {
   unsigned NumBytes = getFixupKindNumBytes(Fixup.getKind());
   Value = adjustFixupValue(Fixup.getKind(), Value);
+  if (!Value) return;           // Doesn't change encoding.
+
+  unsigned Offset = Fixup.getOffset();
+  assert(Offset + NumBytes <= DataSize && "Invalid fixup offset!");
 
-  assert(Fixup.getOffset() + NumBytes <= DataSize &&
-         "Invalid fixup offset!");
   // For each byte of the fragment that the fixup touches, mask in the
   // bits from the fixup value.
   for (unsigned i = 0; i != NumBytes; ++i)
-    Data[Fixup.getOffset() + i] |= uint8_t(Value >> (i * 8));
+    Data[Offset + i] |= uint8_t((Value >> (i * 8)) & 0xff);
 }
 
 } // end anonymous namespace