aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlice Carlotti <alice.carlotti@arm.com>2025-08-07 18:03:54 +0100
committerAlice Carlotti <alice.carlotti@arm.com>2025-08-18 14:37:10 +0100
commit9e5fdac9ac81c8bc383f4314388c2c830f1e575c (patch)
tree24d2b3ae41f5adc9f12d7abecf626710694dd7ae
parent40acf2f9ae60f8f7d1f8a20ea0086e755253007d (diff)
downloadbinutils-9e5fdac9ac81c8bc383f4314388c2c830f1e575c.zip
binutils-9e5fdac9ac81c8bc383f4314388c2c830f1e575c.tar.gz
binutils-9e5fdac9ac81c8bc383f4314388c2c830f1e575c.tar.bz2
gas: Record file name in macro locations
This allows the correct file name to be used when emitting messages for lines within a macro. The line numbers were already set and displayed correctly, which resulted in mismatched file names and line numbers. PR 32738
-rw-r--r--gas/macro.c10
-rw-r--r--gas/testsuite/gas/elf/line.l12
-rw-r--r--gas/testsuite/gas/elf/line2.l2
3 files changed, 13 insertions, 11 deletions
diff --git a/gas/macro.c b/gas/macro.c
index 20309d4..13202d3 100644
--- a/gas/macro.c
+++ b/gas/macro.c
@@ -112,11 +112,13 @@ buffer_and_nest (const char *from, const char *to, sb *ptr,
unsigned int line;
char *linefile;
- as_where_top (&line);
- if (!flag_m68k_mri)
- linefile = xasprintf ("\t.linefile %u .", line + 1);
+ const char *prefix = flag_m68k_mri ? "" : ".";
+ const char *file = as_where_top (&line);
+
+ if (file)
+ linefile = xasprintf ("\t%slinefile %u \"%s\"", prefix, line + 1, file);
else
- linefile = xasprintf ("\tlinefile %u .", line + 1);
+ linefile = xasprintf ("\t%slinefile %u .", prefix, line + 1);
sb_add_string (ptr, linefile);
xfree (linefile);
}
diff --git a/gas/testsuite/gas/elf/line.l b/gas/testsuite/gas/elf/line.l
index 37384d7..f2bc9ef 100644
--- a/gas/testsuite/gas/elf/line.l
+++ b/gas/testsuite/gas/elf/line.l
@@ -2,17 +2,17 @@
.*: Assembler messages:
line\.s:[0-9]*18: Warning: \.warning .*
-line\.s:2: Warning: m1/1: 123
+.*line\.s:2: Warning: m1/1: 123
line\.s:[0-9]*21: Info: .*
-line\.s:4: Warning: m1/2: 123
+.*line\.s:4: Warning: m1/2: 123
line\.s:[0-9]*21: Info: .*
-line\.s:2: Warning: m1/1: abc
+.*line\.s:2: Warning: m1/1: abc
line\.s:[0-9]*22: Info: .*
-line\.s:4: Warning: m1/2: abc
+.*line\.s:4: Warning: m1/2: abc
line\.s:[0-9]*22: Info: .*
-line\.s:2: Warning: m1/1: XYZ
+.*line\.s:2: Warning: m1/1: XYZ
line\.s:[0-9]*23: Info: .*
-line\.s:4: Warning: m1/2: XYZ
+.*line\.s:4: Warning: m1/2: XYZ
line\.s:[0-9]*23: Info: .*
line\.s:[0-9]*24: Warning: \.warning .*
Line2\.s:10: Warning: m2/1: 987
diff --git a/gas/testsuite/gas/elf/line2.l b/gas/testsuite/gas/elf/line2.l
index d98b74b..92627fe 100644
--- a/gas/testsuite/gas/elf/line2.l
+++ b/gas/testsuite/gas/elf/line2.l
@@ -1,5 +1,5 @@
.*line2\.s: Assembler messages:
.*line2\.inc:2: Warning: inside macro
.*line2\.inc:6: Info: macro invoked from here
-.*:2: Warning: inside macro
+.*line2\.inc:2: Warning: inside macro
.*line2\.s:3: Info: macro invoked from here