]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gas: fix rs_fill_nop listing
authorJan Beulich <jbeulich@suse.com>
Fri, 14 Feb 2025 08:33:18 +0000 (09:33 +0100)
committerJan Beulich <jbeulich@suse.com>
Fri, 14 Feb 2025 09:03:35 +0000 (10:03 +0100)
In commit a0094f1a70e1 ("gas: make .nops output visible in listing") I
was wrongly assuming fr_fix would be zero for rs_fill_nop, when that's
only a side effect of listing_newline() inserting dummy frags, but only
when file/line did actually change from the previous invocation. This is
in particular not going to be true when the .nops directive isn't the
first statement on a line.

gas/listing.c
gas/testsuite/gas/i386/i386.exp
gas/testsuite/gas/i386/nop-7.l [new file with mode: 0644]
gas/testsuite/gas/i386/nop-7.s [new file with mode: 0644]

index ebe5ff5bdf0c880e8639b20e3dd24b19ed72a20e..43a7fdf86b2dcce7171c1e2d35298c09d54e3aa0 100644 (file)
@@ -820,9 +820,8 @@ calc_hex (list_info_type *list)
        }
       else if (frag_ptr->fr_type == rs_fill_nop && frag_ptr->fr_opcode)
        {
-         gas_assert (!octet_in_frag);
-
          /* Print as many bytes from fr_opcode as is sensible.  */
+         octet_in_frag = 0;
          while (octet_in_frag < (unsigned int) frag_ptr->fr_offset
                 && data_buffer_size < MAX_BYTES - 3)
            {
index b4d33cc7500300605715521e8d5b5f491c843c14..09d4dc94afe2f1adf1d46828889a6bf0e42fad32 100644 (file)
@@ -637,6 +637,7 @@ if [gas_32_check] then {
     run_dump_test "nop-1-suffix"
     run_list_test "nop-1" "-aln"
     run_dump_test "nop-2"
+    run_list_test "nop-7" "-aln"
     run_dump_test "optimize-1"
     run_dump_test "optimize-1a"
     run_dump_test "optimize-2"
diff --git a/gas/testsuite/gas/i386/nop-7.l b/gas/testsuite/gas/i386/nop-7.l
new file mode 100644 (file)
index 0000000..2a74137
--- /dev/null
@@ -0,0 +1,6 @@
+[      ]*[0-9]+[       ]+\.text
+[      ]*[0-9]+[       ]+nops:
+[      ]*[0-9]+[       ]+.... F88D7426[        ]+clc; \.nops 4; stc
+[      ]*[0-9]+[       ]+00F9
+[      ]*[0-9]+[       ]+.... C3[      ]+ret
+#pass
diff --git a/gas/testsuite/gas/i386/nop-7.s b/gas/testsuite/gas/i386/nop-7.s
new file mode 100644 (file)
index 0000000..8018f21
--- /dev/null
@@ -0,0 +1,6 @@
+       .text
+nops:
+       clc; .nops 4; stc
+       ret
+
+       .end