<div dir="ltr"><div class="gmail_extra"><div>On Sun, Oct 6, 2013 at 7:38 PM, Shankar Easwaran <span dir="ltr"><<a href="mailto:shankare@codeaurora.org" target="_blank">shankare@codeaurora.org</a>></span> wrote:<br></div>
<div class="gmail_quote"><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="im">On 10/4/2013 11:16 PM, Michael Spencer 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 Fri, Oct 4, 2013 at 8:50 PM, Shankar Easwaran <<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,<br>
<br>
It is needed that lld verifies the input to the linker.<br>
<br>
For example : a x86 ELF file can be given to lld when the target is<br>
x86_64. Similiarly with other flavors.<br>
<br>
I was thinking to have a varargs function in the LinkingContext that would<br>
be overridden by each of the LinkingContexts to verify files after being<br>
read.<br>
<br>
The reader would call the varargs function in the LinkingContext and raise<br>
an error if the input is not suitable with the current link mode.<br>
<br>
Thanks<br>
<br>
Shankar Easwaran<br>
<br>
--<br>
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted<br>
by the Linux Foundation<br>
<br>
<br>
</blockquote>
Why would it need to be varargs?<br>
</blockquote></div>
LinkingContext for ELF would require fields from the ELF header to verify if the file thats being read belongs to the current target architecture.<br>
<br>
I am not sure of how many fields would determine the same for Darwin and COFF.<br>
<br>
This is the reason I thought it should be varargs.</blockquote><div><br></div><div>The reader has an {ELF,COFF,Darwin}LinkingContext. It can just ask the context.</div><div> </div><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="im"><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">
Also, parse can just return an error that<br>
specifies the format is wrong.<br>
</blockquote></div>
It would still need to call the LinkingContext to figure out if the format is associated with the target.</blockquote><div><br></div><div>Exactly.</div><div> </div><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="im"><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">
Specifically this would be a good place to use the user data part of<br>
ErrorOr to specify what was expected and what was received.<br>
</blockquote></div>
Couldnt follow this. Can you elaborate ?</blockquote><div><br></div><div>ErrorOr supports user data. See unittests/Support/ErrorOrTest.cpp.</div><div><br></div><div>It would simply be: return ArchMismatch(expected, actual);</div>
<div><br></div><div>Then an error handler higher up can extract that to form a proper error message.</div><div><br></div><div>- Michael Spencer<br></div><div> </div><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=""><div class="h5"><br>
<br>
Thanks<br>
<br>
Shankar Easwaran<br>
<br>
-- <br>
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by the Linux Foundation<br>
<br>
</div></div></blockquote></div><br></div></div>