[lld] r202111 - [LinkerScript] OUTPUT_FORMAT: Parse Quoted Strings

Rui Ueyama ruiu at google.com
Tue Feb 25 10:39:15 PST 2014


On Tue, Feb 25, 2014 at 1:20 AM, Chandler Carruth <chandlerc at google.com>wrote:

>
> On Tue, Feb 25, 2014 at 12:23 AM, Shankar Easwaran <
> shankare at codeaurora.org> wrote:
>
>> $ld.gold -T y1
>> ld.gold: error: y1:1:29: syntax error, unexpected QUOTED_STRING,
>> expecting ')' or ','
>> ld.gold: fatal error: unable to parse script file y1
>>
>> $ld -T y1
>> ld:y1:1: syntax error
>>
>> I want to remain consistent with this behavior in the case of lld as
>> well, and fix the GNU ld bugs in lld as well so that behavior is consistent
>> when you use a arbitrary mix of quoted/unquoted strings.
>>
>
> This is *not* because the quotes aren't allowed. The error is because
> without the quotes, 'foo,' is lexed as the argument to the command. This is
> why adding whitespace before the ',' fixes the issue, as Rui has repeatedly
> pointed out.
>
> Try this example:
>
> OUTPUT_FORMAT("elf64-powerpc", elf64-powerpc, "elf64-powerpcle");
>
> Here I get:
> ld.gold: error: x:1:47: syntax error, unexpected QUOTED_STRING, expecting
> ','
>
> Note that this points to the third argument's open " as the error. The
> problem isn't that the first argument is quoted or the second argument
> isn't quoted, it is that the ',' is considered part of the string. Adding
> just a space before the ',' will fix this error.
>

Ah, so this statement in the GNU LD manual is clearly inconsistent with the
implementation. I don't say which is wrong, the manual or the
implementation, as there's no spec for it. :/ Anyways thank you for finding
this out.

Strings such as file or format names can normally be entered directly. *If
> the file name contains a character such as a comma* which would otherwise
> serve to separate file names, you may put the file name in double quotes.
> There is no way to use a double quote character in a file name.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140225/3d29bdea/attachment.html>


More information about the llvm-commits mailing list