dwarf2 sub-section test
authorAlan Modra <amodra@gmail.com>
Tue, 21 Sep 2021 23:34:00 +0000 (09:04 +0930)
committerAlan Modra <amodra@gmail.com>
Wed, 22 Sep 2021 00:54:05 +0000 (10:24 +0930)
This is a testcase for the bug fixed by commit 5b4846283c3d.  When
running the testcase on ia64 targets I found timeouts along with lots
of memory being consumed, due to ia64 gas not tracking text
sub-sections.  Trying to add nops for ".nop 16" in ".text 1" resulting
in them being added to subsegment 0, with no increase to subsegment 1
size.  This patch also fixes that problem.

Note that the testcase fails on ft32-elf, mn10200-elf, score-elf,
tic5x-elf, and xtensa-elf.  The first two are relocation errors, the
last three appear to be the .nop directive failing to emit the right
number of nops.  I didn't XFAIL any of them.

* config/tc-ia64.c (md): Add last_text_subseg.
(ia64_flush_insns, dot_endp): Use last_text_subseg.
(ia64_frob_label, md_assemble): Set last_text_subseg.
* testsuite/gas/elf/dwarf2-21.d,
* testsuite/gas/elf/dwarf2-21.s: New test.
* testsuite/gas/elf/elf.exp: Run it.

gas/config/tc-ia64.c
gas/testsuite/gas/elf/dwarf2-21.d [new file with mode: 0644]
gas/testsuite/gas/elf/dwarf2-21.s [new file with mode: 0644]
gas/testsuite/gas/elf/elf.exp

index 4fc0c5610dc610219439a26a5fe606ee10344451..4fa7f767f123949d4579c0254e930cfcda829c36 100644 (file)
@@ -306,6 +306,7 @@ static struct
     slot[NUM_SLOTS];
 
     segT last_text_seg;
+    subsegT last_text_subseg;
 
     struct dynreg
       {
@@ -952,7 +953,7 @@ ia64_flush_insns (void)
   saved_seg = now_seg;
   saved_subseg = now_subseg;
 
-  subseg_set (md.last_text_seg, 0);
+  subseg_set (md.last_text_seg, md.last_text_subseg);
 
   while (md.num_slots_in_use > 0)
     emit_one_bundle ();                /* force out queued instructions */
@@ -4410,7 +4411,7 @@ dot_endp (int dummy ATTRIBUTE_UNUSED)
     {
       symbolS *proc_end;
 
-      subseg_set (md.last_text_seg, 0);
+      subseg_set (md.last_text_seg, md.last_text_subseg);
       proc_end = expr_build_dot ();
 
       start_unwind_section (saved_seg, SPECIAL_SECTION_UNWIND);
@@ -7767,6 +7768,7 @@ ia64_frob_label (struct symbol *sym)
   if (bfd_section_flags (now_seg) & SEC_CODE)
     {
       md.last_text_seg = now_seg;
+      md.last_text_subseg = now_subseg;
       fix = XOBNEW (&notes, struct label_fix);
       fix->sym = sym;
       fix->next = CURR_SLOT.label_fixups;
@@ -10854,6 +10856,7 @@ md_assemble (char *str)
     insn_group_break (1, 0, 0);
 
   md.last_text_seg = now_seg;
+  md.last_text_subseg = now_subseg;
 
  done:
   input_line_pointer = saved_input_line_pointer;
diff --git a/gas/testsuite/gas/elf/dwarf2-21.d b/gas/testsuite/gas/elf/dwarf2-21.d
new file mode 100644 (file)
index 0000000..16fa317
--- /dev/null
@@ -0,0 +1,18 @@
+#name: DWARF2 21
+#as: -gdwarf-2
+#readelf: -wL
+# Note that non-zero view numbers are allowed here.  This doesn't really
+# make much sense, but DW_LNS_fixed_advance_pc is defined to not set the
+# view back to zero in contrast with all other changes in PC.  A number
+# of targets always use DW_LNS_fixed_advance_pc in their gas-generated
+# line info.
+
+Contents of the \.debug_line section:
+
+CU: (.*/elf/dwarf2-21|tmpdir/asm)\.s:
+File name +Line number +Starting address +View +Stmt
+(dwarf2-21|asm)\.s +2 +0 +x
+(dwarf2-21|asm)\.s +4 +0x10(| +1) +x
+(dwarf2-21|asm)\.s +8 +0x20(| +2) +x
+(dwarf2-21|asm)\.s +6 +0x30(| +3) +x
+(dwarf2-21|asm)\.s +- +0x40
diff --git a/gas/testsuite/gas/elf/dwarf2-21.s b/gas/testsuite/gas/elf/dwarf2-21.s
new file mode 100644 (file)
index 0000000..8c91043
--- /dev/null
@@ -0,0 +1,8 @@
+       .text
+       .nop 16
+       .text 1
+       .nop 16
+       .text 3
+       .nop 16
+       .text 2
+       .nop 16
index 2485008d56938d59925479c2411adce0694ef74b..ab86264097470ca104f613fa023002ed0e3d3bbb 100644 (file)
@@ -296,6 +296,7 @@ if { [is_elf_format] } then {
     run_dump_test "dwarf2-18" $dump_opts
     run_dump_test "dwarf2-19" $dump_opts
     run_dump_test "dwarf2-20" $dump_opts
+    run_dump_test "dwarf2-21" $dump_opts
     run_dump_test "dwarf-5-file0" $dump_opts
     run_dump_test "dwarf-5-file0-2" $dump_opts
     run_dump_test "dwarf-5-dir0" $dump_opts