[PATCH] nios2: Disable assembler debug info for --gdwarf-5
H.J. Lu
hjl.tools@gmail.com
Mon Jan 25 21:19:19 GMT 2021
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
More information about the Binutils
mailing list