[llvm] [PowerPC][JITLink] Support R_PPC64_GOT_TLSGD_PCREL34 (PR #68660)
Kai Luo via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 9 21:57:18 PDT 2023
https://github.com/bzEq created https://github.com/llvm/llvm-project/pull/68660
`R_PPC64_GOT_TLSGD_PCREL34` is generated for pwr10+.
>From 4b0f4431fd664c149b0694e4f17b0ed64c97f2e4 Mon Sep 17 00:00:00 2001
From: Kai Luo <lkail at cn.ibm.com>
Date: Tue, 10 Oct 2023 12:56:08 +0800
Subject: [PATCH] Support R_PPC64_GOT_TLSGD_PCREL34
---
.../llvm/ExecutionEngine/JITLink/ppc64.h | 1 +
llvm/lib/ExecutionEngine/JITLink/ELF_ppc64.cpp | 16 ++++++++++++----
llvm/lib/ExecutionEngine/JITLink/ppc64.cpp | 2 ++
.../JITLink/ppc64/ELF_ppc64_relocations.s | 18 ++++++++++++++++++
4 files changed, 33 insertions(+), 4 deletions(-)
diff --git a/llvm/include/llvm/ExecutionEngine/JITLink/ppc64.h b/llvm/include/llvm/ExecutionEngine/JITLink/ppc64.h
index 88af15d61e714e1..252dc1647639da6 100644
--- a/llvm/include/llvm/ExecutionEngine/JITLink/ppc64.h
+++ b/llvm/include/llvm/ExecutionEngine/JITLink/ppc64.h
@@ -60,6 +60,7 @@ enum EdgeKind_ppc64 : Edge::Kind {
RequestCallNoTOC,
RequestTLSDescInGOTAndTransformToTOCDelta16HA,
RequestTLSDescInGOTAndTransformToTOCDelta16LO,
+ RequestTLSDescInGOTAndTransformToDelta34,
};
enum PLTCallStubKind {
diff --git a/llvm/lib/ExecutionEngine/JITLink/ELF_ppc64.cpp b/llvm/lib/ExecutionEngine/JITLink/ELF_ppc64.cpp
index 5ce7a5bda840239..46f38b99ec8687b 100644
--- a/llvm/lib/ExecutionEngine/JITLink/ELF_ppc64.cpp
+++ b/llvm/lib/ExecutionEngine/JITLink/ELF_ppc64.cpp
@@ -43,17 +43,22 @@ class TLSInfoTableManager_ELF_ppc64
bool visitEdge(LinkGraph &G, Block *B, Edge &E) {
Edge::Kind K = E.getKind();
- if (K == ppc64::RequestTLSDescInGOTAndTransformToTOCDelta16HA) {
+ switch (K) {
+ case ppc64::RequestTLSDescInGOTAndTransformToTOCDelta16HA:
E.setKind(ppc64::TOCDelta16HA);
E.setTarget(this->getEntryForTarget(G, E.getTarget()));
return true;
- }
- if (K == ppc64::RequestTLSDescInGOTAndTransformToTOCDelta16LO) {
+ case ppc64::RequestTLSDescInGOTAndTransformToTOCDelta16LO:
E.setKind(ppc64::TOCDelta16LO);
E.setTarget(this->getEntryForTarget(G, E.getTarget()));
return true;
+ case ppc64::RequestTLSDescInGOTAndTransformToDelta34:
+ E.setKind(ppc64::Delta34);
+ E.setTarget(this->getEntryForTarget(G, E.getTarget()));
+ return true;
+ default:
+ return false;
}
- return false;
}
Symbol &createEntry(LinkGraph &G, Symbol &Target) {
@@ -366,6 +371,9 @@ class ELFLinkGraphBuilder_ppc64
case ELF::R_PPC64_GOT_TLSGD16_LO:
Kind = ppc64::RequestTLSDescInGOTAndTransformToTOCDelta16LO;
break;
+ case ELF::R_PPC64_GOT_TLSGD_PCREL34:
+ Kind = ppc64::RequestTLSDescInGOTAndTransformToDelta34;
+ break;
}
Edge GE(Kind, Offset, *GraphSymbol, Addend);
diff --git a/llvm/lib/ExecutionEngine/JITLink/ppc64.cpp b/llvm/lib/ExecutionEngine/JITLink/ppc64.cpp
index b147ffc8dac2175..a96ad15c6a32ee1 100644
--- a/llvm/lib/ExecutionEngine/JITLink/ppc64.cpp
+++ b/llvm/lib/ExecutionEngine/JITLink/ppc64.cpp
@@ -132,6 +132,8 @@ const char *getEdgeKindName(Edge::Kind K) {
return "RequestTLSDescInGOTAndTransformToTOCDelta16HA";
case RequestTLSDescInGOTAndTransformToTOCDelta16LO:
return "RequestTLSDescInGOTAndTransformToTOCDelta16LO";
+ case RequestTLSDescInGOTAndTransformToDelta34:
+ return "RequestTLSDescInGOTAndTransformToDelta34";
default:
return getGenericEdgeKindName(static_cast<Edge::Kind>(K));
}
diff --git a/llvm/test/ExecutionEngine/JITLink/ppc64/ELF_ppc64_relocations.s b/llvm/test/ExecutionEngine/JITLink/ppc64/ELF_ppc64_relocations.s
index 7e39a20ef6ab8b0..4034aa115d7d7a2 100644
--- a/llvm/test/ExecutionEngine/JITLink/ppc64/ELF_ppc64_relocations.s
+++ b/llvm/test/ExecutionEngine/JITLink/ppc64/ELF_ppc64_relocations.s
@@ -8,6 +8,7 @@
# RUN: --abs external_addr14_func=0x0880 \
# RUN: --abs external_addr16_data=0x6000 \
# RUN: --abs external_addr32_data=0x36668840 \
+# RUN: --abs pcrel_external_tls=0x36668880 \
# RUN: --check %s %t/elf_reloc.o
# RUN: llvm-mc --triple=powerpc64-unknown-linux-gnu --filetype=obj -o \
# RUN: %t/elf_reloc.o %s
@@ -18,6 +19,7 @@
# RUN: --abs external_addr14_func=0x0880 \
# RUN: --abs external_addr16_data=0x6000 \
# RUN: --abs external_addr32_data=0x36668840 \
+# RUN: --abs pcrel_external_tls=0x36668880 \
# RUN: --check %s %t/elf_reloc.o
# jitlink-check: section_addr(elf_reloc.o, $__GOT) + 0x8000 = __TOC__
@@ -240,6 +242,22 @@ reloc_rel16:
blr
.size reloc_rel16, .-reloc_rel16
+ .global reloc_tlsgd_pcrel34
+ .p2align 4
+ .type reloc_tlsgd_pcrel34, at function
+reloc_tlsgd_pcrel34:
+ mflr 0
+ std 0, 16(1)
+ stdu 1, -32(1)
+ paddi 3, 0, pcrel_external_tls at got@tlsgd at pcrel, 1
+ bl __tls_get_addr at notoc(a at tlsgd)
+ lwa 3, 0(3)
+ addi 1, 1, 32
+ ld 0, 16(1)
+ mtlr 0
+ blr
+ .size reloc_tlsgd_pcrel34,.-reloc_tlsgd_pcrel34
+
.type .L.str, at object
.section .rodata.str1.1,"aMS", at progbits,1
.L.str:
More information about the llvm-commits
mailing list