[JITLink] Adds support for PLT based relocations to the ELF/i386 JITLink backend
authorKshitij Jain <jkshtj@outlook.com>
Sun, 29 Jan 2023 17:19:41 +0000 (17:19 +0000)
committerKshitij Jain <jkshtj@outlook.com>
Mon, 30 Jan 2023 01:15:34 +0000 (01:15 +0000)
commitcd9fd4255b48e6c759aa09a4d91249def330b835
tree7f591f73f51a7bff653b9825c17f5a87c5303eb3
parent1738d046631aed29c2ce7e3b1e79c1ba81eef27d
[JITLink] Adds support for PLT based relocations to the ELF/i386 JITLink backend

This commit adds support for PLT based relocations. Specifically -
1. It adds logic to create a `PLTTableManager` in the `buildTables_ELF_i386`
function, which is called as part of the post-prune JITLink passes. The `PLTTableManager`
handles creating pointer jump stubs and related GOT entries for position independent
code.

2. It also adds a pre-fixup pass to optimize away PLT based calls in position independent
code, when possible.

Reviewed By: lhames

Differential Revision: https://reviews.llvm.org/D142846
llvm/include/llvm/ExecutionEngine/JITLink/i386.h
llvm/lib/ExecutionEngine/JITLink/ELF_i386.cpp
llvm/lib/ExecutionEngine/JITLink/i386.cpp
llvm/test/ExecutionEngine/JITLink/i386/ELF_i386_small_pic_relocations_got.s [moved from llvm/test/ExecutionEngine/JITLink/i386/ELF_i386_small_pic_relocations.s with 78% similarity]
llvm/test/ExecutionEngine/JITLink/i386/ELF_i386_small_pic_relocations_plt.s [new file with mode: 0644]