[PATCH 2/2] gas: Record file name in macro locations
Jan Beulich
jbeulich@suse.com
Thu Aug 14 06:19:47 GMT 2025
On 13.08.2025 20:03, Alice Carlotti wrote:
> 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
>
> Ok for master?
>
>
> diff --git a/gas/macro.c b/gas/macro.c
> index 20309d4d68f0958839f07a85b83f47d5624750ef..13202d3f58a5e21913e47b2a5be521f92a84086d 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);
While this looks to make sense, ...
> --- 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
... I can't see why this (and other similar) change(s) are needed. Plain "line.s"
without anything ahead of it looks to be what is wanted here.
> --- 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
Perhaps also a question on patch 1 is then here as well: Why would the leading .*
be wanted here?
Jan
More information about the Binutils
mailing list