]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blobdiff - gas/config/tc-z8k.c
2021-03-18 Christian Groessler <chris@groessler.org>
[thirdparty/binutils-gdb.git] / gas / config / tc-z8k.c
index 9cfacb1844dd35ba7bf036fb0811f1a197af2769..d3ca8eabeffa2fb1c0755a0ec134b483267a7528 100644 (file)
@@ -993,24 +993,34 @@ apply_fix (unsigned char *ptr, bfd_reloc_code_real_type type,
   /* size is in nibbles.  */
 
   newfix ((ptr - buffer) / 2, type, size + 1, operand);
-  switch (size)
+
+  if (type == BFD_RELOC_Z8K_DISP7)
     {
-    case 8:                    /* 8 nibbles == 32 bits.  */
-      *ptr++ = n >> 28;
-      *ptr++ = n >> 24;
-      *ptr++ = n >> 20;
-      *ptr++ = n >> 16;
-      /* Fall through.  */
-    case 4:                    /* 4 nibbles == 16 bits.  */
-      *ptr++ = n >> 12;
-      *ptr++ = n >> 8;
-      /* Fall through.  */
-    case 2:
-      *ptr++ = n >> 4;
-      /* Fall through.  */
-    case 1:
+      /* 2 nibbles, but most significant bit is part of the opcode == 7 bits.  */
+      *ptr++ = (n >> 4) & 7;
       *ptr++ = n >> 0;
-      break;
+    }
+  else
+    {
+      switch (size)
+        {
+        case 8:                        /* 8 nibbles == 32 bits.  */
+          *ptr++ = n >> 28;
+          *ptr++ = n >> 24;
+          *ptr++ = n >> 20;
+          *ptr++ = n >> 16;
+          /* Fall through.  */
+        case 4:                        /* 4 nibbles == 16 bits.  */
+          *ptr++ = n >> 12;
+          *ptr++ = n >> 8;
+          /* Fall through.  */
+        case 2:
+          *ptr++ = n >> 4;
+          /* Fall through.  */
+        case 1:
+          *ptr++ = n >> 0;
+          break;
+        }
     }
   return ptr;
 }