From: Alan Modra <amodra@gmail.com>
To: Michael Matz <matz@suse.de>
Cc: binutils@sourceware.org
Subject: Re: [PATCH] Let '^' through the lexer
Date: Thu, 13 Jul 2023 08:32:58 +0930 [thread overview]
Message-ID: <ZK8xIvI+cKyCY/z6@squeak.grove.modra.org> (raw)
In-Reply-To: <alpine.LSU.2.20.2307121351250.13548@wotan.suse.de>
On Wed, Jul 12, 2023 at 01:56:54PM +0000, Michael Matz via Binutils wrote:
> so that the (existing) code in parser and expression evaluator
> actually get to see it and handle it as XOR.
> ---
>
> A colleague was asking me about why XOR is missing from linker scripts and
> I initially wanted to say "but it is supported, only undocumented",
> because I distinctly remembered the code handling XOR in the expression
> parser and evaluator. But ... he was right. The lexer unhelpfully
> doesn't let '^' through and just spits out a "unrecognized character"
> error.
>
> This is the case since the dawn of time it seems (ldgram end ldexp
> handling it, but ldlex not), but I don't see a reason. While '^'
> might also be a meta-character in other lexer modes, that's no different
> from, say, '?' and '*'. So, let's just handle it as well, document it,
> and leave it be :-)
>
> (I have looked around for a testcase that systematically tests the
> expression syntax in linker scripts. I can't find one, so I haven't added
> a case for this one either).
>
> This is regtested on x86-64-linux only, my test-everything setup is
> missing right now. Assuming that that works as well, okay for master?
OK, but..
> --- a/ld/ld.texi
> +++ b/ld/ld.texi
> @@ -6826,11 +6826,12 @@ precedence associativity Operators Notes
> 4 left >> <<
> 5 left == != > < <= >=
Since you're adjusting this table, can you fix the precedence above?
== and != are lower precedence than the other relational operators.
> 6 left &
> -7 left |
> -8 left &&
> -9 left ||
> -10 right ? :
> -11 right &= += -= *= /= (2)
> +7 left ^
> +8 left |
> +9 left &&
> +10 left ||
> +11 right ? :
> +12 right &= += -= *= /= (2)
This line misses some assignment operators supported by ldgram.y.
It should be += -= *= /= <<= >>= &= |=
> (lowest)
> @end smallexample
> Notes:
> @@ -6858,11 +6859,12 @@ height2pt&\omit&&\omit&&\omit&\cr
> &4&&left&&>> <<&\cr
> &5&&left&&== != > < <= >=&\cr
> &6&&left&&\&&\cr
> -&7&&left&&|&\cr
> -&8&&left&&{\&\&}&\cr
> -&9&&left&&||&\cr
> -&10&&right&&? :&\cr
> -&11&&right&&\qquad\&= += -= *= /=\qquad\ddag&\cr
> +&7&&left&&^&\cr
> +&8&&left&&|&\cr
> +&9&&left&&{\&\&}&\cr
> +&10&&left&&||&\cr
> +&11&&right&&? :&\cr
> +&12&&right&&\qquad\&= += -= *= /=\qquad\ddag&\cr
> &lowest&&&&&\cr
> height2pt&\omit&&\omit&&\omit&\cr}
> \hrule}
> diff --git a/ld/ldlex.l b/ld/ldlex.l
> index 1a6be1b6af2..9cb002452d8 100644
> --- a/ld/ldlex.l
> +++ b/ld/ldlex.l
> @@ -247,6 +247,7 @@ V_IDENTIFIER [*?.$_a-zA-Z\[\]\-\!\^\\]([*?.$_a-zA-Z0-9\[\]\-\!\^\\]|::)*
> <EXPRESSION,MRI>"/" { RTOKEN('/'); }
> <EXPRESSION,MRI>"%" { RTOKEN('%'); }
> <EXPRESSION,MRI>"<" { RTOKEN('<'); }
> +<EXPRESSION,MRI>"^" { RTOKEN('^'); }
> <SCRIPT,EXPRESSION,MRI,WILD>"=" { RTOKEN('='); }
> <SCRIPT,EXPRESSION,MRI,WILD>"}" { RTOKEN('}'); }
> <SCRIPT,EXPRESSION,MRI,WILD>"{" { RTOKEN('{'); }
> --
> 2.39.1
--
Alan Modra
Australia Development Lab, IBM
next prev parent reply other threads:[~2023-07-12 23:03 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 [this message]
2023-07-13 7:54 ` Jan Beulich
2023-07-13 10:20 ` Alan Modra
2023-07-13 16:02 ` Michael Matz
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=ZK8xIvI+cKyCY/z6@squeak.grove.modra.org \
--to=amodra@gmail.com \
--cc=binutils@sourceware.org \
--cc=matz@suse.de \
/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).