From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31190 invoked by alias); 26 Mar 2014 16:39:03 -0000 Mailing-List: contact binutils-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: binutils-owner@sourceware.org Received: (qmail 31179 invoked by uid 89); 26 Mar 2014 16:39:03 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-4.1 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 26 Mar 2014 16:39:02 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s2QGcxmg017589 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 26 Mar 2014 12:39:00 -0400 Received: from littlehelper.redhat.com (vpn1-7-232.ams2.redhat.com [10.36.7.232]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id s2QGcv4G030318 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NO) for ; Wed, 26 Mar 2014 12:38:58 -0400 From: Nick Clifton 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 Message-ID: <874n2koqxq.fsf@redhat.com> MIME-Version: 1.0 Content-Type: text/plain X-IsSubscribed: yes X-SW-Source: 2014-03/txt/msg00272.txt.bz2 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 * 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));