<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Wed, Jul 6, 2016 at 9:43 AM, John McCall <span dir="ltr">&lt;<a href="mailto:rjmccall@apple.com" target="_blank">rjmccall@apple.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div><span class=""><blockquote type="cite"><div>On Jul 6, 2016, at 7:33 AM, Saleem Abdulrasool &lt;<a href="mailto:compnerd@compnerd.org" target="_blank">compnerd@compnerd.org</a>&gt; wrote:</div><div><div dir="ltr">On Tue, Jul 5, 2016 at 6:28 PM, John McCall <span dir="ltr">&lt;<a href="mailto:rjmccall@apple.com" target="_blank">rjmccall@apple.com</a>&gt;</span> wrote:<br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><span><div><blockquote type="cite"><div>On Jul 5, 2016, at 5:56 PM, Saleem Abdulrasool &lt;<a href="mailto:compnerd@compnerd.org" target="_blank">compnerd@compnerd.org</a>&gt; wrote:</div><div><div dir="ltr">On Tue, Jul 5, 2016 at 10:30 AM, John McCall <span dir="ltr">&lt;<a href="mailto:rjmccall@apple.com" target="_blank">rjmccall@apple.com</a>&gt;</span> wrote:<br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span>&gt; On Jul 3, 2016, at 2:40 PM, Saleem Abdulrasool &lt;<a href="mailto:compnerd@compnerd.org" target="_blank">compnerd@compnerd.org</a>&gt; wrote:<br>
&gt; Hello again,<br>
&gt;<br>
&gt; I come bearing more problems :-).<br>
&gt;<br>
&gt; I seem to have found another point in the ABI which prevents an easy port of swift to Windows without an emulation layer underneath.  This time it deals with the protocol conformance table.  The table is constructed with a direct reference to protocol.  However, because the protocol lies in an external module, this ends up being a problem as it must be indirectly addressed.<br>
&gt;<br>
&gt; There is a workaround in place for generating a GOT equivalent entry, however, that still doesnt indirect through the pointer, which needs to be done to address the executable model on Windows.<br>
<br>
</span>Is it not possible to emit the GOT equivalent entry as a reference to the appropriate entry in the import lookup table?</blockquote><div><br></div><div>I had tried that, but it would still just be a constant reference to the value rather than the synthetic.  Perhaps I am misunderstanding something?</div></div></div></div></div></blockquote><div><br></div></div></span>I don&#39;t know what you mean.  I assume this is the reference to the protocol structure from the global protocol-conformances list.  This reference is a relative offset, either directly to the protocol structure or indirectly to a global containing a pointer to an external protocol structure.  PE&#39;s import lookup table is an array of pointers to external objects.</div></blockquote><div><br></div><div>Exactly, in the case that identified the issue, it is _TMps12OutputStream</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div>I could easily believe that COFF doesn&#39;t allow us to express a relative offset to an entry in the import lookup table.</div></div></blockquote><div><br></div><div>I don&#39;t think that there is any way to represent that in IR, and I don&#39;t know if COFF allows us to encode such a thing.  I will see if I can construct an object file/library and see if we can get away with that.</div></div></div></div></div></blockquote><div><br></div></span>The way to represent it in IR is using the same private unnamed_addr representation that we special-case for ELF/Mach-O.  I guess it would be a mandatory transformation for COFF.</div><div><br></div><div>But if it&#39;s not representable in COFF, that&#39;s pretty conclusive.</div></div></blockquote><div><br></div><div>I did look into this.  It is, as I suspected, not possible to represent an offset to the value in the ILT or IAT.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><span class="HOEnZb"><font color="#888888"><div>John.</div></font></span><span class=""><div><br><blockquote type="cite"><div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div>  However, it sounds like you think this needs to be *doubly* indirected, i.e. the conformance list needs to be a relative offset to a variable containing a pointer to a variable containing a pointer to the import lookup table.  I&#39;m not sure why that would be. </div></div></blockquote><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><span><font color="#888888"><div>John.</div></font></span></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div data-smartmail="gmail_signature">Saleem Abdulrasool<br>compnerd (at) compnerd (dot) org</div>
</div></div>
</div></blockquote></div><br></span></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature">Saleem Abdulrasool<br>compnerd (at) compnerd (dot) org</div>
</div></div>