[llvm] fabd71e - [CSKY] STT_TLS
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Sat Mar 22 21:21:08 PDT 2025
Author: Fangrui Song
Date: 2025-03-22T21:12:39-07:00
New Revision: fabd71e6c23a58f1feafba5d7c85414f96a38ab0
URL: https://github.com/llvm/llvm-project/commit/fabd71e6c23a58f1feafba5d7c85414f96a38ab0
DIFF: https://github.com/llvm/llvm-project/commit/fabd71e6c23a58f1feafba5d7c85414f96a38ab0.diff
LOG: [CSKY] STT_TLS
Added:
llvm/test/MC/CSKY/relocation-specifier.s
Modified:
llvm/lib/Target/CSKY/MCTargetDesc/CSKYELFObjectWriter.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/CSKY/MCTargetDesc/CSKYELFObjectWriter.cpp b/llvm/lib/Target/CSKY/MCTargetDesc/CSKYELFObjectWriter.cpp
index 4471c1cc05d99..48eab15a68d94 100644
--- a/llvm/lib/Target/CSKY/MCTargetDesc/CSKYELFObjectWriter.cpp
+++ b/llvm/lib/Target/CSKY/MCTargetDesc/CSKYELFObjectWriter.cpp
@@ -39,6 +39,18 @@ unsigned CSKYELFObjectWriter::getRelocType(MCContext &Ctx,
// Determine the type of the relocation
unsigned Kind = Fixup.getTargetKind();
uint8_t Modifier = Target.getAccessVariant();
+ switch (Modifier) {
+ case CSKYMCExpr::VK_TLSGD:
+ case CSKYMCExpr::VK_TLSLDM:
+ case CSKYMCExpr::VK_TLSLDO:
+ case CSKYMCExpr::VK_TLSIE:
+ case CSKYMCExpr::VK_TLSLE:
+ if (auto *S = Target.getSymA())
+ cast<MCSymbolELF>(S->getSymbol()).setType(ELF::STT_TLS);
+ break;
+ default:
+ break;
+ }
if (IsPCRel) {
switch (Kind) {
diff --git a/llvm/test/MC/CSKY/relocation-specifier.s b/llvm/test/MC/CSKY/relocation-specifier.s
new file mode 100644
index 0000000000000..51b40376cb2a0
--- /dev/null
+++ b/llvm/test/MC/CSKY/relocation-specifier.s
@@ -0,0 +1,15 @@
+# RUN: llvm-mc -filetype=obj -triple=csky -mattr=+2e3 %s -o %t
+# RUN: llvm-readelf -s - < %t | FileCheck %s --check-prefix=READELF --implicit-check-not=TLS
+
+# READELF: TLS GLOBAL DEFAULT UND gd
+# READELF: TLS GLOBAL DEFAULT UND ld
+# READELF: TLS GLOBAL DEFAULT UND ie
+# READELF: TLS GLOBAL DEFAULT UND le
+
+lrw16 r0, gd at TLSGD32
+lrw16 r0, ld at TLSLDM32
+lrw16 r3, ie at GOTTPOFF
+lrw16 r3, le at TPOFF
+
+.data
+.long got at GOT
More information about the llvm-commits
mailing list