aboutsummaryrefslogtreecommitdiff
path: root/gas
diff options
context:
space:
mode:
authorJan Beulich <jbeulich@suse.com>2023-10-23 10:36:36 +0200
committerJan Beulich <jbeulich@suse.com>2023-10-23 10:36:36 +0200
commita0094f1a70e1d5a7a8124e7c988fc1ddd1886f19 (patch)
treed6e8add33de5a9eeed47a75f544e4f196dcdb3d2 /gas
parentc69011e9533ec2b26b4983badcffdab807a2d754 (diff)
downloadgdb-a0094f1a70e1d5a7a8124e7c988fc1ddd1886f19.zip
gdb-a0094f1a70e1d5a7a8124e7c988fc1ddd1886f19.tar.gz
gdb-a0094f1a70e1d5a7a8124e7c988fc1ddd1886f19.tar.bz2
gas: make .nops output visible in listing
Due to using a different frag type (in turn due to storing data differently), making the resulting code appear in listings requires special handling.
Diffstat (limited to 'gas')
-rw-r--r--gas/as.h4
-rw-r--r--gas/listing.c22
-rw-r--r--gas/testsuite/gas/i386/i386.exp1
-rw-r--r--gas/testsuite/gas/i386/nop-1.l39
-rw-r--r--gas/write.c7
5 files changed, 71 insertions, 2 deletions
diff --git a/gas/as.h b/gas/as.h
index 99ffe77..46dd0d0 100644
--- a/gas/as.h
+++ b/gas/as.h
@@ -247,7 +247,9 @@ enum _relax_state
1 constant byte: no-op fill control byte. */
rs_space_nop,
- /* Similar to rs_fill. It is used to implement .nop directive . */
+ /* Similar to rs_fill. It is used to implement .nops directive.
+ When listings are enabled, fr_opcode gets the buffer assigned, once
+ that's available. */
rs_fill_nop,
/* A DWARF leb128 value; only ELF uses this. The subtype is 0 for
diff --git a/gas/listing.c b/gas/listing.c
index 54fedbb..00ec9ca 100644
--- a/gas/listing.c
+++ b/gas/listing.c
@@ -815,6 +815,28 @@ calc_hex (list_info_type *list)
var_rep_idx = var_rep_max;
}
}
+ 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. */
+ while (octet_in_frag < (unsigned int) frag_ptr->fr_offset
+ && data_buffer_size < MAX_BYTES - 3)
+ {
+ if (address == ~(unsigned int) 0)
+ address = frag_ptr->fr_address / OCTETS_PER_BYTE;
+
+ sprintf (data_buffer + data_buffer_size,
+ "%02X",
+ frag_ptr->fr_opcode[octet_in_frag] & 0xff);
+ data_buffer_size += 2;
+
+ octet_in_frag++;
+ }
+
+ free (frag_ptr->fr_opcode);
+ frag_ptr->fr_opcode = NULL;
+ }
frag_ptr = frag_ptr->fr_next;
}
diff --git a/gas/testsuite/gas/i386/i386.exp b/gas/testsuite/gas/i386/i386.exp
index 1072c07..1d9e297 100644
--- a/gas/testsuite/gas/i386/i386.exp
+++ b/gas/testsuite/gas/i386/i386.exp
@@ -598,6 +598,7 @@ if [gas_32_check] then {
run_list_test "inval-pseudo" "-al"
run_dump_test "nop-1"
run_dump_test "nop-1-suffix"
+ run_list_test "nop-1" "-aln"
run_dump_test "nop-2"
run_dump_test "optimize-1"
run_dump_test "optimize-1a"
diff --git a/gas/testsuite/gas/i386/nop-1.l b/gas/testsuite/gas/i386/nop-1.l
new file mode 100644
index 0000000..a818708
--- /dev/null
+++ b/gas/testsuite/gas/i386/nop-1.l
@@ -0,0 +1,39 @@
+[ ]*[0-9]+[ ]+\.text
+[ ]*[0-9]+[ ]+single:
+[ ]*[0-9]+[ ]+\.nops 0
+[ ]*[0-9]+[ ]+.... 90[ ]+nop
+[ ]*[0-9]+[ ]*
+[ ]*[0-9]+[ ]+pseudo_1:
+[ ]*[0-9]+[ ]+.... 90[ ]+\.nops 1
+[ ]*[0-9]+[ ]*
+[ ]*[0-9]+[ ]+pseudo_8:
+[ ]*[0-9]+[ ]+.... 2E8DB426[ ]+\.nops 8
+[ ]*[0-9]+[ ]+00000000 *
+[ ]*[0-9]+[ ]*
+[ ]*[0-9]+[ ]+pseudo_8_4:
+[ ]*[0-9]+[ ]+.... 8D742600[ ]+\.nops 8, 4
+[ ]*[0-9]+[ ]+8D742600 *
+[ ]*[0-9]+[ ]*
+[ ]*[0-9]+[ ]+pseudo_20:
+[ ]*[0-9]+[ ]+.... 2E8DB426[ ]+\.nops 20
+[ ]*[0-9]+[ ]+00000000 *
+[ ]*[0-9]+[ ]+2E8DB426 *
+[ ]*[0-9]+[ ]+00000000 *
+[ ]*[0-9]+[ ]+8D742600 *
+[ ]*[0-9]+[ ]*
+[ ]*[0-9]+[ ]+pseudo_30:
+[ ]*[0-9]+[ ]+.... EB1C2E8D[ ]+\.nops 30
+[ ]*[0-9]+[ ]+B4260000 *
+[ ]*[0-9]+[ ]+00002E8D *
+[ ]*[0-9]+[ ]+B4260000 *
+[ ]*[0-9]+[ ]+00002E8D *
+[ ]*[0-9]+[ ]*
+[ ]*[0-9]+[ ]+pseudo_129:
+[ ]*[0-9]+[ ]+.... EB7F2E8D[ ]+\.nops 129
+[ ]*[0-9]+[ ]+B4260000 *
+[ ]*[0-9]+[ ]+00002E8D *
+[ ]*[0-9]+[ ]+B4260000 *
+[ ]*[0-9]+[ ]+00002E8D *
+[ ]*[0-9]+[ ]*
+[ ]*[0-9]+[ ]+end:
+#pass
diff --git a/gas/write.c b/gas/write.c
index 573a667..20ba3f8 100644
--- a/gas/write.c
+++ b/gas/write.c
@@ -1682,7 +1682,12 @@ write_contents (bfd *abfd ATTRIBUTE_UNUSED,
bfd_get_filename (stdoutput),
bfd_errmsg (bfd_get_error ()));
offset += count;
- free (buf);
+#ifndef NO_LISTING
+ if (listing & LISTING_LISTING)
+ f->fr_opcode = buf;
+ else
+#endif
+ free (buf);
}
continue;
}