<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Fri, Jun 3, 2016 at 2:28 AM, Peter Smith via llvm-dev <span dir="ltr"><<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">Hello everyone,<br>
<br>
The review <a href="http://reviews.llvm.org/D20951" rel="noreferrer">http://reviews.llvm.org/D20951</a> implements initial support<br>
for the ARM architecture in LLD. To keep the patch size down, and to<br>
avoid the complexities of interworking between ARM and Thumb, there<br>
is just enough support for an ARM only Hello World to link and run on<br>
ARM Linux [*].<br>
<br>
My main aim is to get this functionality committed as the basis of an<br>
ARM port and would like to know how best to go about this? I wanted to<br>
start the ARM port with enough functionality to execute at least one<br>
simple program, although this still might be too large to face in one<br>
review. I'm happy to split it up into a series of smaller patches with<br>
one relocation, one test file. Alternatively if you think more<br>
functionality is needed, please let me know what I need to complete<br>
for a first commit?<br>
<br>
The initial goal for Linaro is ARM Linux support for ARMv7 and AArch32<br>
ARMv8. With interworking, TLS and exceptions support the ARM support<br>
and test coverage should be on a par with the current state of the lld<br>
AArch64 support.<br>
<br>
There are several major pieces of work to do for ARM linux:<br>
<br>
My rough order of priority on what to work on next:<br>
<br>
Support for Thumb, Thumb2 and interworking:<br>
- Thumb relocation directives.<br>
- BL to BLX transformation for function calls between ARM and Thumb.<br>
- Thunk generation for B immediate.<br>
- Keeping track of which parts are ARM/Thumb.<br></blockquote><div><br></div><div>Simon implemented "thunk" for MIPS. Thunk contains linker-generated machine code and is added after each input section in the result and bridges incompatible function calls. I think you can use it for ARM thumb and non-thumb function calls.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">
Support for TLS<br>
- Add relocation and relaxation support for standard and descriptor<br>
based models.<br></blockquote><div><br></div><div>I think we already have a good foundation, so I guess you only need add architecture-specific code there in Relocations.cpp.</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">
Support for C++ exceptions:<br>
- Creation of a PT_ARM_EXIDX program header.<br>
- Support for the SHF_LINK_ORDER (used by .ARM.exidx).</blockquote><div><br></div><div>Is there anything special in them from the linker's perspective?</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">
Support for range-extension<br>
- Thumb2 BL range is only 16 Mb, conditional branch range is only 1<br>
Mb. Range extension thunks are likely to be needed for large programs.<br></blockquote><div><br></div><div>This can be added to thunks, I guess.</div><div> <br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">
Support for big-endian ARM targets<br>
- ARMv6 and above has little-endian instructions and big-endian data.<br>
The input objects for ARM have big-endian instructions so the linker<br>
must endian reverse each instruction.<br></blockquote><div><br></div><div>Does this mean you need to read every 4 bytes in .text (or 2 bytes if thumb) and swap the byte order of the word, if the target is big-endian? If the linker is supposed to do it, we have no choice other than doing it, but it's... weird.</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">
Use SHT_ARM_ATTRIBUTES sections for compatibility checking<br>
- Detect incompatible objects at link-time rather than risk runtime errors.<br></blockquote><div><br></div><div>You may want to take a look at isCompatible function in SymbolTable.cpp which does similar thing.<br></div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">
At this stage I haven't thought too hard about how best to implement<br>
these. I think that some of these may be disruptive enough to post<br>
design alternatives as RFCs rather than as reviews.<br>
<br>
[*] I tested hello world against an old GCC distribution that has ARM<br>
only libraries that do not require interworking:<br>
arm-none-linux-gnueabi-gcc (CodeSourcery Sourcery G++ Lite 2007q1-10)<br>
4.2.0.<br>
<br>
Documentation can be found in the ABI for the ARM Architecture, which<br>
is available on ARM's website:<br>
<a href="http://infocenter.arm.com/help/topic/com.arm.doc.subset.swdev.abi/index.html" rel="noreferrer">http://infocenter.arm.com/help/topic/com.arm.doc.subset.swdev.abi/index.html</a><br>
The official instruction encodings are documented in the ARM<br>
Architecture Reference Manual. This is publically available from ARM<br>
but requires a free registration to download:<br>
<a href="http://infocenter.arm.com/help/topic/com.arm.doc.ddi0406c/index.html" rel="noreferrer">http://infocenter.arm.com/help/topic/com.arm.doc.ddi0406c/index.html</a><br>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</blockquote></div><br></div></div>