[JITLink][ELF][AArch64] Implement Procedure Linkage Table.
authorSunho Kim <ksunhokim123@naver.com>
Fri, 10 Jun 2022 04:46:31 +0000 (13:46 +0900)
committerSunho Kim <ksunhokim123@naver.com>
Fri, 10 Jun 2022 05:44:33 +0000 (14:44 +0900)
commit87c4268329072153f178d554e138166d579f18b9
treeab3df5622775ac6d74d7a87558260cda5452c64a
parente9f2d47bfe29c31c7a1b43a2cc503ed9cdc0fbad
[JITLink][ELF][AArch64] Implement Procedure Linkage Table.

Implements Procedure Linkage Table (PLT) for ELF/AARCH64. The aarch64 linux calling convention also uses r16 as the intra-procedure-call scratch register same as MachO/ARM64. We can use the same stub sequence for this reason.

Also, BR regiseter doesn't touch X30 register. External function call by BL instruction (touched by CALL26 relocation) will set X30 to the original PC + 4, which is the intended behavior. External function call by B instruction (touched by JUMP26 relocation) doesn't requite to set X30, so the patch will be correct in this case too.

Reference: https://github.com/ARM-software/abi-aa/blob/main/aapcs64/aapcs64.rst#611general-purpose-registers

Reviewed By: lhames

Differential Revision: https://reviews.llvm.org/D127061
llvm/lib/ExecutionEngine/JITLink/ELF_aarch64.cpp
llvm/test/ExecutionEngine/JITLink/AArch64/ELF_aarch64_relocations.s