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

Shankar Easwaran shankare at codeaurora.org
Tue Feb 25 00:23:25 PST 2014


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> 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>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.

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/49cef98c/attachment.html>


More information about the llvm-commits mailing list