public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 2/3] Fix DW_CFA_advance_loc relocation.
  2017-03-13 21:48 Fix RISC-V CFA relocations Palmer Dabbelt
  2017-03-13 21:48 ` [PATCH 1/3] Fix the offset of CFA relocation Palmer Dabbelt
@ 2017-03-13 21:48 ` Palmer Dabbelt
  2017-03-14 10:55   ` Jan Beulich
  2017-03-15  9:27   ` Nick Clifton
  2017-03-13 21:48 ` [PATCH 3/3] Define DWARF2_USE_FIXED_ADVANCE_PC Palmer Dabbelt
  2017-03-14 17:01 ` Fix RISC-V CFA relocations Palmer Dabbelt
  3 siblings, 2 replies; 10+ messages in thread
From: Palmer Dabbelt @ 2017-03-13 21:48 UTC (permalink / raw)
  To: binutils; +Cc: Kuan-Lin Chen

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): Set fx_frag and
        fx_next->fx_frag for CFA_advance_loc relocations.
---
 gas/ChangeLog         | 5 +++++
 gas/config/tc-riscv.c | 2 ++
 2 files changed, 7 insertions(+)

diff --git a/gas/ChangeLog b/gas/ChangeLog
index 4d638b4..1478cdf 100644
--- a/gas/ChangeLog
+++ b/gas/ChangeLog
@@ -1,5 +1,10 @@
 2017-03-02  Kuan-Lin Chen  <rufus@andestech.com>
 
+	* config/tc-riscv.c (md_apply_fix): Set fx_frag and
+	fx_next->fx_frag for CFA_advance_loc relocations.
+
+2017-03-02  Kuan-Lin Chen  <rufus@andestech.com>
+
 	* config/tc-riscv.c (md_apply_fix): Compute the correct offsets
 	for CFA relocations.
 
diff --git a/gas/config/tc-riscv.c b/gas/config/tc-riscv.c
index 3744e84..723ccba 100644
--- a/gas/config/tc-riscv.c
+++ b/gas/config/tc-riscv.c
@@ -1966,6 +1966,8 @@ md_apply_fix (fixS *fixP, valueT *valP, segT seg ATTRIBUTE_UNUSED)
 		  if (subtype < 0x80 && (subtype & 0x40))
 		    {
 		      /* DW_CFA_advance_loc */
+		      fixP->fx_frag = (fragS *) fixP->fx_frag->fr_opcode;
+		      fixP->fx_next->fx_frag = fixP->fx_frag;
 		      fixP->fx_r_type = BFD_RELOC_RISCV_SET6;
 		      fixP->fx_next->fx_r_type = BFD_RELOC_RISCV_SUB6;
 		    }
-- 
2.10.2

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Fix RISC-V CFA relocations
@ 2017-03-13 21:48 Palmer Dabbelt
  2017-03-13 21:48 ` [PATCH 1/3] Fix the offset of CFA relocation Palmer Dabbelt
                   ` (3 more replies)
  0 siblings, 4 replies; 10+ messages in thread
From: Palmer Dabbelt @ 2017-03-13 21:48 UTC (permalink / raw)
  To: binutils

Without this patch set we don't correctly compute CFA relocation offsets, which
means debug info is broken on RISC-V.

[PATCH 1/3] Fix the offset of CFA relocation.
[PATCH 2/3] Fix DW_CFA_advance_loc relocation.
[PATCH 3/3] Define DWARF2_USE_FIXED_ADVANCE_PC.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 1/3] Fix the offset of CFA relocation.
  2017-03-13 21:48 Fix RISC-V CFA relocations Palmer Dabbelt
@ 2017-03-13 21:48 ` Palmer Dabbelt
  2017-03-15  9:27   ` Nick Clifton
  2017-03-13 21:48 ` [PATCH 2/3] Fix DW_CFA_advance_loc relocation Palmer Dabbelt
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 10+ messages in thread
From: Palmer Dabbelt @ 2017-03-13 21:48 UTC (permalink / raw)
  To: binutils; +Cc: Kuan-Lin Chen

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 4d6dd4e..4d638b4 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-13  Nick Clifton  <nickc@redhat.com>
 
 	PR binutils/21202
diff --git a/gas/config/tc-riscv.c b/gas/config/tc-riscv.c
index 6bbaa4b..3744e84 100644
--- a/gas/config/tc-riscv.c
+++ b/gas/config/tc-riscv.c
@@ -1847,6 +1847,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;
@@ -1932,30 +1933,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;
@@ -2079,7 +2081,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;
@@ -2090,8 +2091,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

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 3/3] Define DWARF2_USE_FIXED_ADVANCE_PC.
  2017-03-13 21:48 Fix RISC-V CFA relocations Palmer Dabbelt
  2017-03-13 21:48 ` [PATCH 1/3] Fix the offset of CFA relocation Palmer Dabbelt
  2017-03-13 21:48 ` [PATCH 2/3] Fix DW_CFA_advance_loc relocation Palmer Dabbelt
@ 2017-03-13 21:48 ` Palmer Dabbelt
  2017-03-15  9:28   ` Nick Clifton
  2017-03-14 17:01 ` Fix RISC-V CFA relocations Palmer Dabbelt
  3 siblings, 1 reply; 10+ messages in thread
From: Palmer Dabbelt @ 2017-03-13 21:48 UTC (permalink / raw)
  To: binutils; +Cc: Kuan-Lin Chen

From: Kuan-Lin Chen <rufus@andestech.com>

gas/ChangeLog

2017-03-02  Kuan-Lin Chen  <rufus@andestech.com>

        * config/tc-riscv.h (HWARD2_USE_FIXED_ADVANCE_PC): New define.
---
 gas/ChangeLog         | 4 ++++
 gas/config/tc-riscv.h | 3 +++
 2 files changed, 7 insertions(+)

diff --git a/gas/ChangeLog b/gas/ChangeLog
index 1478cdf..19245ec 100644
--- a/gas/ChangeLog
+++ b/gas/ChangeLog
@@ -1,5 +1,9 @@
 2017-03-02  Kuan-Lin Chen  <rufus@andestech.com>
 
+	* config/tc-riscv.h (HWARD2_USE_FIXED_ADVANCE_PC): New define.
+
+2017-03-02  Kuan-Lin Chen  <rufus@andestech.com>
+
 	* config/tc-riscv.c (md_apply_fix): Set fx_frag and
 	fx_next->fx_frag for CFA_advance_loc relocations.
 
diff --git a/gas/config/tc-riscv.h b/gas/config/tc-riscv.h
index ae8d60e..e92b387 100644
--- a/gas/config/tc-riscv.h
+++ b/gas/config/tc-riscv.h
@@ -112,4 +112,7 @@ extern int tc_riscv_regname_to_dw2regnum (char *);
 #define elf_tc_final_processing riscv_elf_final_processing
 extern void riscv_elf_final_processing (void);
 
+/* Adjust debug_line after relaxation.  */
+#define DWARF2_USE_FIXED_ADVANCE_PC 1
+
 #endif /* TC_RISCV */
-- 
2.10.2

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 2/3] Fix DW_CFA_advance_loc relocation.
  2017-03-13 21:48 ` [PATCH 2/3] Fix DW_CFA_advance_loc relocation Palmer Dabbelt
@ 2017-03-14 10:55   ` Jan Beulich
  2017-03-14 16:18     ` Palmer Dabbelt
  2017-03-15  9:27   ` Nick Clifton
  1 sibling, 1 reply; 10+ messages in thread
From: Jan Beulich @ 2017-03-14 10:55 UTC (permalink / raw)
  To: Palmer Dabbelt; +Cc: Kuan-Lin Chen, binutils

>>> On 13.03.17 at 22:47, <palmer@dabbelt.com> wrote:
> 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): Set fx_frag and
>         fx_next->fx_frag for CFA_advance_loc relocations.

As this appears to recur - may I please ask that for patches which
can't otherwise be identified to affect a certain architecture only
(instead of common code), you name that architecture in the patch
title (e.g. by a prefix to the subject) or include it in a marker
similar to [PATCH]?

Thanks, Jan

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 2/3] Fix DW_CFA_advance_loc relocation.
  2017-03-14 10:55   ` Jan Beulich
@ 2017-03-14 16:18     ` Palmer Dabbelt
  0 siblings, 0 replies; 10+ messages in thread
From: Palmer Dabbelt @ 2017-03-14 16:18 UTC (permalink / raw)
  To: JBeulich; +Cc: rufus, binutils

On Tue, 14 Mar 2017 03:55:25 PDT (-0700), JBeulich@suse.com wrote:
>>>> On 13.03.17 at 22:47, <palmer@dabbelt.com> wrote:
>> 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): Set fx_frag and
>>         fx_next->fx_frag for CFA_advance_loc relocations.
>
> As this appears to recur - may I please ask that for patches which
> can't otherwise be identified to affect a certain architecture only
> (instead of common code), you name that architecture in the patch
> title (e.g. by a prefix to the subject) or include it in a marker
> similar to [PATCH]?

Sorry about that, I'll be sure to tag our stuff with RISC-V in the future.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Fix RISC-V CFA relocations
  2017-03-13 21:48 Fix RISC-V CFA relocations Palmer Dabbelt
                   ` (2 preceding siblings ...)
  2017-03-13 21:48 ` [PATCH 3/3] Define DWARF2_USE_FIXED_ADVANCE_PC Palmer Dabbelt
@ 2017-03-14 17:01 ` Palmer Dabbelt
  3 siblings, 0 replies; 10+ messages in thread
From: Palmer Dabbelt @ 2017-03-14 17:01 UTC (permalink / raw)
  To: binutils

On Mon, 13 Mar 2017 14:47:50 PDT (-0700), Palmer Dabbelt wrote:
> Without this patch set we don't correctly compute CFA relocation offsets, which
> means debug info is broken on RISC-V.
>
> [PATCH 1/3] Fix the offset of CFA relocation.
> [PATCH 2/3] Fix DW_CFA_advance_loc relocation.
> [PATCH 3/3] Define DWARF2_USE_FIXED_ADVANCE_PC.

Committed.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 1/3] Fix the offset of CFA relocation.
  2017-03-13 21:48 ` [PATCH 1/3] Fix the offset of CFA relocation Palmer Dabbelt
@ 2017-03-15  9:27   ` Nick Clifton
  0 siblings, 0 replies; 10+ messages in thread
From: Nick Clifton @ 2017-03-15  9:27 UTC (permalink / raw)
  To: Palmer Dabbelt, binutils; +Cc: Kuan-Lin Chen

Hi Palmer,

> 2017-03-02  Kuan-Lin Chen  <rufus@andestech.com>
> 
>         * config/tc-riscv.c (md_apply_fix): Compute the correct offsets
>         for CFA relocations.

Approved - please apply.

Cheers
  Nick

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 2/3] Fix DW_CFA_advance_loc relocation.
  2017-03-13 21:48 ` [PATCH 2/3] Fix DW_CFA_advance_loc relocation Palmer Dabbelt
  2017-03-14 10:55   ` Jan Beulich
@ 2017-03-15  9:27   ` Nick Clifton
  1 sibling, 0 replies; 10+ messages in thread
From: Nick Clifton @ 2017-03-15  9:27 UTC (permalink / raw)
  To: Palmer Dabbelt, binutils; +Cc: Kuan-Lin Chen

Hi Palmer,

> 2017-03-02  Kuan-Lin Chen  <rufus@andestech.com>
> 
>         * config/tc-riscv.c (md_apply_fix): Set fx_frag and
>         fx_next->fx_frag for CFA_advance_loc relocations.

Approved - please apply.

Cheers
  Nick

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 3/3] Define DWARF2_USE_FIXED_ADVANCE_PC.
  2017-03-13 21:48 ` [PATCH 3/3] Define DWARF2_USE_FIXED_ADVANCE_PC Palmer Dabbelt
@ 2017-03-15  9:28   ` Nick Clifton
  0 siblings, 0 replies; 10+ messages in thread
From: Nick Clifton @ 2017-03-15  9:28 UTC (permalink / raw)
  To: Palmer Dabbelt, binutils; +Cc: Kuan-Lin Chen

Hi Palmer,

> 2017-03-02  Kuan-Lin Chen  <rufus@andestech.com>
> 
>         * config/tc-riscv.h (HWARD2_USE_FIXED_ADVANCE_PC): New define.

Approved - please apply.

Cheers
  Nick


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2017-03-15  9:28 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-13 21:48 Fix RISC-V CFA relocations Palmer Dabbelt
2017-03-13 21:48 ` [PATCH 1/3] Fix the offset of CFA relocation Palmer Dabbelt
2017-03-15  9:27   ` Nick Clifton
2017-03-13 21:48 ` [PATCH 2/3] Fix DW_CFA_advance_loc relocation Palmer Dabbelt
2017-03-14 10:55   ` Jan Beulich
2017-03-14 16:18     ` Palmer Dabbelt
2017-03-15  9:27   ` Nick Clifton
2017-03-13 21:48 ` [PATCH 3/3] Define DWARF2_USE_FIXED_ADVANCE_PC Palmer Dabbelt
2017-03-15  9:28   ` Nick Clifton
2017-03-14 17:01 ` Fix RISC-V CFA relocations Palmer Dabbelt

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).