[llvm-dev] RFC: LLD range extension thunks

Peter Smith via llvm-dev llvm-dev at lists.llvm.org
Thu Jan 19 02:33:08 PST 2017


I think anything that we come up with will need to support Mips as
well as ARM and AArch64. I'm aware of the Mips LA25 Thunk and the need
for these Thunks to be placed before the Target Section. I'm intending
that the first patch that uses synthetic sections for Thunks will do
this. I'm not intending to go looking for new Mips Thunk types to
implement, I think it would be better that someone with more
experience of Mips and an ability to test properly, implemented these
[*]. I'm similarly ignorant of Power, which has limited range branch
instructions.

My plan for implementation so far is to convert the existing
implementation to use synthetic sections without trying to do range
extension. When that is in and working we can build upon that to
include range extension. If we can make the range detection and thunk
placement sufficiently flexible it shouldn't be difficult to add new
Thunks later.

[*] I can see that the pseudo-direct addressing used by J and JAL
instructions could in principle have range extension thunks and would
need different handling to ARM/AArch64 branches with PC-relative
offsets. I'm not sure whether Mips toolchains typically do use Thunks
in this case or if it is the caller's responsibility to use an
indirect jump via JR instead.


On 18 January 2017 at 23:59, Simon Atanasyan <simon at atanasyan.com> wrote:
>
>
> On Jan 19, 2017 2:48 AM, "Ed Maste" <emaste at freebsd.org> wrote:
>
> On 4 January 2017 at 13:34, Peter Smith via llvm-dev
> <llvm-dev at lists.llvm.org> wrote:
>> I'm about to start working on range extension thunks in lld. This is
>> an attempt to summarize the approach I'd like to take and what the
>> impact will be on lld outside of thunks.
>
> Now that LLD works well for FreeBSD/amd64 (and arm64 is very close)
> I'm looking at other architectures, starting with mips64. The
> statically-linked toolchain components currently fail to link with an
> out of range jump, so I'm very interested in seeing this work
> progress. Are you looking at only arm and AArch64? Once the
> infrastructure is in I'll try to take a look at mips if nobody else
> does first.
>
>
> I'm waiting for this changes too. Now mips thunks places at the end of the
> corresponding section. Not sure about FreeBSD but on Linux that leads to
> incorrect code in case of static linking -- a thunk goes between crt*.o
> files which needs to be "joined" together. Gnu linker puts thunks to the
> separate section. We need to do the same thing.


More information about the llvm-dev mailing list