]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
PR28217, Syntax error when memory region contains a hyphen
authorAlan Modra <amodra@gmail.com>
Fri, 13 Aug 2021 02:20:16 +0000 (11:50 +0930)
committerAlan Modra <amodra@gmail.com>
Fri, 13 Aug 2021 03:02:53 +0000 (12:32 +0930)
commitaf29a8abcf50ff9cb465a136c68b06bfc2ca7b75
tree3178a2b395ebf1861809037b3bcc6e4b26113347
parent41ee6d14fd3faf486036cdb9042e432664abfe48
PR28217, Syntax error when memory region contains a hyphen

The saga of commit 40726f16a8d7 continues.  This attacks the problem
of switching between SCRIPT and EXPRESSION state lexing by removing
the need to do so for phdrs like ":text".  Instead {WILDCHAR}*
matching, the reason why ":text" lexed as one token, is restricted to
within the braces of a section or overlay statement.  The new WILD
lexer state is switched at the non-optional brace tokens, so
ldlex_backup is no longer needed.  I've also removed the BOTH state,
which doesn't seem to be needed any more.  Besides rules involving
error reporting, there was just one place where SCRIPT appeared
without BOTH, the {WILDCHAR}* rule, three where BOTH appears without
SCRIPT for tokens that only need EXPRESSION state, and two where BOTH
appears alongside INPUT_LIST.  (Since I'm editing the wild and
filename rules, removing BOTH and adding WILD can also be seen as
renaming the old BOTH state to SCRIPT and renaming the old SCRIPT
state to WILD with a reduced scope.)

As a followup, I'll look at removing EXPRESSION state from some lexer
rules that no longer need it due to this cleanup.

PR 28217
* ldgram.y (exp <ORIGIN, LENGTH>): Use paren_script_name.
(section): Parse within braces of section in wild mode, and
after brace back in script mode.  Remove ldlex_backup call.
Similarly for OVERLAY.
(overlay_section): Similarly.
(script_file): Replace ldlex_both with ldlex_script.
* ldlex.h (ldlex_wild): Declare.
(ldlex_both): Delete.
* ldlex.l (BOTH): Delete.  Remove state from all rules.
(WILD): New state.  Enable many tokens in this state.
Enable filename match in SCRIPT mode.  Enable WILDCHAR match
in WILD state, disable in SCRIPT mode.
(ldlex_wild): New function.
* ldfile.c (ldfile_try_open_bfd): Replace ldlex_both call with
ldlex_script.
ld/ldfile.c
ld/ldgram.y
ld/ldlex.h
ld/ldlex.l