From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by sourceware.org (Postfix) with ESMTPS id E63573858D20 for ; Wed, 12 Jul 2023 13:56:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E63573858D20 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 254761FD65 for ; Wed, 12 Jul 2023 13:56:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1689170214; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type; bh=66EQRhKRtOV+r7SIZlf6WQBN7QevQ9EhWLdwuhbdZj0=; b=MWWypFeP6XHgHcWZ/jCyFPGUEjrgEEaFGkF1rd24NIKhjIPTyp+Xc+9dE4ZpNHomTSCKs7 MACtqRVDUOY2CQrJ6k0ps0ZxTA+r4F81/hWGl/pETV/MwxzitOkho8m2HNp/kJQtAAllGf BVOO3wloQ9qZLIinfB8/ydVit7dxjs0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1689170214; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type; bh=66EQRhKRtOV+r7SIZlf6WQBN7QevQ9EhWLdwuhbdZj0=; b=xRYEu7KD9Ndk0ta8ZsBk+qWbwujZTXZ696PAwRJifbPGnuT0wLJvUelY3ezBTSe+DI51uI 4aR3SRZQxalN6gAA== Received: from wotan.suse.de (wotan.suse.de [10.160.0.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id 1B8B82C143 for ; Wed, 12 Jul 2023 13:56:54 +0000 (UTC) Received: by wotan.suse.de (Postfix, from userid 10510) id 124386859; Wed, 12 Jul 2023 13:56:54 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by wotan.suse.de (Postfix) with ESMTP id 113E267F5 for ; Wed, 12 Jul 2023 13:56:54 +0000 (UTC) Date: Wed, 12 Jul 2023 13:56:54 +0000 (UTC) From: Michael Matz To: binutils@sourceware.org Subject: [PATCH] Let '^' through the lexer Message-ID: User-Agent: Alpine 2.20 (LSU 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-9.1 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: 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? Ciao, Michael. --- ld/ld.texi | 22 ++++++++++++---------- ld/ldlex.l | 1 + 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/ld/ld.texi b/ld/ld.texi index aa8b1aa86eb..8f82fe5a92f 100644 --- a/ld/ld.texi +++ b/ld/ld.texi @@ -6826,11 +6826,12 @@ precedence associativity Operators Notes 4 left >> << 5 left == != > < <= >= 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) (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\[\]\-\!\^\\]|::)* "/" { RTOKEN('/'); } "%" { RTOKEN('%'); } "<" { RTOKEN('<'); } +"^" { RTOKEN('^'); } "=" { RTOKEN('='); } "}" { RTOKEN('}'); } "{" { RTOKEN('{'); } -- 2.39.1