<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div><blockquote type="cite" class=""><div class="">On May 19, 2016, at 5:39 PM, Saleem Abdulrasool &lt;<a href="mailto:compnerd@compnerd.org" class="">compnerd@compnerd.org</a>&gt; wrote:</div><div class=""><div dir="ltr" class="">On Thu, May 19, 2016 at 9:07 AM, John McCall <span dir="ltr" class="">&lt;<a href="mailto:rjmccall@apple.com" target="_blank" class="">rjmccall@apple.com</a>&gt;</span> wrote:<br class=""><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 class="">&gt; On May 18, 2016, at 1:51 PM, Saleem Abdulrasool &lt;<a href="mailto:compnerd@compnerd.org" class="">compnerd@compnerd.org</a>&gt; wrote:<br class="">
&gt; Hi,<br class="">
&gt;<br class="">
&gt; It seems that there are assumptions about the ability to create relative address across sections which doesn't seem possible on Windows ARM.<br class="">
&gt;<br class="">
&gt; Consider the following swift code:<br class="">
&gt;<br class="">
&gt; final class _ContiguousArrayStorage&lt;Element&gt; { }<br class="">
&gt;<br class="">
&gt; When compiled for Windows x86 (via swiftc -c -target i686-windows -parse-as-library -parse-stdlib -module-name Swift -o Swift.obj reduced.swift) it will generate the metadata pattern as:<br class="">
&gt;<br class="">
&gt;&nbsp; &nbsp; &nbsp;__TMPCs23_ContiguousArrayStorage:<br class="">
&gt;&nbsp; &nbsp; &nbsp; &nbsp;...<br class="">
&gt;&nbsp; &nbsp; &nbsp; &nbsp;.long __TMnCs23_ContiguousArrayStorage-(__MPCs23_ContiguousArrayStorage+128)<br class="">
&gt;&nbsp; &nbsp; &nbsp; &nbsp;...<br class="">
&gt;<br class="">
&gt; This generates a IMAGE_REL_I386_REL32 relocation which is the 32-bit relative displacement of the target.<br class="">
&gt;<br class="">
&gt; On Windows ARM (swiftc -c -target i686-windows -parse-pas-library -parse-stdlib -module-name Swift -o Swift.obj reduced.swift) it will generate similar assembly:<br class="">
&gt;<br class="">
&gt;&nbsp; &nbsp; &nbsp;_TMPCs23_ContiguousArrayStorage:<br class="">
&gt;&nbsp; &nbsp; &nbsp; &nbsp;...<br class="">
&gt;&nbsp; &nbsp; &nbsp; &nbsp;.long _TMnCs23_ContiguousArrayStorage-(_MPCs23_ContiguousArrayStorage+128)<br class="">
&gt;&nbsp; &nbsp; &nbsp; &nbsp;...<br class="">
&gt;<br class="">
&gt; However, this generates an IMAGE_REL_ARM_ADDR32 relocation which is the 32-bit VA of the target.&nbsp; If the symbol are in the same section, it is possible to get a relative value.&nbsp; However, I don't really see a way to generate a relative offset across sections.&nbsp; There is no relocation in the COFF ARM specification which provides the 32-bit relative displacement of the target.&nbsp; There are 20, 23, and 24 bit relative displacements designed specifically for branch instructions, but none that would operate on generic data.<br class="">
&gt;<br class="">
&gt; Is there a good way to address this ABI issue?&nbsp; Or perhaps do we need something more invasive to support such targets?&nbsp; Now, I might be completely overlooking something simple that I didn't consider, so pointing that out would be greatly appreciated as well.<br class="">
<br class="">
</span>You can build PIC on Windows ARM, right?&nbsp; How does Microsoft compile this:<br class="">
<br class="">
&nbsp; static int x;<br class="">
&nbsp; int *get_x_addr() { return &amp;x; }</blockquote><div class=""><br class=""></div><div class="">It will generate what they call a based relocation, relying on the DLL sliding to adjust for the load at an address other than the preferred base address.</div></div></div></div></div></blockquote><div><br class=""></div></div>Okay, so an absolute address and metadata to do a fix-up, i.e. not PIC. &nbsp;Score one for Joe.<div class=""><br class=""></div><div class="">I guess it's probably not reasonable to assume that&nbsp;IMAGE_REL_ARM_BRANCH24 will just work. :) &nbsp;16M is not really a reasonable max image size anyway.</div><div class=""><br class=""></div><div class="">Well, if we wanted to be adventurous, we could ask Microsoft to add an IMAGE_REL_ARM_REL32 relocation in a future toolchain. &nbsp;What we're asking of the ELF and Mach-O linkers isn't all that much less ridiculous... In the meantime, yeah, we should probably just switch to absolute addressing; it should be easy enough to generalize that in the metadata scheme.<br class=""><div class=""><br class=""></div><div class="">John.</div></div></body></html>