From eeed9cc785ca447868967e5c84dae63e9ca8e6c2 Mon Sep 17 00:00:00 2001 From: Hans-Peter Nilsson Date: Wed, 15 Oct 2014 03:10:25 +0200 Subject: Allow unquoted = as the first character in ldscript input_list names * ldlex.l (INPUTLIST): New start condition. (comment pattern, ",", "(", ")", "AS_NEEDED") ({FILENAMECHAR1}{FILENAMECHAR}*, "-l"{FILENAMECHAR}+) (quoted string pattern, whitespace pattern): Add INPUTLIST to valid start conditions. ("="{FILENAMECHAR1}{FILENAMECHAR}*): New NAME rule. (ldlex_inputlist): New start-condition-setter function. * ldgram.y (input_list1): Rename from input_list. All recursive use changed. (input_list): New wrapper rule for input_list1, setting INPUTLIST lexer state for the duration of parsing input_list1. All this to say INPUT(=/path/to/file) and not be forced to use INPUT("=/path/to/file") whenever there's a need to force a sysroot- prefix. Still, IMHO it seems better to make use of a previously invalid syntax and not only change the meaning of quoted =-prefixed paths (though arguably that's not very useful before this patchset). This got a little bit hairier than I'd expected: I had to add a new lexer state (aka. start condition) to avoid a first "=" being lexed as the token "=", despite that not making sense in constructs expecting file-names in the first place. (The grammar doesn't allow for expressions in any part of those lists.) I guess I *could* have made it work using that token anyway, but I didn't like the idea that you would be able to separate the "=" from the rest of the file-name with whitespace. --- ld/ldgram.y | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'ld/ldgram.y') diff --git a/ld/ldgram.y b/ld/ldgram.y index 4875fa7..e76a0a3 100644 --- a/ld/ldgram.y +++ b/ld/ldgram.y @@ -365,38 +365,43 @@ ifile_p1: ; input_list: + { ldlex_inputlist(); } + input_list1 + { ldlex_popstate(); } + +input_list1: NAME { lang_add_input_file($1,lang_input_file_is_search_file_enum, (char *)NULL); } - | input_list ',' NAME + | input_list1 ',' NAME { lang_add_input_file($3,lang_input_file_is_search_file_enum, (char *)NULL); } - | input_list NAME + | input_list1 NAME { lang_add_input_file($2,lang_input_file_is_search_file_enum, (char *)NULL); } | LNAME { lang_add_input_file($1,lang_input_file_is_l_enum, (char *)NULL); } - | input_list ',' LNAME + | input_list1 ',' LNAME { lang_add_input_file($3,lang_input_file_is_l_enum, (char *)NULL); } - | input_list LNAME + | input_list1 LNAME { lang_add_input_file($2,lang_input_file_is_l_enum, (char *)NULL); } | AS_NEEDED '(' { $$ = input_flags.add_DT_NEEDED_for_regular; input_flags.add_DT_NEEDED_for_regular = TRUE; } - input_list ')' + input_list1 ')' { input_flags.add_DT_NEEDED_for_regular = $3; } - | input_list ',' AS_NEEDED '(' + | input_list1 ',' AS_NEEDED '(' { $$ = input_flags.add_DT_NEEDED_for_regular; input_flags.add_DT_NEEDED_for_regular = TRUE; } - input_list ')' + input_list1 ')' { input_flags.add_DT_NEEDED_for_regular = $5; } - | input_list AS_NEEDED '(' + | input_list1 AS_NEEDED '(' { $$ = input_flags.add_DT_NEEDED_for_regular; input_flags.add_DT_NEEDED_for_regular = TRUE; } - input_list ')' + input_list1 ')' { input_flags.add_DT_NEEDED_for_regular = $4; } ; -- cgit v1.1