Previously, this code
extern int shl;
int get_shl(void) { return shl; }
gave errors like
$ x86_64-w64-mingw32-gcc -masm=intel test.c
ccUSyr0f.s: Assembler messages:
ccUSyr0f.s:24: Error: invalid use of operator "shl"
because it contained
.refptr.shl:
.quad shl
This `shl` should have referenced the symbol, but it appeared in an expression
context, where, in Intel syntax, it got interpreted as the shift-left operator.
This commit fixes the issue by emitting the target symbol with
`ASM_OUTPUT_LABELREF`, which will quote it properly with regard to the output
assembler syntax.
PR target/53929
gcc/ChangeLog:
* config/mingw/winnt.cc (mingw_pe_file_end): Use `ASM_OUTPUT_LABELREF`
to emit `name`.
Signed-off-by: LIU Hao <[email protected]>
---
gcc/config/mingw/winnt.cc | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/gcc/config/mingw/winnt.cc b/gcc/config/mingw/winnt.cc
index e926b25cf98a..c73aa15ad37e 100644
--- a/gcc/config/mingw/winnt.cc
+++ b/gcc/config/mingw/winnt.cc
@@ -860,7 +860,9 @@ mingw_pe_file_end (void)
"\t.p2align\t3, 0\n"
"\t.globl\t%s\n"
"\t.linkonce\tdiscard\n", oname, oname);
- fprintf (asm_out_file, "%s:\n\t.quad\t%s\n", oname, name);
+ fprintf (asm_out_file, "%s:\n\t.quad\t", oname);
+ ASM_OUTPUT_LABELREF (asm_out_file, name);
+ fputc ('\n', asm_out_file);
}
}
}
--
2.54.0
From 67c701fc4f02a48f6053e34c28a4f367bd77dd8c Mon Sep 17 00:00:00 2001 From: LIU Hao <[email protected]> Date: Fri, 8 May 2026 21:02:23 +0800 Subject: [PATCH] mingw: Ensure symbols are quoted in Intel syntax Previously, this code extern int shl; int get_shl(void) { return shl; } gave errors like $ x86_64-w64-mingw32-gcc -masm=intel test.c ccUSyr0f.s: Assembler messages: ccUSyr0f.s:24: Error: invalid use of operator "shl" because it contained .refptr.shl: .quad shl This `shl` should have referenced the symbol, but it appeared in an expression context, where, in Intel syntax, it got interpreted as the shift-left operator. This commit fixes the issue by emitting the target symbol with `ASM_OUTPUT_LABELREF`, which will quote it properly with regard to the output assembler syntax. PR target/53929 gcc/ChangeLog: * config/mingw/winnt.cc (mingw_pe_file_end): Use `ASM_OUTPUT_LABELREF` to emit `name`. Signed-off-by: LIU Hao <[email protected]> --- gcc/config/mingw/winnt.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/gcc/config/mingw/winnt.cc b/gcc/config/mingw/winnt.cc index e926b25cf98a..c73aa15ad37e 100644 --- a/gcc/config/mingw/winnt.cc +++ b/gcc/config/mingw/winnt.cc @@ -860,7 +860,9 @@ mingw_pe_file_end (void) "\t.p2align\t3, 0\n" "\t.globl\t%s\n" "\t.linkonce\tdiscard\n", oname, oname); - fprintf (asm_out_file, "%s:\n\t.quad\t%s\n", oname, name); + fprintf (asm_out_file, "%s:\n\t.quad\t", oname); + ASM_OUTPUT_LABELREF (asm_out_file, name); + fputc ('\n', asm_out_file); } } } -- 2.54.0
OpenPGP_signature.asc
Description: OpenPGP digital signature
