10 Commits

Author SHA1 Message Date
Kai Luo
18dc8dcd76
[PowerPC][JITLink] Support R_PPC64_GOT_TLSGD_PCREL34 (#68660)
`R_PPC64_GOT_TLSGD_PCREL34` is generated for pwr10+.
2023-10-14 10:57:03 +08:00
Kai Luo
a712244f3b
[PowerPC][JITLink] Support R_PPC64_GOT_PCREL34 (#68658)
`R_PPC64_GOT_PCREL34` is generated for pwr10+.
2023-10-13 08:51:11 +08:00
Kai Luo
b6e2eac293 [JITLink][PowerPC] Add relocations included in rtdyld but missing from jitlink
RuntimeDyld has implemented more relocations than JITLink for ppc64. This patch adds relocations missing from JITLink for ppc64.

Reviewed By: lhames

Differential Revision: https://reviews.llvm.org/D157366
2023-08-13 09:44:18 +08:00
Kai Luo
9c38a178d3 [JITLink][PowerPC] Add basic TLS support for ppc64
Add basic TLS support for ppc64. Only global-dynamic model is supported.

Reviewed By: lhames

Differential Revision: https://reviews.llvm.org/D155926
2023-08-02 05:02:36 +00:00
Kai Luo
ca6d86f6bf [JITLink][PowerPC] Support R_PPC64_PCREL34
PC-relative instructions are added in ISA-3.1 implemented by pwr10. This patch adds basic pc-relative relocation.

Reviewed By: lhames

Differential Revision: https://reviews.llvm.org/D155771
2023-08-02 02:00:38 +00:00
Kai Luo
11a02de782 [JITLink][PowerPC] Change method to check if a symbol is external to current object
After PrePrunePass `claimOrExternalizeWeakAndCommonSymbols`, a defined symbol might become external. So determine a function call is external or not when building the linkgraph is not accurate. This largely affects updating TOC pointer on PowerPC. TOC pointer is supposed to be the same in one object file(if no mulitple TOC appears) and is updated when control flow transferred to another object file.

This patch defers checking a function call is external or not, in `buildTables_ELF_ppc64` which is a PostPrunePass.

This patch fixes failures when `jitlink -orc-runtime=/path/to/libort_rt.a` is used.

Reviewed By: lhames

Differential Revision: https://reviews.llvm.org/D155925
2023-07-26 03:20:56 +00:00
Kai Luo
995f199f0a [JITLink][PowerPC] Correct handling of R_PPC64_REL24_NOTOC
According to the ELFv2 ABI

> This relocation type is used to specify a function call where the TOC pointer is not initialized. It is similar to R_PPC64_REL24 in that it specifies a symbol to be resolved. If the symbol resolves to a function that requires a TOC pointer (as determined by st_other bits) then a link editor must arrange for the call to be via the global entry point of the called function. Any stub code must not rely on a valid TOC base address in r2.

This patch fixes handling of `R_PPC64_REL24_NOTOC` by using the same stub code sequence as lld.

Reviewed By: lhames

Differential Revision: https://reviews.llvm.org/D155672
2023-07-24 14:00:53 +08:00
Kai Luo
61358d4fbe [JITLink][PowerPC] Add TOC and relocations for ppc64
This patch builds TOC and adds common relocations for ppc64.

To build TOC, sections belong to TOC are merged into one section, serves as GOT and small data accessing.

Relocations commonly seen in local function call, external function call and global variable reference are added.

References
- https://youtu.be/i-inxFudrgI
- https://maskray.me/blog/2023-02-26-linker-notes-on-power-isa
- https://openpowerfoundation.org/specifications/64bitelfabi/

Reviewed By: lhames

Differential Revision: https://reviews.llvm.org/D154198
2023-07-10 11:26:53 +08:00
Aaron Ballman
846bde483d Silence switch statement contains 'default' but no 'case' labels warning; NFC
These are showing up in MSVC builds.
2023-05-23 09:28:05 -04:00
Lang Hames
8313507a7c [JITLink][ELF][ppc64] Add skeleton ppc64 support and ELF/ppc64 JITLink backend.
This patch introduces a skeleton JITLink ppc64 support header and ELF/ppc64
backend. No relocations are supported in this initial version, but given a
program requiring no relocations (e.g. one that just returns a constant value
from main) the new backend is able to construct a LinkGraph from a ppc64 ELF
relocatable object, and the llvm-jitlink tool is able to execute it.

This commit should also serve as a good example of how to introduce a JITLink
backend for a new architecture.

Reviewed By: sgraenitz, v.g.vassilev, vchuravy, nemanjai, jain98, MaskRay

Differential Revision: https://reviews.llvm.org/D148192
2023-05-22 20:10:01 +00:00