* [PATCH 0/2] x86: don't recognize quoted symbol names as registers or operators
@ 2023-05-05 12:49 Jan Beulich
2023-05-05 12:51 ` [PATCH 1/2] " Jan Beulich
2023-05-05 12:52 ` [PATCH 2/2] x86/Intel: address quoted-symbol related FIXMEs Jan Beulich
0 siblings, 2 replies; 3+ messages in thread
From: Jan Beulich @ 2023-05-05 12:49 UTC (permalink / raw)
To: Binutils; +Cc: H.J. Lu
The first patch in particular is aiming at providing the foundation
to address gcc's bug target/53929.
1: don't recognize quoted symbol names as registers or operators
2: Intel: address quoted-symbol related FIXMEs
Jan
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 1/2] x86: don't recognize quoted symbol names as registers or operators
2023-05-05 12:49 [PATCH 0/2] x86: don't recognize quoted symbol names as registers or operators Jan Beulich
@ 2023-05-05 12:51 ` Jan Beulich
2023-05-05 12:52 ` [PATCH 2/2] x86/Intel: address quoted-symbol related FIXMEs Jan Beulich
1 sibling, 0 replies; 3+ messages in thread
From: Jan Beulich @ 2023-05-05 12:51 UTC (permalink / raw)
To: Binutils; +Cc: H.J. Lu
The concept of quoted symbols names was introduced pretty late. Utilize
it to allow access to symbols with names matching that of a register (or,
in Intel syntax, also an identifier-like operator).
This is primarily to aid gcc when generating Intel syntax output; see
their bug target/53929.
---
If desired, the i386_parse_name() could of course be restricted to
Intel syntax only. But
--- a/gas/config/tc-i386.c
+++ b/gas/config/tc-i386.c
@@ -13868,6 +13868,13 @@ i386_parse_name (char *name, expressionS
const reg_entry *r = NULL;
char *end = input_line_pointer;
+ /* We only know the terminating character here. It being double quote could
+ be the closing one of a quoted symbol name, or an opening one from a
+ following string (or another quoted symbol name). Since the latter can't
+ be valid syntax for anything, bailing in either case is good enough. */
+ if (*nextcharP == '"')
+ return 0;
+
*end = *nextcharP;
if (*name == REGISTER_PREFIX || allow_naked_reg)
r = parse_real_register (name, &input_line_pointer);
--- a/gas/config/tc-i386-intel.c
+++ b/gas/config/tc-i386-intel.c
@@ -169,6 +169,10 @@ operatorT i386_operator (const char *nam
return O_illegal;
}
+ /* See the quotation related comment in i386_parse_name(). */
+ if (*pc == '"')
+ return O_absent;
+
for (j = 0; i386_operators[j].name; ++j)
if (strcasecmp (i386_operators[j].name, name) == 0)
{
--- a/gas/testsuite/gas/i386/i386.exp
+++ b/gas/testsuite/gas/i386/i386.exp
@@ -105,6 +105,7 @@ if [gas_32_check] then {
run_list_test "equ-bad"
run_dump_test "divide"
run_dump_test "quoted"
+ run_dump_test "quoted2"
run_dump_test "unary"
run_dump_test "padlock"
run_dump_test "crx"
--- a/gas/testsuite/gas/i386/quoted.d
+++ b/gas/testsuite/gas/i386/quoted.d
@@ -18,4 +18,11 @@ Disassembly of section .text:
[ ]*[a-f0-9]+:[ ]*ff 15 00 00 00 00[ ]+call \*0x0 [a-f0-9]+: (R_386_|dir)?32 x\(y\)
[ ]*[a-f0-9]+:[ ]*26 ff 15 00 00 00 00[ ]+call \*%es:0x0 [a-f0-9]+: (R_386_|dir)?32 x\(y\)
[ ]*[a-f0-9]+:[ ]*26 ff 15 00 00 00 00[ ]+call \*%es:0x0 [a-f0-9]+: (R_386_|dir)?32 x\(y\)
+[ ]*[a-f0-9]+:[ ]*b8 00 00 00 00[ ]+mov \$0x0,%eax [a-f0-9]+: (R_386_|dir)?32 %eax
+[ ]*[a-f0-9]+:[ ]*a1 00 00 00 00[ ]+mov 0x0,%eax [a-f0-9]+: (R_386_|dir)?32 %eax
+[ ]*[a-f0-9]+:[ ]*a1 00 00 00 00[ ]+mov 0x0,%eax [a-f0-9]+: (R_386_|dir)?32 ecx
+[ ]*[a-f0-9]+:[ ]*a1 00 00 00 00[ ]+mov 0x0,%eax [a-f0-9]+: (R_386_|dir)?32 xmm0
+[ ]*[a-f0-9]+:[ ]*a1 00 00 00 00[ ]+mov 0x0,%eax [a-f0-9]+: (R_386_|dir)?32 not
+[ ]*[a-f0-9]+:[ ]*a1 00 00 00 00[ ]+mov 0x0,%eax [a-f0-9]+: (R_386_|dir)?32 and
+[ ]*[a-f0-9]+:[ ]*b8 00 00 00 00[ ]+mov \$0x0,%eax [a-f0-9]+: (R_386_|dir)?32 edx
#pass
--- a/gas/testsuite/gas/i386/quoted.s
+++ b/gas/testsuite/gas/i386/quoted.s
@@ -14,3 +14,13 @@ quoted:
call *"x(y)"
call *%es:"x(y)"
call %es:*"x(y)"
+
+ mov $"%eax", %eax
+ mov "%eax", %eax
+
+ .intel_syntax noprefix
+ mov eax, "ecx"
+ mov eax, "xmm0"
+ mov eax, "not"
+ mov eax, "and"
+ mov eax, offset "edx"
--- /dev/null
+++ b/gas/testsuite/gas/i386/quoted2.d
@@ -0,0 +1,15 @@
+#objdump: -r
+#name: i386 quoted symbols (data)
+# Mach-O relocations appear in inverse order
+#notarget: *-*-darwin
+
+.*: +file format .*
+
+RELOCATION RECORDS FOR \[\.data\]:
+OFFSET +TYPE +VALUE
+0+00 (R_386_|dir)?32 +%ebx
+0+04 (R_386_|dir)?32 +%rdx
+0+08 (R_386_|dir)?32 +eax
+0+0c (R_386_|dir)?32 +cr0
+0+10 (R_386_|dir)?32 +k0
+#pass
--- /dev/null
+++ b/gas/testsuite/gas/i386/quoted2.s
@@ -0,0 +1,9 @@
+ .data
+quoted:
+ .long "%ebx"
+ .long "%rdx"
+
+ .intel_syntax noprefix
+ .long "eax"
+ .long "cr0"
+ .long "k0"
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 2/2] x86/Intel: address quoted-symbol related FIXMEs
2023-05-05 12:49 [PATCH 0/2] x86: don't recognize quoted symbol names as registers or operators Jan Beulich
2023-05-05 12:51 ` [PATCH 1/2] " Jan Beulich
@ 2023-05-05 12:52 ` Jan Beulich
1 sibling, 0 replies; 3+ messages in thread
From: Jan Beulich @ 2023-05-05 12:52 UTC (permalink / raw)
To: Binutils; +Cc: H.J. Lu
If in a "word ptr <address>" or alike construct the "ptr" part is
double-quoted, it shouldn't be recognized as the specific keyword we're
looking for (just like we don't recognize double-quoted operator or
register names anymore). Be careful though to tell closing from opening
double-quotes, as a quoted symbol may follow right afterwards.
--- a/gas/config/tc-i386-intel.c
+++ b/gas/config/tc-i386-intel.c
@@ -188,15 +188,12 @@ operatorT i386_operator (const char *nam
if (i386_types[j].name && *pc == ' ')
{
+ const char *start = ++input_line_pointer;
char *pname;
- char c;
+ char c = get_symbol_name (&pname);
- ++input_line_pointer;
- c = get_symbol_name (&pname);
-
- if (strcasecmp (pname, "ptr") == 0)
+ if (strcasecmp (pname, "ptr") == 0 && (c != '"' || pname == start))
{
- /* FIXME: What if c == '"' ? */
pname[-1] = *pc;
*pc = c;
if (intel_syntax > 0 || operands != 1)
@@ -204,9 +201,8 @@ operatorT i386_operator (const char *nam
return i386_types[j].op;
}
- if (strcasecmp (pname, "bcst") == 0)
+ if (strcasecmp (pname, "bcst") == 0 && (c != '"' || pname == start))
{
- /* FIXME: Again, what if c == '"' ? */
pname[-1] = *pc;
*pc = c;
if (intel_syntax > 0 || operands != 1
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-05-05 12:52 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-05 12:49 [PATCH 0/2] x86: don't recognize quoted symbol names as registers or operators Jan Beulich
2023-05-05 12:51 ` [PATCH 1/2] " Jan Beulich
2023-05-05 12:52 ` [PATCH 2/2] x86/Intel: address quoted-symbol related FIXMEs Jan Beulich
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).