gold accepts quoted strings:
gold/yyscript.y
252┊ file_cmd:
253┊ EXTERN '(' extern_name_list ')'
312┊ /* A list of external undefined symbols. We put the lexer into
313┊ expression mode so that commas separate names; this is what the GNU
314┊ linker does. */
315┊
316┊ extern_name_list:
317┊ { script_push_lex_into_expression_mode(closure); }
318┊ extern_name_list_body
319┊ { script_pop_lex_mode(closure); }
320┊ ;
321┊
322┊ extern_name_list_body:
323┊ string
324┊ { script_add_extern(closure, $1.value, $1.length); }
325┊ | extern_name_list_body string
326┊ { script_add_extern(closure, $2.value, $2.length); }
327┊ | extern_name_list_body ',' string
328┊ { script_add_extern(closure, $3.value, $3.length); }
329┊ ;
330┊
1123┊ /* A string can be either a STRING or a QUOTED_STRING. Almost all the
1124┊ time we don't care, and we use this rule. */
1125┊ string:
1126┊ STRING
1127┊ { $$ = $1; }
1128┊ | QUOTED_STRING
1129┊ { $$ = $1; }
1130┊ ;binutils requires quoted strings for some kinds of symbols, e.g.:
- it accepts quoted symbols with @ in name:
$ echo 'EXTERN("__libc_start_main@@GLIBC_2.2.5")' > a.script $ g++ a.script /usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64/crt1.o: In function `_start': (.text+0x20): undefined reference to `main' collect2: error: ld returned 1 exit status
- but rejects them if unquoted:
$ echo 'EXTERN(__libc_start_main@@GLIBC_2.2.5)' > a.script $ g++ a.script a.script: file not recognized: File format not recognized collect2: error: ld returned 1 exit status
To maintain compatibility with existing linker scripts support quoted strings in lld as well.