From: LIU Hao <lh_mouse@126.com>
To: Jan Beulich <jbeulich@suse.com>
Cc: binutils@sourceware.org, GCC Development <gcc@gcc.gnu.org>
Subject: Re: RFC: Formalization of the Intel assembly syntax (PR53929)
Date: Tue, 23 Jan 2024 09:27:34 +0800 [thread overview]
Message-ID: <38e2198d-ee2d-4b91-92d3-0890779bf0dd@126.com> (raw)
In-Reply-To: <1999d6bb-757f-41f4-ad8c-e2d54d14ee4b@suse.com>
[-- Attachment #1.1.1: Type: text/plain, Size: 1161 bytes --]
在 2024-01-22 16:39, Jan Beulich 写道:
> Right, I did some work in that direction a while ago. But iirc there are
> still cases left to be addressed.
Attached is a draft patch for GCC, bootstrapped on {i686,x86_64}-w64-mingw32 with GCC 13.2 and
binutils 2.41.0.
This addresses the issue when a bad name exists in the same translation unit. In the case of an
external symbol there's still an error:
```
extern int bx;
int get(const char* p) { return p[bx]; }
```
```
lh_mouse@lhmouse-pc ~/Desktop $ x86_64-w64-mingw32-gcc -S -o - -masm=intel test.c | fgrep bx
mov rax, QWORD PTR .refptr.bx[rip]
.section .rdata$.refptr.bx, "dr"
.globl .refptr.bx
.refptr.bx:
.quad bx
lh_mouse@lhmouse-pc ~/Desktop $ x86_64-w64-mingw32-gcc -masm=intel test.c | fgrep bx
C:\Users\lh_mouse\AppData\Local\Temp\ccuyuu6c.s: Assembler messages:
C:\Users\lh_mouse\AppData\Local\Temp\ccuyuu6c.s:29: Error: invalid use of register
C:\Users\lh_mouse\AppData\Local\Temp\ccuyuu6c.s:29: Warning: register value used as expression
lh_mouse@lhmouse-pc ~/Desktop $
```
--
Best regards,
LIU Hao
[-- Attachment #1.1.2: 0401-Always-quote-labels-in-Intel-syntax.patch --]
[-- Type: text/x-patch, Size: 1325 bytes --]
From 2579afab42b90dceac860114acbad1ab79bca979 Mon Sep 17 00:00:00 2001
From: LIU Hao <lh_mouse@126.com>
Date: Tue, 23 Jan 2024 02:20:29 +0800
Subject: [PATCH] Always quote symbols in Intel syntax
---
gcc/config/i386/i386.h | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/gcc/config/i386/i386.h b/gcc/config/i386/i386.h
index 539083f2fbf8..785c6eda8d55 100644
--- a/gcc/config/i386/i386.h
+++ b/gcc/config/i386/i386.h
@@ -2175,7 +2175,7 @@ extern int const svr4_debugger_register_map[FIRST_PSEUDO_REGISTER];
#define ASM_OUTPUT_SYMBOL_REF(FILE, SYM) \
do { \
const char *name \
- = assemble_name_resolve (XSTR (x, 0)); \
+ = assemble_name_resolve (XSTR (SYM, 0)); \
/* In -masm=att wrap identifiers that start with $ \
into parens. */ \
if (ASSEMBLER_DIALECT == ASM_ATT \
@@ -2186,6 +2186,13 @@ extern int const svr4_debugger_register_map[FIRST_PSEUDO_REGISTER];
assemble_name_raw ((FILE), name); \
fputc (')', (FILE)); \
} \
+ else if (ASSEMBLER_DIALECT == ASM_INTEL \
+ && name[0] != '*') \
+ { \
+ fputc ('\"', (FILE)); \
+ assemble_name_raw ((FILE), name); \
+ fputc ('\"', (FILE)); \
+ } \
else \
assemble_name_raw ((FILE), name); \
} while (0)
--
2.43.0
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 840 bytes --]
next prev parent reply other threads:[~2024-01-23 1:27 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-18 5:34 LIU Hao
2024-01-18 9:02 ` Fangrui Song
2024-01-18 12:54 ` Jan Beulich
2024-01-18 16:40 ` LIU Hao
2024-01-19 9:13 ` Jan Beulich
2024-01-20 12:40 ` LIU Hao
2024-01-22 8:39 ` Jan Beulich
2024-01-23 1:27 ` LIU Hao [this message]
2024-01-23 8:38 ` Jan Beulich
2024-01-23 9:00 ` LIU Hao
2024-01-23 9:03 ` Jan Beulich
2024-01-23 9:21 ` LIU Hao
2024-01-23 9:37 ` Jan Beulich
2024-01-30 4:22 ` Hans-Peter Nilsson
2024-01-31 10:11 ` LIU Hao
[not found] ` <DS7PR12MB5765DBF9500DE323DB4A8E29CB712@DS7PR12MB5765.namprd12.prod.outlook.com>
2024-01-19 1:42 ` LIU Hao
2024-01-19 7:41 ` Jan Beulich
2024-01-19 8:19 ` Fangrui Song
[not found] ` <DS7PR12MB5765654642BE3AD4C7F54E05CB702@DS7PR12MB5765.namprd12.prod.outlook.com>
2024-01-20 12:32 ` LIU Hao
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=38e2198d-ee2d-4b91-92d3-0890779bf0dd@126.com \
--to=lh_mouse@126.com \
--cc=binutils@sourceware.org \
--cc=gcc@gcc.gnu.org \
--cc=jbeulich@suse.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).