diff options
author | Alan Modra <amodra@gmail.com> | 2021-08-14 09:32:35 +0930 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2021-08-14 09:54:48 +0930 |
commit | 4ffb22ec4040030ea36829c74076f35b3ca0872a (patch) | |
tree | 16484472ec9b5cdaf746debdd2f62cb499f94406 /ld/ldgram.y | |
parent | 96ddc891f296b9a5f4a2e6788adb38d93b1e14ca (diff) | |
download | gdb-4ffb22ec4040030ea36829c74076f35b3ca0872a.zip gdb-4ffb22ec4040030ea36829c74076f35b3ca0872a.tar.gz gdb-4ffb22ec4040030ea36829c74076f35b3ca0872a.tar.bz2 |
ld script fill pattern expression
It turns out we do need to backtrack when parsing after all. The
fill_opt component in the section rule swiches to EXPRESSION and back
to SCRIPT, and to find the end of an expression it is necessary to
look ahead one token.
* ldgram.y (section): Throw away lookahead NAME token.
(overlay_section): Likewise.
* testsuite/ld-elf/overlay.t: Add fill pattern on overlays.
Test fill pattern before stupidly named normal sections too,
and before /DISCARD/.
Diffstat (limited to 'ld/ldgram.y')
-rw-r--r-- | ld/ldgram.y | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/ld/ldgram.y b/ld/ldgram.y index 1f6c44a..a0c881e 100644 --- a/ld/ldgram.y +++ b/ld/ldgram.y @@ -1063,6 +1063,18 @@ section: NAME { ldlex_popstate (); } memspec_opt memspec_at_opt phdr_opt fill_opt { + /* fill_opt may have switched the lexer into + expression state, and back again, but in + order to find the end of the fill + expression the parser must look ahead one + token. If it is a NAME, throw it away as + it will have been lexed in the wrong + state. */ + if (yychar == NAME) + { + yyclearin; + ldlex_backup (); + } lang_leave_output_section_statement ($17, $14, $16, $15); } @@ -1079,6 +1091,11 @@ section: NAME '}' memspec_opt memspec_at_opt phdr_opt fill_opt { + if (yychar == NAME) + { + yyclearin; + ldlex_backup (); + } lang_leave_overlay ($5, (int) $4, $15, $12, $14, $13); } @@ -1179,6 +1196,11 @@ overlay_section: { ldlex_popstate (); } phdr_opt fill_opt { + if (yychar == NAME) + { + yyclearin; + ldlex_backup (); + } lang_leave_overlay_section ($9, $8); } opt_comma |