From: Palmer Dabbelt <palmer@dabbelt.com>
To: binutils@sourceware.org
To: Tristan Gingold <gingold@adacore.com>
Cc: Kuan-Lin Chen <rufus@andestech.com>
Subject: [PATCH 2/7] RISC-V: Fix the offset of CFA relocation.
Date: Wed, 22 Mar 2017 23:04:00 -0000 [thread overview]
Message-ID: <20170322230408.8885-3-palmer@dabbelt.com> (raw)
In-Reply-To: <20170322230408.8885-1-palmer@dabbelt.com>
From: Kuan-Lin Chen <rufus@andestech.com>
gas/ChangeLog:
2017-03-02 Kuan-Lin Chen <rufus@andestech.com>
* config/tc-riscv.c (md_apply_fix): Compute the correct offsets
for CFA relocations.
---
gas/ChangeLog | 5 +++++
gas/config/tc-riscv.c | 20 ++++++++++----------
2 files changed, 15 insertions(+), 10 deletions(-)
diff --git a/gas/ChangeLog b/gas/ChangeLog
index d59472a..7639ec7 100644
--- a/gas/ChangeLog
+++ b/gas/ChangeLog
@@ -1,3 +1,8 @@
+2017-03-02 Kuan-Lin Chen <rufus@andestech.com>
+
+ * config/tc-riscv.c (md_apply_fix): Compute the correct offsets
+ for CFA relocations.
+
2017-03-21 Andreas Krebbel <krebbel@linux.vnet.ibm.com>
Backport from mainline
diff --git a/gas/config/tc-riscv.c b/gas/config/tc-riscv.c
index ec5b0bb..c79f313 100644
--- a/gas/config/tc-riscv.c
+++ b/gas/config/tc-riscv.c
@@ -1837,6 +1837,7 @@ md_apply_fix (fixS *fixP, valueT *valP, segT seg ATTRIBUTE_UNUSED)
unsigned int subtype;
bfd_byte *buf = (bfd_byte *) (fixP->fx_frag->fr_literal + fixP->fx_where);
bfd_boolean relaxable = FALSE;
+ offsetT loc;
/* Remember value for tc_gen_reloc. */
fixP->fx_addnumber = *valP;
@@ -1922,30 +1923,31 @@ md_apply_fix (fixS *fixP, valueT *valP, segT seg ATTRIBUTE_UNUSED)
case BFD_RELOC_RISCV_CFA:
/* Load the byte to get the subtype. */
- subtype = bfd_get_8 (NULL, &fixP->fx_frag->fr_literal[fixP->fx_where]);
+ subtype = bfd_get_8 (NULL, &((fragS *) (fixP->fx_frag->fr_opcode))->fr_literal[fixP->fx_where]);
+ loc = fixP->fx_frag->fr_fix - (subtype & 7);
switch (subtype)
{
case DW_CFA_advance_loc1:
- fixP->fx_where++;
- fixP->fx_next->fx_where++;
+ fixP->fx_where = loc + 1;
+ fixP->fx_next->fx_where = loc + 1;
fixP->fx_r_type = BFD_RELOC_RISCV_SET8;
fixP->fx_next->fx_r_type = BFD_RELOC_RISCV_SUB8;
break;
case DW_CFA_advance_loc2:
fixP->fx_size = 2;
- fixP->fx_where++;
fixP->fx_next->fx_size = 2;
- fixP->fx_next->fx_where++;
+ fixP->fx_where = loc + 1;
+ fixP->fx_next->fx_where = loc + 1;
fixP->fx_r_type = BFD_RELOC_RISCV_SET16;
fixP->fx_next->fx_r_type = BFD_RELOC_RISCV_SUB16;
break;
case DW_CFA_advance_loc4:
fixP->fx_size = 4;
- fixP->fx_where++;
fixP->fx_next->fx_size = 4;
- fixP->fx_next->fx_where++;
+ fixP->fx_where = loc;
+ fixP->fx_next->fx_where = loc;
fixP->fx_r_type = BFD_RELOC_RISCV_SET32;
fixP->fx_next->fx_r_type = BFD_RELOC_RISCV_SUB32;
break;
@@ -2069,7 +2071,6 @@ riscv_pre_output_hook (void)
{
if (frag->fr_type == rs_cfa)
{
- fragS *loc4_frag;
expressionS exp;
symbolS *add_symbol = frag->fr_symbol->sy_value.X_add_symbol;
@@ -2080,8 +2081,7 @@ riscv_pre_output_hook (void)
exp.X_add_number = 0;
exp.X_op_symbol = op_symbol;
- loc4_frag = (fragS *) frag->fr_opcode;
- fix_new_exp (loc4_frag, (int) frag->fr_offset, 1, &exp, 0,
+ fix_new_exp (frag, (int) frag->fr_offset, 1, &exp, 0,
BFD_RELOC_RISCV_CFA);
}
}
--
2.10.2
next prev parent reply other threads:[~2017-03-22 23:04 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-22 23:04 binutils-2_28-branch: Assorted RISC-V Fixes Palmer Dabbelt
2017-03-22 23:04 ` [PATCH 4/7] RISC-V: Define DWARF2_USE_FIXED_ADVANCE_PC Palmer Dabbelt
2017-03-22 23:04 ` [PATCH 3/7] RISC-V: Fix DW_CFA_advance_loc relocation Palmer Dabbelt
2017-03-22 23:04 ` [PATCH 1/7] RISC-V: Fix [dis]assembly of srai/srli Palmer Dabbelt
2017-03-22 23:04 ` [PATCH 6/7] RISC-V: Fix assembler for c.li, c.andi and c.addiw Palmer Dabbelt
2017-03-22 23:04 ` [PATCH 5/7] RISC-V: Fix assembler for c.addi, rd can be x0 Palmer Dabbelt
2017-03-22 23:04 ` Palmer Dabbelt [this message]
2017-03-22 23:04 ` [PATCH 7/7] Sanitize RISC-V GAS help text, documentation Palmer Dabbelt
2017-03-23 10:53 ` binutils-2_28-branch: Assorted RISC-V Fixes gingold
2017-03-30 20:01 ` Palmer Dabbelt
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=20170322230408.8885-3-palmer@dabbelt.com \
--to=palmer@dabbelt.com \
--cc=binutils@sourceware.org \
--cc=rufus@andestech.com \
/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).