public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] nios2: Disable assembler debug info for --gdwarf-5
@ 2021-01-25 21:19 H.J. Lu
  2021-01-26 12:51 ` [PATCH] nios2: Don't disable relaxation with --gdwarf-N H.J. Lu
  0 siblings, 1 reply; 3+ messages in thread
From: H.J. Lu @ 2021-01-25 21:19 UTC (permalink / raw)
  To: binutils; +Cc: Sandra Loosemore, Andrew Jenner

After

commit 705989f19adf20dd70c50237ec61cd708f2b0939
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Mon Jan 18 06:25:05 2021 -0800

    as: Automatically enable DWARF5 support

--gdwarf-5 is no longer needed to accept DWARF5 info generated by GCC.

Since assembler generated debug information is incompatible with
relaxation, don't generate debug information for assembly codes with
--gdwarf-5 which is passed down by GCC.

OK for master and 2.36 branch?

H.J.
---
	PR gas/27243
	* config/tc-nios2.c (md_begin): Set debug_type to DEBUG_UNSPECIFIED
	for --gdwarf-5.
	* testsuite/gas/nios2/relax.d: New file.
	* testsuite/gas/nios2/relax.s: Likewise.

diff --git a/gas/config/tc-nios2.c b/gas/config/tc-nios2.c
index eea6687fcc4..5686976a4d3 100644
--- a/gas/config/tc-nios2.c
+++ b/gas/config/tc-nios2.c
@@ -3643,9 +3643,11 @@ md_begin (void)
   nios2_as_options.noat = FALSE;
   nios2_as_options.nobreak = FALSE;
 
-  /* Debug information is incompatible with relaxation.  */
-  if (debug_type != DEBUG_UNSPECIFIED)
-    nios2_as_options.relax = relax_none;
+  /* NB: Since assembler generated debug information is incompatible
+     with relaxation, don't generate debug information for assembly
+     codes with --gdwarf-5 which is passed down by GCC.  */
+  if (debug_type != DEBUG_UNSPECIFIED && dwarf_level >= 5)
+  debug_type = DEBUG_UNSPECIFIED;
 
   /* Initialize the alignment data.  */
   nios2_current_align_seg = now_seg;
diff --git a/gas/testsuite/gas/elf/dwarf-5-nop-for-line-table.d b/gas/testsuite/gas/elf/dwarf-5-nop-for-line-table.d
index 651a1a20707..364a1a8c94a 100644
--- a/gas/testsuite/gas/elf/dwarf-5-nop-for-line-table.d
+++ b/gas/testsuite/gas/elf/dwarf-5-nop-for-line-table.d
@@ -1,6 +1,8 @@
 #as: --gdwarf-5
 #name: Check line table is produced with .nops
 #readelf: -wL
+# --gdwarf-5 is ignored on nios2 since it is incompatible with relaxation.
+#xfail: nios2-*
 
 #...
 Contents of the .debug_line section:
diff --git a/gas/testsuite/gas/nios2/relax.d b/gas/testsuite/gas/nios2/relax.d
new file mode 100644
index 00000000000..ae9b3bd917e
--- /dev/null
+++ b/gas/testsuite/gas/nios2/relax.d
@@ -0,0 +1,16 @@
+#as: --gdwarf-5
+#objdump: -dr --prefix-addresses --show-raw-insn
+#name: NIOS2 relax with --gdwarf-5
+
+# Test the branch instructions.
+.*:     file format elf32-littlenios2
+
+Disassembly of section .text:
+0x00000000 21400526 	beq	r4,r5,0x00000018
+0x00000004 0002e03a 	nextpc	at
+0x00000008 085fffc4 	addi	at,at,32767
+0x0000000c 085fffc4 	addi	at,at,32767
+0x00000010 08400484 	addi	at,at,18
+0x00000014 0800683a 	jmp	at
+	...
+0x00010018 f800283a 	ret
diff --git a/gas/testsuite/gas/nios2/relax.s b/gas/testsuite/gas/nios2/relax.s
new file mode 100644
index 00000000000..ef417fdc33b
--- /dev/null
+++ b/gas/testsuite/gas/nios2/relax.s
@@ -0,0 +1,5 @@
+	.text
+	bne	r4, r5, 1f
+	.zero 0x10000
+1:
+	ret
-- 
2.29.2


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

* [PATCH] nios2: Don't disable relaxation with --gdwarf-N
  2021-01-25 21:19 [PATCH] nios2: Disable assembler debug info for --gdwarf-5 H.J. Lu
@ 2021-01-26 12:51 ` H.J. Lu
  2021-01-26 16:16   ` Sandra Loosemore
  0 siblings, 1 reply; 3+ messages in thread
From: H.J. Lu @ 2021-01-26 12:51 UTC (permalink / raw)
  To: Binutils; +Cc: Sandra Loosemore, Andrew Jenner

[-- Attachment #1: Type: text/plain, Size: 1082 bytes --]

On Mon, Jan 25, 2021 at 1:19 PM H.J. Lu <hjl.tools@gmail.com> wrote:
>
> After
>
> commit 705989f19adf20dd70c50237ec61cd708f2b0939
> Author: H.J. Lu <hjl.tools@gmail.com>
> Date:   Mon Jan 18 06:25:05 2021 -0800
>
>     as: Automatically enable DWARF5 support
>
> --gdwarf-5 is no longer needed to accept DWARF5 info generated by GCC.
>
> Since assembler generated debug information is incompatible with
> relaxation, don't generate debug information for assembly codes with
> --gdwarf-5 which is passed down by GCC.
>
> OK for master and 2.36 branch?
>
> H.J.
> ---
>         PR gas/27243
>         * config/tc-nios2.c (md_begin): Set debug_type to DEBUG_UNSPECIFIED
>         for --gdwarf-5.
>         * testsuite/gas/nios2/relax.d: New file.
>         * testsuite/gas/nios2/relax.s: Likewise.

GCC 11 passes --gdwarf-5 to assembler to enable DWARF5 debug info.  Don't
disable relaxation when --gdwarf-N is specified.  The assembler generated
debug information will treat the sequence of the relaxed instructions as
a single instruction.

OK for master and 2.36 branch?

-- 
H.J.

[-- Attachment #2: 0001-nios2-Don-t-disable-relaxation-with-gdwarf-N.patch --]
[-- Type: text/x-patch, Size: 2607 bytes --]

From d39a3002bdec4e71fa6f68b505c9cb0579821776 Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
Date: Mon, 25 Jan 2021 13:14:34 -0800
Subject: [PATCH] nios2: Don't disable relaxation with --gdwarf-N

GCC 11 passes --gdwarf-5 to assembler to enable DWARF5 debug info.  Don't
disable relaxation when --gdwarf-N is specified.  The assembler generated
debug information will treat the sequence of the relaxed instructions as
a single instruction.

	PR gas/27243
	* config/tc-nios2.c (md_begin): Don't disable relaxation with
	--gdwarf-N.
	* testsuite/gas/nios2/relax.d: New file.
	* testsuite/gas/nios2/relax.s: Likewise.
---
 gas/config/tc-nios2.c           |  4 ----
 gas/testsuite/gas/nios2/relax.d | 25 +++++++++++++++++++++++++
 gas/testsuite/gas/nios2/relax.s |  5 +++++
 3 files changed, 30 insertions(+), 4 deletions(-)
 create mode 100644 gas/testsuite/gas/nios2/relax.d
 create mode 100644 gas/testsuite/gas/nios2/relax.s

diff --git a/gas/config/tc-nios2.c b/gas/config/tc-nios2.c
index eea6687fcc4..be4536caa8a 100644
--- a/gas/config/tc-nios2.c
+++ b/gas/config/tc-nios2.c
@@ -3643,10 +3643,6 @@ md_begin (void)
   nios2_as_options.noat = FALSE;
   nios2_as_options.nobreak = FALSE;
 
-  /* Debug information is incompatible with relaxation.  */
-  if (debug_type != DEBUG_UNSPECIFIED)
-    nios2_as_options.relax = relax_none;
-
   /* Initialize the alignment data.  */
   nios2_current_align_seg = now_seg;
   nios2_last_label = NULL;
diff --git a/gas/testsuite/gas/nios2/relax.d b/gas/testsuite/gas/nios2/relax.d
new file mode 100644
index 00000000000..ca01a4f926a
--- /dev/null
+++ b/gas/testsuite/gas/nios2/relax.d
@@ -0,0 +1,25 @@
+#source: relax.s
+#as: --gdwarf-5
+#objdump: -w -WL -dr --prefix-addresses --show-raw-insn
+#name: NIOS2 relax with --gdwarf-5
+
+# Test relaxation with assembler generated debug info.
+.*:     file format elf32-littlenios2
+
+Contents of the .debug_line section:
+
+CU: ./relax.s:
+File +name +Line +number +Starting +address +View +Stmt
+relax.s +2 +0 +x
+relax.s +5 +0x10018 +x
+relax.s +- +0x1001c
+
+Disassembly of section .text:
+0x00000000 21400526 	beq	r4,r5,0x00000018
+0x00000004 0002e03a 	nextpc	at
+0x00000008 085fffc4 	addi	at,at,32767
+0x0000000c 085fffc4 	addi	at,at,32767
+0x00000010 08400484 	addi	at,at,18
+0x00000014 0800683a 	jmp	at
+	...
+0x00010018 f800283a 	ret
diff --git a/gas/testsuite/gas/nios2/relax.s b/gas/testsuite/gas/nios2/relax.s
new file mode 100644
index 00000000000..ef417fdc33b
--- /dev/null
+++ b/gas/testsuite/gas/nios2/relax.s
@@ -0,0 +1,5 @@
+	.text
+	bne	r4, r5, 1f
+	.zero 0x10000
+1:
+	ret
-- 
2.29.2


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

* Re: [PATCH] nios2: Don't disable relaxation with --gdwarf-N
  2021-01-26 12:51 ` [PATCH] nios2: Don't disable relaxation with --gdwarf-N H.J. Lu
@ 2021-01-26 16:16   ` Sandra Loosemore
  0 siblings, 0 replies; 3+ messages in thread
From: Sandra Loosemore @ 2021-01-26 16:16 UTC (permalink / raw)
  To: H.J. Lu, Binutils

On 1/26/21 5:51 AM, H.J. Lu wrote:
> On Mon, Jan 25, 2021 at 1:19 PM H.J. Lu <hjl.tools@gmail.com> wrote:
>>
>> After
>>
>> commit 705989f19adf20dd70c50237ec61cd708f2b0939
>> Author: H.J. Lu <hjl.tools@gmail.com>
>> Date:   Mon Jan 18 06:25:05 2021 -0800
>>
>>      as: Automatically enable DWARF5 support
>>
>> --gdwarf-5 is no longer needed to accept DWARF5 info generated by GCC.
>>
>> Since assembler generated debug information is incompatible with
>> relaxation, don't generate debug information for assembly codes with
>> --gdwarf-5 which is passed down by GCC.
>>
>> OK for master and 2.36 branch?
>>
>> H.J.
>> ---
>>          PR gas/27243
>>          * config/tc-nios2.c (md_begin): Set debug_type to DEBUG_UNSPECIFIED
>>          for --gdwarf-5.
>>          * testsuite/gas/nios2/relax.d: New file.
>>          * testsuite/gas/nios2/relax.s: Likewise.
> 
> GCC 11 passes --gdwarf-5 to assembler to enable DWARF5 debug info.  Don't
> disable relaxation when --gdwarf-N is specified.  The assembler generated
> debug information will treat the sequence of the relaxed instructions as
> a single instruction.
> 
> OK for master and 2.36 branch?

This is OK.  I tested the same tweak overnight, gas and gcc test results 
look reasonable with no Dwarf-related failures, and I also convinced 
myself through manual inspection that the line number table is being 
adjusted properly for the relaxation code sequences.

-Sandra

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

end of thread, other threads:[~2021-01-26 16:16 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-25 21:19 [PATCH] nios2: Disable assembler debug info for --gdwarf-5 H.J. Lu
2021-01-26 12:51 ` [PATCH] nios2: Don't disable relaxation with --gdwarf-N H.J. Lu
2021-01-26 16:16   ` Sandra Loosemore

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