Skip to content

Commit

Permalink
[ELF] Rename R_TLS to R_TPREL and R_NEG_TLS to R_TPREL_NEG. NFC
Browse files Browse the repository at this point in the history
The scope of R_TLS (TP offset relocation types (TPREL/TPOFF) used for the
local-exec TLS model) is actually narrower than its name may imply. R_TLS_NEG
is only used by Solaris R_386_TLS_LE_32.

Rename them so that they will be less confusing.

Reviewed By: grimar, psmith, rprichard

Differential Revision: https://reviews.llvm.org/D93467
  • Loading branch information
MaskRay committed Dec 18, 2020
1 parent b88ed4e commit 22c1bd5
Show file tree
Hide file tree
Showing 13 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion lld/ELF/Arch/AArch64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ RelExpr AArch64::getRelExpr(RelType type, const Symbol &s,
case R_AARCH64_TLSLE_MOVW_TPREL_G1:
case R_AARCH64_TLSLE_MOVW_TPREL_G1_NC:
case R_AARCH64_TLSLE_MOVW_TPREL_G2:
return R_TLS;
return R_TPREL;
case R_AARCH64_CALL26:
case R_AARCH64_CONDBR19:
case R_AARCH64_JUMP26:
Expand Down
2 changes: 1 addition & 1 deletion lld/ELF/Arch/ARM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ RelExpr ARM::getRelExpr(RelType type, const Symbol &s,
case R_ARM_NONE:
return R_NONE;
case R_ARM_TLS_LE32:
return R_TLS;
return R_TPREL;
case R_ARM_V4BX:
// V4BX is just a marker to indicate there's a "bx rN" instruction at the
// given address. It can be used to implement a special linker mode which
Expand Down
2 changes: 1 addition & 1 deletion lld/ELF/Arch/Hexagon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ RelExpr Hexagon::getRelExpr(RelType type, const Symbol &s,
case R_HEX_TPREL_32_6_X:
case R_HEX_TPREL_HI16:
case R_HEX_TPREL_LO16:
return R_TLS;
return R_TPREL;
default:
error(getErrorLocation(loc) + "unknown relocation (" + Twine(type) +
") against symbol " + toString(s));
Expand Down
2 changes: 1 addition & 1 deletion lld/ELF/Arch/Mips.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ RelExpr MIPS<ELFT>::getRelExpr(RelType type, const Symbol &s,
case R_MIPS_TLS_TPREL64:
case R_MICROMIPS_TLS_TPREL_HI16:
case R_MICROMIPS_TLS_TPREL_LO16:
return R_TLS;
return R_TPREL;
case R_MIPS_PC32:
case R_MIPS_PC16:
case R_MIPS_PC19_S2:
Expand Down
2 changes: 1 addition & 1 deletion lld/ELF/Arch/PPC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ RelExpr PPC::getRelExpr(RelType type, const Symbol &s,
case R_PPC_TPREL16_HA:
case R_PPC_TPREL16_LO:
case R_PPC_TPREL16_HI:
return R_TLS;
return R_TPREL;
default:
error(getErrorLocation(loc) + "unknown relocation (" + Twine(type) +
") against symbol " + toString(s));
Expand Down
2 changes: 1 addition & 1 deletion lld/ELF/Arch/PPC64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1025,7 +1025,7 @@ RelExpr PPC64::getRelExpr(RelType type, const Symbol &s,
case R_PPC64_TPREL16_HIGHEST:
case R_PPC64_TPREL16_HIGHESTA:
case R_PPC64_TPREL34:
return R_TLS;
return R_TPREL;
case R_PPC64_DTPREL16:
case R_PPC64_DTPREL16_DS:
case R_PPC64_DTPREL16_HA:
Expand Down
2 changes: 1 addition & 1 deletion lld/ELF/Arch/RISCV.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ RelExpr RISCV::getRelExpr(const RelType type, const Symbol &s,
case R_RISCV_TPREL_HI20:
case R_RISCV_TPREL_LO12_I:
case R_RISCV_TPREL_LO12_S:
return R_TLS;
return R_TPREL;
case R_RISCV_RELAX:
case R_RISCV_TPREL_ADD:
return R_NONE;
Expand Down
2 changes: 1 addition & 1 deletion lld/ELF/Arch/SPARCV9.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ RelExpr SPARCV9::getRelExpr(RelType type, const Symbol &s,
return R_NONE;
case R_SPARC_TLS_LE_HIX22:
case R_SPARC_TLS_LE_LOX10:
return R_TLS;
return R_TPREL;
default:
error(getErrorLocation(loc) + "unknown relocation (" + Twine(type) +
") against symbol " + toString(s));
Expand Down
4 changes: 2 additions & 2 deletions lld/ELF/Arch/X86.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,9 @@ RelExpr X86::getRelExpr(RelType type, const Symbol &s,
case R_386_GOTOFF:
return R_GOTPLTREL;
case R_386_TLS_LE:
return R_TLS;
return R_TPREL;
case R_386_TLS_LE_32:
return R_NEG_TLS;
return R_TPREL_NEG;
case R_386_NONE:
return R_NONE;
default:
Expand Down
2 changes: 1 addition & 1 deletion lld/ELF/Arch/X86_64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ RelExpr X86_64::getRelExpr(RelType type, const Symbol &s,
case R_X86_64_DTPOFF64:
return R_DTPREL;
case R_X86_64_TPOFF32:
return R_TLS;
return R_TPREL;
case R_X86_64_TLSDESC_CALL:
return R_TLSDESC_CALL;
case R_X86_64_TLSLD:
Expand Down
4 changes: 2 additions & 2 deletions lld/ELF/InputSection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -812,7 +812,7 @@ uint64_t InputSectionBase::getRelocTargetVA(const InputFile *file, RelType type,
case R_RELAX_TLS_GD_TO_LE:
case R_RELAX_TLS_IE_TO_LE:
case R_RELAX_TLS_LD_TO_LE:
case R_TLS:
case R_TPREL:
// It is not very clear what to return if the symbol is undefined. With
// --noinhibit-exec, even a non-weak undefined reference may reach here.
// Just return A, which matches R_ABS, and the behavior of some dynamic
Expand All @@ -821,7 +821,7 @@ uint64_t InputSectionBase::getRelocTargetVA(const InputFile *file, RelType type,
return a;
return getTlsTpOffset(sym) + a;
case R_RELAX_TLS_GD_TO_LE_NEG:
case R_NEG_TLS:
case R_TPREL_NEG:
if (sym.isUndefined())
return a;
return -getTlsTpOffset(sym) + a;
Expand Down
2 changes: 1 addition & 1 deletion lld/ELF/Relocations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1073,7 +1073,7 @@ static void addPltEntry(PltSection *plt, GotPltSection *gotPlt,
static void addGotEntry(Symbol &sym) {
in.got->addEntry(sym);

RelExpr expr = sym.isTls() ? R_TLS : R_ABS;
RelExpr expr = sym.isTls() ? R_TPREL : R_ABS;
uint64_t off = sym.getGotOffset();

// If a GOT slot value can be calculated at link-time, which is now,
Expand Down
4 changes: 2 additions & 2 deletions lld/ELF/Relocations.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ enum RelExpr {
R_GOTPLT,
R_GOTPLTREL,
R_GOTREL,
R_NEG_TLS,
R_NONE,
R_PC,
R_PLT,
Expand All @@ -58,7 +57,8 @@ enum RelExpr {
R_RELAX_TLS_LD_TO_LE,
R_RELAX_TLS_LD_TO_LE_ABS,
R_SIZE,
R_TLS,
R_TPREL,
R_TPREL_NEG,
R_TLSDESC,
R_TLSDESC_CALL,
R_TLSDESC_PC,
Expand Down

0 comments on commit 22c1bd5

Please sign in to comment.