Skip to content
This repository was archived by the owner on Feb 5, 2019. It is now read-only.

Commit 86c7a99

Browse files
Simon Dardisalexcrichton
authored andcommitted
[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 83b72ce commit 86c7a99

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
@@ -240,8 +240,6 @@ void MipsMCExpr::fixELFSymbolsInTLSFixups(MCAssembler &Asm) const {
240240
break;
241241
case MEK_CALL_HI16:
242242
case MEK_CALL_LO16:
243-
case MEK_DTPREL_HI:
244-
case MEK_DTPREL_LO:
245243
case MEK_GOT:
246244
case MEK_GOT_CALL:
247245
case MEK_GOT_DISP:
@@ -257,14 +255,16 @@ void MipsMCExpr::fixELFSymbolsInTLSFixups(MCAssembler &Asm) const {
257255
case MEK_NEG:
258256
case MEK_PCREL_HI16:
259257
case MEK_PCREL_LO16:
260-
case MEK_TLSLDM:
261258
// If we do have nested target-specific expressions, they will be in
262259
// a consecutive chain.
263260
if (const MipsMCExpr *E = dyn_cast<const MipsMCExpr>(getSubExpr()))
264261
E->fixELFSymbolsInTLSFixups(Asm);
265262
break;
266-
case MEK_GOTTPREL:
263+
case MEK_DTPREL_HI:
264+
case MEK_DTPREL_LO:
265+
case MEK_TLSLDM:
267266
case MEK_TLSGD:
267+
case MEK_GOTTPREL:
268268
case MEK_TPREL_HI:
269269
case MEK_TPREL_LO:
270270
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)