From: Michael Matz <matz@suse.de>
To: Alan Modra <amodra@gmail.com>
Cc: Jan Beulich <jbeulich@suse.com>, binutils@sourceware.org
Subject: Re: [PATCH] Let '^' through the lexer
Date: Thu, 13 Jul 2023 16:02:35 +0000 (UTC) [thread overview]
Message-ID: <alpine.LSU.2.20.2307131600080.13548@wotan.suse.de> (raw)
In-Reply-To: <ZK/P4xDydoEt1G7k@squeak.grove.modra.org>
Hey,
On Thu, 13 Jul 2023, Alan Modra wrote:
> On Thu, Jul 13, 2023 at 09:54:46AM +0200, Jan Beulich wrote:
> > On 13.07.2023 01:02, Alan Modra via Binutils wrote:
> > > This line misses some assignment operators supported by ldgram.y.
> > > It should be += -= *= /= <<= >>= &= |=
> >
> > At which point, considering the subject of the patch, I'm inclined
> > to ask: What about ^=?
>
> It would need support in ldgram.y and ldexp.c.
Exactly. I felt that should be a separate patch. But as it's easy to do
and improves symmetry, here it is. Okay for master if everything checks
out (on x86-64 it does)?
Ciao,
Michael.
--------------
commit 894720ff9ce38ee1758d5a38cd1b0738c524f0c6
Author: Michael Matz <matz@suse.de>
Date: Thu Jul 13 17:58:19 2023 +0200
Also support '^=' in linker script expressions
this requires also changes in ldgram.y and ldexp.c, unlike
accepting '^' only. But let's do this anyway, if only for
symmetry.
diff --git a/ld/ld.texi b/ld/ld.texi
index 5009f0e5a6c..16ed74d7c9b 100644
--- a/ld/ld.texi
+++ b/ld/ld.texi
@@ -6832,7 +6832,7 @@ precedence associativity Operators Notes
10 left &&
11 left ||
12 right ? :
-13 right += -= *= /= <<= >>= &= |= (2)
+13 right += -= *= /= <<= >>= &= |= ^= (2)
(lowest)
@end smallexample
Notes:
@@ -6866,7 +6866,7 @@ height2pt&\omit&&\omit&&\omit&\cr
&10&&left&&{\&\&}&\cr
&11&&left&&||&\cr
&12&&right&&? :&\cr
-&13&&right&&\qquad += -= *= /= <<= >>= \&= |=\qquad\ddag&\cr
+&13&&right&&\qquad += -= *= /= <<= >>= \&= |= ^=\qquad\ddag&\cr
&lowest&&&&&\cr
height2pt&\omit&&\omit&&\omit&\cr}
\hrule}
diff --git a/ld/ldexp.c b/ld/ldexp.c
index 170e1ed7f56..c0d90d3f93a 100644
--- a/ld/ldexp.c
+++ b/ld/ldexp.c
@@ -94,6 +94,7 @@ exp_print_token (token_code_type code, int infix_p)
{ RSHIFTEQ, ">>=" },
{ ANDEQ, "&=" },
{ OREQ, "|=" },
+ { XOREQ, "^=" },
{ OROR, "||" },
{ ANDAND, "&&" },
{ EQ, "==" },
diff --git a/ld/ldgram.y b/ld/ldgram.y
index 081176ba0f1..9dbf10b2b1f 100644
--- a/ld/ldgram.y
+++ b/ld/ldgram.y
@@ -108,7 +108,7 @@ static int error_index;
%type <section_phdr> phdr_opt
%type <integer> opt_nocrossrefs
-%right <token> PLUSEQ MINUSEQ MULTEQ DIVEQ '=' LSHIFTEQ RSHIFTEQ ANDEQ OREQ
+%right <token> PLUSEQ MINUSEQ MULTEQ DIVEQ '=' LSHIFTEQ RSHIFTEQ ANDEQ OREQ XOREQ
%right <token> '?' ':'
%left <token> OROR
%left <token> ANDAND
@@ -747,6 +747,8 @@ assign_op:
{ $$ = '&'; }
| OREQ
{ $$ = '|'; }
+ | XOREQ
+ { $$ = '^'; }
;
diff --git a/ld/ldlex.l b/ld/ldlex.l
index 9cb002452d8..435172c08c3 100644
--- a/ld/ldlex.l
+++ b/ld/ldlex.l
@@ -233,6 +233,7 @@ V_IDENTIFIER [*?.$_a-zA-Z\[\]\-\!\^\\]([*?.$_a-zA-Z0-9\[\]\-\!\^\\]|::)*
<SCRIPT,EXPRESSION,MRI,WILD>"/=" { RTOKEN(DIVEQ); }
<SCRIPT,EXPRESSION,MRI,WILD>"&=" { RTOKEN(ANDEQ); }
<SCRIPT,EXPRESSION,MRI,WILD>"|=" { RTOKEN(OREQ); }
+<SCRIPT,EXPRESSION,MRI,WILD>"^=" { RTOKEN(XOREQ); }
<EXPRESSION,MRI>"&&" { RTOKEN(ANDAND); }
<SCRIPT,EXPRESSION,MRI>">" { RTOKEN('>'); }
<SCRIPT,EXPRESSION,MRI,INPUTLIST>"," { RTOKEN(','); }
next prev parent reply other threads:[~2023-07-13 16:02 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-12 13:56 Michael Matz
2023-07-12 23:02 ` Alan Modra
2023-07-13 7:54 ` Jan Beulich
2023-07-13 10:20 ` Alan Modra
2023-07-13 16:02 ` Michael Matz [this message]
2023-07-14 3:32 ` Alan Modra
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=alpine.LSU.2.20.2307131600080.13548@wotan.suse.de \
--to=matz@suse.de \
--cc=amodra@gmail.com \
--cc=binutils@sourceware.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).