Skip to content
This repository was archived by the owner on Apr 23, 2020. It is now read-only.

Commit 194c54b

Browse files
author
Simon Dardis
committed
[mips] Fix PR35140
Mark all symbols involved with TLS relocations as being TLS symbols. This resolves PR35140. Thanks to Alex Crichton for reporting the issue! Reviewers: atanasyan Differential Revision: https://reviews.llvm.org/D39591 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@317470 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent d64a599 commit 194c54b

File tree

2 files changed

+32
-4
lines changed

2 files changed

+32
-4
lines changed

lib/Target/Mips/MCTargetDesc/MipsMCExpr.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -246,8 +246,6 @@ void MipsMCExpr::fixELFSymbolsInTLSFixups(MCAssembler &Asm) const {
246246
break;
247247
case MEK_CALL_HI16:
248248
case MEK_CALL_LO16:
249-
case MEK_DTPREL_HI:
250-
case MEK_DTPREL_LO:
251249
case MEK_GOT:
252250
case MEK_GOT_CALL:
253251
case MEK_GOT_DISP:
@@ -263,14 +261,16 @@ void MipsMCExpr::fixELFSymbolsInTLSFixups(MCAssembler &Asm) const {
263261
case MEK_NEG:
264262
case MEK_PCREL_HI16:
265263
case MEK_PCREL_LO16:
266-
case MEK_TLSLDM:
267264
// If we do have nested target-specific expressions, they will be in
268265
// a consecutive chain.
269266
if (const MipsMCExpr *E = dyn_cast<const MipsMCExpr>(getSubExpr()))
270267
E->fixELFSymbolsInTLSFixups(Asm);
271268
break;
272-
case MEK_GOTTPREL:
269+
case MEK_DTPREL_HI:
270+
case MEK_DTPREL_LO:
271+
case MEK_TLSLDM:
273272
case MEK_TLSGD:
273+
case MEK_GOTTPREL:
274274
case MEK_TPREL_HI:
275275
case MEK_TPREL_LO:
276276
fixELFSymbolsInTLSFixupsImpl(getSubExpr(), Asm);

test/MC/Mips/tls-symbols.s

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# RUN: llvm-mc -arch=mips < %s -position-independent -filetype=obj \
2+
# RUN: | llvm-readelf -symbols | FileCheck %s
3+
# RUN: llvm-mc -arch=mips < %s -filetype=obj | llvm-readelf -symbols \
4+
# RUN: | FileCheck %s
5+
6+
# Test that TLS relocations cause symbols to be marked as TLS symbols.
7+
8+
.set noat
9+
lui $3, %tlsgd(foo1)
10+
lui $1, %dtprel_hi(foo2)
11+
lui $1, %dtprel_lo(foo3)
12+
lui $1, %tprel_hi(foo4)
13+
lui $1, %tprel_lo(foo5)
14+
lw $2, %gottprel(foo6)($28)
15+
16+
.hidden foo1
17+
.hidden foo2
18+
.hidden foo3
19+
.hidden foo4
20+
.hidden foo5
21+
.hidden foo6
22+
23+
# CHECK: 1: {{.+}} {{.+}} TLS GLOBAL HIDDEN UND foo1
24+
# CHECK: 2: {{.+}} {{.+}} TLS GLOBAL HIDDEN UND foo2
25+
# CHECK: 3: {{.+}} {{.+}} TLS GLOBAL HIDDEN UND foo3
26+
# CHECK: 4: {{.+}} {{.+}} TLS GLOBAL HIDDEN UND foo4
27+
# CHECK: 5: {{.+}} {{.+}} TLS GLOBAL HIDDEN UND foo5
28+
# CHECK: 6: {{.+}} {{.+}} TLS GLOBAL HIDDEN UND foo6

0 commit comments

Comments
 (0)