From 058430b4a1ed7441dfc2e167bfdb9dc89ea9a209 Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Tue, 17 Nov 2020 12:41:36 +1030 Subject: Re: Stop Gas from generating line info or address ranges * doc/as.texi (.nop): Document optional size arg. * dwarf2dbg.c (dwarf2_gen_line_info_1): Only check SEC_ALLOC when ELF. Warn whenever dwarf line number information is ignored. * frags.c (frag_offset_ignore_align_p): New function. * frags.h (frag_offset_ignore_align_p): Declare. * read.c (s_nop): Extend to support optional size arg. * testsuite/gas/elf/dwarf2-20.d: Expect warnings, and exact range. * testsuite/gas/elf/dwarf2-20.s: Emit 16 bytes worth of nops. * testsuite/gas/m68hc11/indexed12.d: Expect warnings. --- gas/read.c | 46 ++++++++++++++++++++++++++++++++-------------- 1 file changed, 32 insertions(+), 14 deletions(-) (limited to 'gas/read.c') diff --git a/gas/read.c b/gas/read.c index 9ba61cd..a4c6e4e 100644 --- a/gas/read.c +++ b/gas/read.c @@ -3506,6 +3506,11 @@ s_space (int mult) void s_nop (int ignore ATTRIBUTE_UNUSED) { + expressionS exp; + fragS *start; + addressT start_off; + offsetT frag_off; + #ifdef md_flush_pending_output md_flush_pending_output (); #endif @@ -3515,29 +3520,42 @@ s_nop (int ignore ATTRIBUTE_UNUSED) #endif SKIP_WHITESPACE (); + expression (&exp); demand_empty_rest_of_line (); + start = frag_now; + start_off = frag_now_fix (); + do + { #ifdef md_emit_single_noop - md_emit_single_noop; + md_emit_single_noop; #else - char * nop; + char *nop; #ifndef md_single_noop_insn #define md_single_noop_insn "nop" #endif - /* md_assemble might modify its argument, so - we must pass it a string that is writeable. */ - if (asprintf (&nop, "%s", md_single_noop_insn) < 0) - as_fatal ("%s", xstrerror (errno)); - - /* Some targets assume that they can update input_line_pointer inside - md_assemble, and, worse, that they can leave it assigned to the string - pointer that was provided as an argument. So preserve ilp here. */ - char * saved_ilp = input_line_pointer; - md_assemble (nop); - input_line_pointer = saved_ilp; - free (nop); + /* md_assemble might modify its argument, so + we must pass it a string that is writable. */ + if (asprintf (&nop, "%s", md_single_noop_insn) < 0) + as_fatal ("%s", xstrerror (errno)); + + /* Some targets assume that they can update input_line_pointer + inside md_assemble, and, worse, that they can leave it + assigned to the string pointer that was provided as an + argument. So preserve ilp here. */ + char *saved_ilp = input_line_pointer; + md_assemble (nop); + input_line_pointer = saved_ilp; + free (nop); +#endif +#ifdef md_flush_pending_output + md_flush_pending_output (); #endif + } while (exp.X_op == O_constant + && exp.X_add_number > 0 + && frag_offset_ignore_align_p (start, frag_now, &frag_off) + && frag_off + frag_now_fix () < start_off + exp.X_add_number); } void -- cgit v1.1