aboutsummaryrefslogtreecommitdiff
path: root/gas
diff options
context:
space:
mode:
authorChristian Groessler <chris@groessler.org>2021-03-18 21:33:51 +0100
committerChristian Groessler <chris@groessler.org>2021-03-18 21:33:51 +0100
commit3273f9a19e69e2dcd0a92c653a3567464899a29e (patch)
treeb67f9113c0b72fc495ddf537853eee57748b88be /gas
parent15310fd4eb59093f0c394f7b3644a814b5422403 (diff)
downloadgdb-3273f9a19e69e2dcd0a92c653a3567464899a29e.zip
gdb-3273f9a19e69e2dcd0a92c653a3567464899a29e.tar.gz
gdb-3273f9a19e69e2dcd0a92c653a3567464899a29e.tar.bz2
2021-03-18 Christian Groessler <chris@groessler.org>
* config/tc-z8k.c (apply_fix): Handle 7-bit relocations correctly. Problem found by Tadashi G. Takaoka <tadashi.g.takaoka@gmail.com>.
Diffstat (limited to 'gas')
-rw-r--r--gas/ChangeLog5
-rw-r--r--gas/config/tc-z8k.c42
2 files changed, 31 insertions, 16 deletions
diff --git a/gas/ChangeLog b/gas/ChangeLog
index f759c93..2953d5d 100644
--- a/gas/ChangeLog
+++ b/gas/ChangeLog
@@ -1,3 +1,8 @@
+2021-03-18 Christian Groessler <chris@groessler.org>
+
+ * config/tc-z8k.c (apply_fix): Handle 7-bit relocations correctly.
+ Problem found by Tadashi G. Takaoka <tadashi.g.takaoka@gmail.com>.
+
2021-03-16 Kuan-Lin Chen <kuanlinchentw@gmail.com>
* config/tc-riscv.c (ext_version_table): Add b, zba, zbb and zbc.
diff --git a/gas/config/tc-z8k.c b/gas/config/tc-z8k.c
index 9cfacb1..d3ca8ea 100644
--- a/gas/config/tc-z8k.c
+++ b/gas/config/tc-z8k.c
@@ -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;
}