[PATCH] D39744: [LLD][ELF][AArch64] Add support for AArch64 range extension thunks.

Rafael Avila de Espindola via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 24 16:26:55 PST 2017


Peter Smith via Phabricator <reviews at reviews.llvm.org> writes:

> - I've used Thunks that can access the whole address range. There are more efficient Thunks that can be used, for example the PI thunk could use the usual ADRP addressing mode, but this would limit the range to +/- 4Gb. In an ideal world we could generate the thunks with a limited range only when we know they are in range, but this will require some changes and additional complexity in the underlying framework so I chose to keep it simple.

Do you know what other linkers do? Do they start with a adrp and upgrade
the thunk if that is not sufficient?

On x86_64 the compiler is required to not use the small code model to
support more than 4gb. Is there something like it in aarch64?

> Index: test/ELF/aarch64-thunk-section-location.s
> ===================================================================
> --- /dev/null
> +++ test/ELF/aarch64-thunk-section-location.s
> @@ -0,0 +1,41 @@
> +// RUN: llvm-mc -filetype=obj -triple=aarch64-linux-gnu %s -o %t
> +// RUN: ld.lld %t -o %t2 2>&1
> +// RUN: llvm-objdump -d  -start-address=134086664 -stop-address=134086676 -triple=aarch64-linux-gnu %t2 | FileCheck %s
> +
> +// Check that the range extension thunks are dumped close to the aarch64 branch
> +// range of 128 MiB
> + .section .text.1, "ax", %progbits
> + .balign 0x1000
> + .globl _start
> +_start:
> + bl high_target
> + ret
> +
> + .section .text.2, "ax", %progbits
> + .space 0x2000000
> +
> + .section .text.2, "ax", %progbits
> + .space 0x2000000
> +
> + .section .text.3, "ax", %progbits
> + .space 0x2000000
> +
> + .section .text.4, "ax", %progbits
> + .space 0x2000000 - 0x40000
> +
> + .section .text.5, "ax", %progbits
> + .space 0x40000


Why do you need multiple sections instead of a single .space with the
total amount? To show that the thunk could have been placed earlier but
was not?

It is surprising that we expected support more than 4GB of code, but if
that is an aarch64 requirement, LGTM.

Cheers,
Rafael


More information about the llvm-commits mailing list