Skip to content

Commit 5adbfdd

Browse files
committed
[mips] Assign R_TLS type to the R_MIPS_TLS_TPREL_XXX relocations. NFC
That allows to remove duplicated code which subtracts 0x7000 from the R_MIPS_TLS_TPREL_XXX relocations values in the `MIPS::relocateOne` function. llvm-svn: 366888
1 parent 3daefb0 commit 5adbfdd

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

lld/ELF/Arch/Mips.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -120,15 +120,16 @@ RelExpr MIPS<ELFT>::getRelExpr(RelType type, const Symbol &s,
120120
case R_MIPS_TLS_DTPREL_LO16:
121121
case R_MIPS_TLS_DTPREL32:
122122
case R_MIPS_TLS_DTPREL64:
123+
case R_MICROMIPS_TLS_DTPREL_HI16:
124+
case R_MICROMIPS_TLS_DTPREL_LO16:
125+
return R_ABS;
123126
case R_MIPS_TLS_TPREL_HI16:
124127
case R_MIPS_TLS_TPREL_LO16:
125128
case R_MIPS_TLS_TPREL32:
126129
case R_MIPS_TLS_TPREL64:
127-
case R_MICROMIPS_TLS_DTPREL_HI16:
128-
case R_MICROMIPS_TLS_DTPREL_LO16:
129130
case R_MICROMIPS_TLS_TPREL_HI16:
130131
case R_MICROMIPS_TLS_TPREL_LO16:
131-
return R_ABS;
132+
return R_TLS;
132133
case R_MIPS_PC32:
133134
case R_MIPS_PC16:
134135
case R_MIPS_PC19_S2:
@@ -538,11 +539,6 @@ void MIPS<ELFT>::relocateOne(uint8_t *loc, RelType type, uint64_t val) const {
538539
type == R_MICROMIPS_TLS_DTPREL_HI16 ||
539540
type == R_MICROMIPS_TLS_DTPREL_LO16) {
540541
val -= 0x8000;
541-
} else if (type == R_MIPS_TLS_TPREL_HI16 || type == R_MIPS_TLS_TPREL_LO16 ||
542-
type == R_MIPS_TLS_TPREL32 || type == R_MIPS_TLS_TPREL64 ||
543-
type == R_MICROMIPS_TLS_TPREL_HI16 ||
544-
type == R_MICROMIPS_TLS_TPREL_LO16) {
545-
val -= 0x7000;
546542
}
547543

548544
switch (type) {

lld/ELF/InputSection.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -619,6 +619,7 @@ static int64_t getTlsTpOffset(const Symbol &s) {
619619
case EM_X86_64:
620620
// Variant 2. The TLS segment is located just before the thread pointer.
621621
return s.getVA(0) - alignTo(Out::tlsPhdr->p_memsz, Out::tlsPhdr->p_align);
622+
case EM_MIPS:
622623
case EM_PPC:
623624
case EM_PPC64:
624625
// The thread pointer points to a fixed offset from the start of the

0 commit comments

Comments
 (0)