Skip to content

Commit fabd71e

Browse files
committed
[CSKY] STT_TLS
1 parent beab1a6 commit fabd71e

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

llvm/lib/Target/CSKY/MCTargetDesc/CSKYELFObjectWriter.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,18 @@ unsigned CSKYELFObjectWriter::getRelocType(MCContext &Ctx,
3939
// Determine the type of the relocation
4040
unsigned Kind = Fixup.getTargetKind();
4141
uint8_t Modifier = Target.getAccessVariant();
42+
switch (Modifier) {
43+
case CSKYMCExpr::VK_TLSGD:
44+
case CSKYMCExpr::VK_TLSLDM:
45+
case CSKYMCExpr::VK_TLSLDO:
46+
case CSKYMCExpr::VK_TLSIE:
47+
case CSKYMCExpr::VK_TLSLE:
48+
if (auto *S = Target.getSymA())
49+
cast<MCSymbolELF>(S->getSymbol()).setType(ELF::STT_TLS);
50+
break;
51+
default:
52+
break;
53+
}
4254

4355
if (IsPCRel) {
4456
switch (Kind) {
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# RUN: llvm-mc -filetype=obj -triple=csky -mattr=+2e3 %s -o %t
2+
# RUN: llvm-readelf -s - < %t | FileCheck %s --check-prefix=READELF --implicit-check-not=TLS
3+
4+
# READELF: TLS GLOBAL DEFAULT UND gd
5+
# READELF: TLS GLOBAL DEFAULT UND ld
6+
# READELF: TLS GLOBAL DEFAULT UND ie
7+
# READELF: TLS GLOBAL DEFAULT UND le
8+
9+
lrw16 r0, gd@TLSGD32
10+
lrw16 r0, ld@TLSLDM32
11+
lrw16 r3, ie@GOTTPOFF
12+
lrw16 r3, le@TPOFF
13+
14+
.data
15+
.long got@GOT

0 commit comments

Comments
 (0)