From 4747d6b0a50fe9fd22c03d10d72a748bef3edb58 Mon Sep 17 00:00:00 2001 From: Saleem Abdulrasool Date: Thu, 30 Jan 2014 04:02:38 +0000 Subject: [PATCH] ARM: support TLS descriptor relocations Add support for tlsdesc relocations which are part of the ABI, marked as experimental. These relocations permit the linker to perform TLS reference optimizations. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@200447 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/MC/MCExpr.h | 1 + lib/MC/MCExpr.cpp | 3 +++ lib/Target/ARM/MCTargetDesc/ARMELFObjectWriter.cpp | 3 +++ test/MC/ARM/symbol-variants.s | 6 ++++++ 4 files changed, 13 insertions(+) diff --git a/include/llvm/MC/MCExpr.h b/include/llvm/MC/MCExpr.h index b62252057f9..13f3ad0570b 100644 --- a/include/llvm/MC/MCExpr.h +++ b/include/llvm/MC/MCExpr.h @@ -167,6 +167,7 @@ public: VK_ARM_PREL31, VK_ARM_TLSLDO, // symbol(tlsldo) VK_ARM_TLSCALL, // symbol(tlscall) + VK_ARM_TLSDESC, // symbol(tlsdesc) VK_PPC_LO, // symbol@l VK_PPC_HI, // symbol@h diff --git a/lib/MC/MCExpr.cpp b/lib/MC/MCExpr.cpp index 3772bceea57..d402e6d896b 100644 --- a/lib/MC/MCExpr.cpp +++ b/lib/MC/MCExpr.cpp @@ -186,6 +186,7 @@ StringRef MCSymbolRefExpr::getVariantKindName(VariantKind Kind) { case VK_ARM_PREL31: return "prel31"; case VK_ARM_TLSLDO: return "tlsldo"; case VK_ARM_TLSCALL: return "tlscall"; + case VK_ARM_TLSDESC: return "tlsdesc"; case VK_PPC_LO: return "l"; case VK_PPC_HI: return "h"; case VK_PPC_HA: return "ha"; @@ -411,6 +412,8 @@ MCSymbolRefExpr::getVariantKindForName(StringRef Name) { .Case("tlsldo", VK_ARM_TLSLDO) .Case("TLSCALL", VK_ARM_TLSCALL) .Case("tlscall", VK_ARM_TLSCALL) + .Case("TLSDESC", VK_ARM_TLSDESC) + .Case("tlsdesc", VK_ARM_TLSDESC) .Default(VK_Invalid); } diff --git a/lib/Target/ARM/MCTargetDesc/ARMELFObjectWriter.cpp b/lib/Target/ARM/MCTargetDesc/ARMELFObjectWriter.cpp index 08c040235fd..5f719d5bb7c 100644 --- a/lib/Target/ARM/MCTargetDesc/ARMELFObjectWriter.cpp +++ b/lib/Target/ARM/MCTargetDesc/ARMELFObjectWriter.cpp @@ -266,6 +266,9 @@ unsigned ARMELFObjectWriter::GetRelocTypeInner(const MCValue &Target, case MCSymbolRefExpr::VK_ARM_TLSCALL: Type = ELF::R_ARM_TLS_CALL; break; + case MCSymbolRefExpr::VK_ARM_TLSDESC: + Type = ELF::R_ARM_TLS_GOTDESC; + break; } break; case ARM::fixup_arm_ldst_pcrel_12: diff --git a/test/MC/ARM/symbol-variants.s b/test/MC/ARM/symbol-variants.s index f0bf4c4b7c0..cf3535eafa4 100644 --- a/test/MC/ARM/symbol-variants.s +++ b/test/MC/ARM/symbol-variants.s @@ -77,3 +77,9 @@ bl f05(plt) @ CHECK: 88 R_ARM_TLS_CALL f22 @ CHECK: 92 R_ARM_TLS_CALL f23 +@ tlsdesc +.word f24(TLSDESC) +.word f25(tlsdesc) +@ CHECK: 96 R_ARM_TLS_GOTDESC f24 +@ CHECK: 100 R_ARM_TLS_GOTDESC f25 +