From: Nick Clifton <nickc@redhat.com>
To: binutils@sourceware.org
Subject: Commit: RL78: Add support for resolving %hi8, %hi16 and %lo16 operators
Date: Wed, 26 Mar 2014 16:39:00 -0000 [thread overview]
Message-ID: <874n2koqxq.fsf@redhat.com> (raw)
Hi Guys,
I am applying a patch to the RL78 port of GAS to fix a problem with
the %hi8, %hi16 and %lo16 operators. They would work, but only if
their arguments needed relocating. If the arguments were constants
then gas would complain!
Tested with no regressions on an rl78-elf toolchain.
Cheers
Nick
gas/ChangeLog
2014-03-26 Nick Clifton <nickc@redhat.com>
* config/tc-rl78.c (rl78_op): Issue an error message if a 16-bit
relocation is used on an 8-bit operand or vice versa.
(tc_gen_reloc): Use the RL78_16U relocation for RL78_CODE.
(md_apply_fix): Add support for RL78_HI8, RL78_HI16 and RL78_LO16.
diff --git a/gas/config/tc-rl78.c b/gas/config/tc-rl78.c
index 962a0b0..ae8f5af 100644
--- a/gas/config/tc-rl78.c
+++ b/gas/config/tc-rl78.c
@@ -208,6 +208,16 @@ rl78_op (expressionS exp, int nbytes, int type)
if (nbytes > 2
&& exp.X_md == BFD_RELOC_RL78_CODE)
exp.X_md = 0;
+
+ if (nbytes == 1
+ && (exp.X_md == BFD_RELOC_RL78_LO16
+ || exp.X_md == BFD_RELOC_RL78_HI16))
+ as_bad (_("16-bit relocation used in 8-bit operand"));
+
+ if (nbytes == 2
+ && exp.X_md == BFD_RELOC_RL78_HI8)
+ as_bad (_("8-bit relocation used in 16-bit operand"));
+
rl78_op_fixup (exp, rl78_bytes.n_ops * 8, nbytes * 8, type);
memset (rl78_bytes.ops + rl78_bytes.n_ops, 0, nbytes);
rl78_bytes.n_ops += nbytes;
@@ -1197,8 +1207,8 @@ tc_gen_reloc (asection * seg ATTRIBUTE_UNUSED, fixS * fixp)
break;
case BFD_RELOC_RL78_CODE:
- SYM0 ();
- OP (ABS16);
+ reloc[0]->howto = bfd_reloc_type_lookup (stdoutput, BFD_RELOC_RL78_16U);
+ reloc[1] = NULL;
break;
case BFD_RELOC_RL78_LO16:
@@ -1326,6 +1336,22 @@ md_apply_fix (struct fix * f ATTRIBUTE_UNUSED,
op[3] = val >> 24;
break;
+ case BFD_RELOC_RL78_HI8:
+ val = val >> 16;
+ op[0] = val;
+ break;
+
+ case BFD_RELOC_RL78_HI16:
+ val = val >> 16;
+ op[0] = val;
+ op[1] = val >> 8;
+ break;
+
+ case BFD_RELOC_RL78_LO16:
+ op[0] = val;
+ op[1] = val >> 8;
+ break;
+
default:
as_bad (_("Unknown reloc in md_apply_fix: %s"),
bfd_get_reloc_code_name (f->fx_r_type));
reply other threads:[~2014-03-26 16:39 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=874n2koqxq.fsf@redhat.com \
--to=nickc@redhat.com \
--cc=binutils@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).