From: Alan Modra Date: Tue, 21 Sep 2021 23:34:00 +0000 (+0930) Subject: dwarf2 sub-section test X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=cf11ebea1206a7c459a94fef8e0880087dd9f38f;p=binutils-gdb.git dwarf2 sub-section test 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. --- diff --git a/gas/config/tc-ia64.c b/gas/config/tc-ia64.c index 4fc0c5610dc..4fa7f767f12 100644 --- a/gas/config/tc-ia64.c +++ b/gas/config/tc-ia64.c @@ -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 (¬es, 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 index 00000000000..16fa317be66 --- /dev/null +++ b/gas/testsuite/gas/elf/dwarf2-21.d @@ -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 index 00000000000..8c91043a054 --- /dev/null +++ b/gas/testsuite/gas/elf/dwarf2-21.s @@ -0,0 +1,8 @@ + .text + .nop 16 + .text 1 + .nop 16 + .text 3 + .nop 16 + .text 2 + .nop 16 diff --git a/gas/testsuite/gas/elf/elf.exp b/gas/testsuite/gas/elf/elf.exp index 2485008d569..ab862640974 100644 --- a/gas/testsuite/gas/elf/elf.exp +++ b/gas/testsuite/gas/elf/elf.exp @@ -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