]> git.ipfire.org Git - thirdparty/gcc.git/commit
i386: Quote user-defined symbols in assembly in Intel syntax
authorLIU Hao <lh_mouse@126.com>
Sat, 22 Feb 2025 05:11:51 +0000 (13:11 +0800)
committerJonathan Yong <10walls@gmail.com>
Sun, 25 May 2025 12:04:50 +0000 (12:04 +0000)
commit5840bf969e2bfdf4f6c51d04aeb1a96a87727d80
treedad571aa3a71bc3e874f421222c971072b466f7c
parent17c1aa2db3024f34a95336c0afacf406863fe6dd
i386: Quote user-defined symbols in assembly in Intel syntax

With `-masm=intel`, GCC generates registers without % prefixes. If a
user-declared symbol happens to match a register, it will confuse the
assembler. User-defined symbols should be quoted, so they are not to
be mistaken for registers or operators.

Support for quoted symbols were added in Binutils 2.26, originally
for ARM assembly, where registers are also unprefixed:
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=d02603dc201f80cd9d2a1f4b1a16110b1e04222b

This change is required for `@SECREL32` to work in Intel syntax when
targeting Windows, where `@` is allowed as part of a symbol. GNU AS
fails to parse a plain symbol with that suffix:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80881#c79

gcc/ChangeLog:

PR target/53929
PR target/80881
* config/i386/i386-protos.h (ix86_asm_output_labelref): Declare new
function for quoting user-defined symbols in Intel syntax.
* config/i386/i386.cc (ix86_asm_output_labelref): Implement it.
* config/i386/i386.h (ASM_OUTPUT_LABELREF): Use it.
* config/i386/cygming.h (ASM_OUTPUT_LABELREF): Use it.
gcc/config/i386/cygming.h
gcc/config/i386/i386-protos.h
gcc/config/i386/i386.cc
gcc/config/i386/i386.h