<div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Feb 24, 2014 at 11:38 PM, Rui Ueyama <span dir="ltr"><<a href="mailto:ruiu@google.com" target="_blank">ruiu@google.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div class="">On Mon, Feb 24, 2014 at 11:24 PM, Shankar Easwaran <span dir="ltr"><<a href="mailto:shankare@codeaurora.org" target="_blank">shankare@codeaurora.org</a>></span> wrote:<br>


<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div>On 2/25/2014 1:14 AM, Rui Ueyama wrote:<br>

<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
On Mon, Feb 24, 2014 at 10:52 PM, Shankar Easwaran<br>
<<a href="mailto:shankare@codeaurora.org" target="_blank">shankare@codeaurora.org</a>><u></u>wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
Hi Chandler, Rui,<br>
<br>
For example :-<br>
<br>
OUTPUT_FORMAT(x, "y", "z")<br>
<br>
We need to display an error for the above case, while<br>
<br>
OUTPUT_FORMAT("x", "y", "z") produces no error.<br>
<br>
</blockquote>
Both gave me error...<br>
</blockquote></div>
I am not sure about your ld version, but here it is :-<br>
<br>
$cat x<br>
OUTPUT_FORMAT(x, "y", "z");<div><br>
$ld -T x<br>
ld:x:1: syntax error<br></div>
$cat y<br>
OUTPUT_FORMAT("x", "y", "z");<br>
$ld -T y<br>
ld: no input files</blockquote><div><br></div></div><div>OUTPUT_FORMAT( x , "y", "z");</div><div><br></div><div>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.</div>
</blockquote></div><br>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.</div><div class="gmail_extra">
<br></div><div class="gmail_extra">Note that on my x86 box, the three argument form won't even parse for me, likely because of a lack of BE/LE support. Either way, *all three* arguments to the OUTPUT_FORMAT command are 'bfdname's and not file names. So if you want to error on using "s, you have to error on using "s in any of the three arguments.</div>
<div class="gmail_extra"><br></div><div class="gmail_extra">We can test what LD *actually* does by using a valid format and a single output format argument:</div><div class="gmail_extra"><br></div><div class="gmail_extra">
% echo 'OUTPUT_FORMAT("elf64-x86-64");' > x</div><div class="gmail_extra">% ld -T x</div><div class="gmail_extra">ld: no input files</div><div class="gmail_extra">% ld.gold -T x</div><div class="gmail_extra">
ld.gold: fatal error: no input files</div><div class="gmail_extra"><br></div><div class="gmail_extra">So both ld and gold are happy with quotes around a bfdname.</div><div class="gmail_extra"><br></div><div class="gmail_extra">
<br></div><div class="gmail_extra">Other sources of actual information are the manual pages for the linker itself:</div><div class="gmail_extra"><br></div><div class="gmail_extra"><a href="https://sourceware.org/binutils/docs/ld/Script-Format.html#Script-Format">https://sourceware.org/binutils/docs/ld/Script-Format.html#Script-Format</a><br>
</div><div class="gmail_extra"><br></div><div class="gmail_extra">This is hardly a specification, but it gives some clear indication of the systax: commands followed by arguments. While it only mentions using quoted strings for file names with random characters in them, that clearly can't be taken literally. As I've shown above both linkers accept quoted strings around 'bfdname' arguments to commands. Also, there are cases where it is clearly required:</div>
<div class="gmail_extra"><br></div><div class="gmail_extra">ENTRY("=foo");</div><div class="gmail_extra"><br></div><div class="gmail_extra">There are manglings which use '=' in their symbol names so this could well be necessary. Both linkers seem to accept it happily.</div>
</div>