public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Jan Beulich <jbeulich@suse.com>
To: Binutils <binutils@sourceware.org>
Subject: [PATCH 3/6] gas: don't ignore .linefile inside false conditionals
Date: Fri, 6 May 2022 08:06:32 +0200	[thread overview]
Message-ID: <58fbd8a8-b6b4-ee39-bbc1-dc351e122c13@suse.com> (raw)
In-Reply-To: <e96f677b-acf7-e5a9-e99e-48ae61a20da8@suse.com>

When assembling code previously pre-processed by a C compiler, long
enough comments may have been collapsed into "# <line> <file>"
constructs. If we skip these, line numbers (and possibly even file
names) will be off / wrong in both diagnostics and debug info.

--- a/gas/cond.c
+++ b/gas/cond.c
@@ -525,6 +525,10 @@ ignore_input (void)
 	  || !strncasecmp (s, "endc", 4))
 	return 0;
       break;
+    case 'l': case 'L':
+      if (!strncasecmp (s, "linefile", 8))
+	return 0;
+      break;
     }
 
   return (current_cframe != NULL) && (current_cframe->ignoring);
--- /dev/null
+++ b/gas/testsuite/gas/all/cond-2.l
@@ -0,0 +1,12 @@
+# This should match the output of gas -al cond-2.s.
+.*: Assembler messages:
+.*:1005: Warning: line 5
+.*cond-2.s.*
+
+
+[ 	]*[1-9][0-9]*[ 	]+\.if[ 	]+0[ 	]*
+[ 	]*[1-9][0-9]*[ 	]+# 1003 "cond-2\.s"
+[ 	]*[1-9][0-9]*[ 	]+\.endif[ 	]*
+[ 	]*[1-9][0-9]*[ 	]*
+[ 	]*[1-9][0-9]*[ 	]+\.warning[ 	].*
+#pass
--- /dev/null
+++ b/gas/testsuite/gas/all/cond-2.s
@@ -0,0 +1,5 @@
+	.if 0
+# 1003 "cond-2.s"
+	.endif
+
+	.warning "line 5"
--- a/gas/testsuite/gas/all/gas.exp
+++ b/gas/testsuite/gas/all/gas.exp
@@ -466,6 +466,11 @@ if [is_elf_format] {
 
 run_dump_test quoted-sym-names
 
+# Targets where # is not a line comment character don't transform
+# "# <line> <file>" into .linefile (PR gas/29120).
+setup_xfail "tic30-*-*"
+run_list_test cond-2 "-al"
+
 run_list_test macro "-alm"
 
 run_list_test pr20312


  parent reply	other threads:[~2022-05-06  6:06 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-06  6:04 [PATCH 0/6] gas: (mostly) further file/line handling adjustments Jan Beulich
2022-05-06  6:05 ` [PATCH 1/6] gas: tweak .irp and alike file/line handling for M68K/MRI Jan Beulich
2022-05-06  6:06 ` [PATCH 2/6] gas: simplify ignore_input() Jan Beulich
2022-05-06  6:06 ` Jan Beulich [this message]
2022-05-06  6:07 ` [PATCH 4/6] gas: fold do_repeat{,_with_expander}() Jan Beulich
2022-05-06  6:08 ` [PATCH 5/6] gas: avoid bignum related errors when processing .linefile Jan Beulich
2022-05-06  6:08 ` [PATCH 6/6] gas: avoid octal numbers being accepted " Jan Beulich

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=58fbd8a8-b6b4-ee39-bbc1-dc351e122c13@suse.com \
    --to=jbeulich@suse.com \
    --cc=binutils@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).