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

Rui Ueyama ruiu at google.com
Tue Feb 25 00:30:11 PST 2014


On Tue, Feb 25, 2014 at 12:23 AM, Shankar Easwaran
<shankare at codeaurora.org>wrote:

>  On 2/25/2014 2:03 AM, Chandler Carruth wrote:
>
> On Mon, Feb 24, 2014 at 11:38 PM, Rui Ueyama <ruiu at google.com> <ruiu at google.com> wrote:
>
>
>  On Mon, Feb 24, 2014 at 11:24 PM, Shankar Easwaran <shankare at codeaurora.org> wrote:
>
>
>  On 2/25/2014 1:14 AM, Rui Ueyama wrote:
>
>
>  On Mon, Feb 24, 2014 at 10:52 PM, Shankar Easwaran<shankare at codeaurora.org> <shankare at codeaurora.org>wrote:
>
>  Hi Chandler, Rui,
>
>  For example :-
>
> OUTPUT_FORMAT(x, "y", "z")
>
> We need to display an error for the above case, while
>
> OUTPUT_FORMAT("x", "y", "z") produces no error.
>
>  Both gave me error...
>
>   I am not sure about your ld version, but here it is :-
>
> $cat x
> OUTPUT_FORMAT(x, "y", "z");
>
> $ld -T x
> ld:x:1: syntax error
> $cat y
> OUTPUT_FORMAT("x", "y", "z");
> $ld -T y
> ld: no input files
>
>  OUTPUT_FORMAT( x , "y", "z");
>
> does not print an error (x with surrounding whitespaces). It's not a
> matter of double quotes? I found that some parentheses in Linux's libc.so
> are surrounded by whitespace characters too, so something may be wrong with
> "(" handling in GNU LD, but it seems to be different issue from quoted
> string.
>
>
>  I think the errors from OUTPUT_FORMAT with a string which is not a bfdname
> are red herrings. I don't think either GNU LD or Gold correctly recover
> from random strings used here.
>
>
> With proper strings, here is the behavior thats consistent with gold/ld.
>
> *Good case*
>
> $cat x1
> OUTPUT_FORMAT("elf64-x86-64", "elf64-x86-64", "elf64-x86-64");
>
> $ld -T x1
> ld: no input files
>
> $ld.gold -T x1
>
> ld.gold: fatal error: no input files
>
> *Bad case *
> $cat y1
> OUTPUT_FORMAT(elf64-x86-64, "elf64-x86-64", "elf64-x86-64");
>
> $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.
>

As I said many times in this thread, please add surrounding whitespaces
around the first argument. Both GNU LD and GOLD accepts it. If you make LLD
to reject such expression because the first argument not quoted by
doublequotes, it's going to be inconsistent with GNU LD/GOLD. It's worse
than accept-invalid because it's going to be an reject-valid issue.


>
> Thanks
>
> Shankar Easwaran
>
> --
> Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by the Linux Foundation
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140225/6019452d/attachment.html>


More information about the llvm-commits mailing list