gas: Improve file name in messages header

Message output from gas is prefixed with a line of the form:

path/file.s: Assembler messages:

Don't use the file name from the first message for this header.
Instead, use the source file name specified in the command line.
This commit is contained in:
Alice Carlotti
2025-08-07 16:58:20 +01:00
parent 5e83077d55
commit 40acf2f9ae
7 changed files with 33 additions and 13 deletions

View File

@@ -500,6 +500,7 @@ PRINTF_WHERE_LIKE (as_bad_where);
PRINTF_WHERE_LIKE (as_warn_where);
PRINTF_INDENT_LIKE (as_info_where);
void set_identify_name (const char *);
void as_abort (const char *, int, const char *) ATTRIBUTE_NORETURN;
void signal_init (void);
int had_errors (void);

View File

@@ -27,7 +27,6 @@
extern const char *strsignal (int);
#endif
static void identify (const char *);
static void as_show_where (void);
static void as_warn_internal (const char *, unsigned int, char *);
static void as_bad_internal (const char *, unsigned int, char *);
@@ -72,8 +71,16 @@ static void signal_crash (int) ATTRIBUTE_NORETURN;
as_abort () is used for logic failure (assert or abort, signal).
*/
static const char *ident_name;
void
set_identify_name (const char *name)
{
ident_name = name;
}
static void
identify (const char *file)
identify (void)
{
static int identified;
@@ -81,14 +88,8 @@ identify (const char *file)
return;
identified++;
if (!file)
{
unsigned int x;
file = as_where (&x);
}
if (file)
fprintf (stderr, "%s: ", file);
if (ident_name && *ident_name)
fprintf (stderr, "%s: ", ident_name);
fprintf (stderr, _("Assembler messages:\n"));
}
@@ -121,7 +122,7 @@ as_show_where (void)
unsigned int line;
file = as_where_top (&line);
identify (file);
identify ();
if (file)
{
if (line != 0)
@@ -185,7 +186,7 @@ as_warn_internal (const char *file, unsigned int line, char *buffer)
context = true;
}
identify (file);
identify ();
if (file)
{
if (line != 0)
@@ -259,7 +260,7 @@ as_bad_internal (const char *file, unsigned int line, char *buffer)
context = true;
}
identify (file);
identify ();
if (file)
{
if (line != 0)

View File

@@ -895,6 +895,8 @@ read_a_source_file (const char *name)
found_comment = 0;
#endif
set_identify_name (name);
buffer = input_scrub_new_file (name);
listing_file (name);

View File

@@ -340,6 +340,8 @@ if { [is_elf_format] } then {
run_list_test line
}
run_list_test "line2" -I${srcdir}/$subdir
run_dump_test "pr25917"
run_dump_test "bss"
# Some targets treat .bss similar to .lcomm.

View File

@@ -0,0 +1,6 @@
.macro mac
.warning "inside macro"
.nop
.endm
mac

View File

@@ -0,0 +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\.s:3: Info: macro invoked from here

View File

@@ -0,0 +1,3 @@
.include "line2.inc"
mac