[llvm] r185394 - [PowerPC] Add support for TLS data relocations
Ulrich Weigand
ulrich.weigand at de.ibm.com
Mon Jul 1 16:33:30 PDT 2013
Author: uweigand
Date: Mon Jul 1 18:33:29 2013
New Revision: 185394
URL: http://llvm.org/viewvc/llvm-project?rev=185394&view=rev
Log:
[PowerPC] Add support for TLS data relocations
This adds support for TLS data relocations and modifiers:
.quad target at dtpmod
.quad target at tprel
.quad target at dtprel
Currently exploited by the asm parser only.
Modified:
llvm/trunk/include/llvm/MC/MCExpr.h
llvm/trunk/include/llvm/Object/ELF.h
llvm/trunk/include/llvm/Support/ELF.h
llvm/trunk/lib/MC/MCELFStreamer.cpp
llvm/trunk/lib/MC/MCExpr.cpp
llvm/trunk/lib/Target/PowerPC/MCTargetDesc/PPCELFObjectWriter.cpp
llvm/trunk/test/MC/PowerPC/ppc64-fixups.s
Modified: llvm/trunk/include/llvm/MC/MCExpr.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCExpr.h?rev=185394&r1=185393&r2=185394&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MC/MCExpr.h (original)
+++ llvm/trunk/include/llvm/MC/MCExpr.h Mon Jul 1 18:33:29 2013
@@ -186,6 +186,7 @@ public:
VK_PPC_TOC_LO, // symbol at toc@l
VK_PPC_TOC_HI, // symbol at toc@h
VK_PPC_TOC_HA, // symbol at toc@ha
+ VK_PPC_DTPMOD, // symbol at dtpmod
VK_PPC_TPREL, // symbol at tprel
VK_PPC_TPREL_LO, // symbol at tprel@l
VK_PPC_TPREL_HI, // symbol at tprel@h
Modified: llvm/trunk/include/llvm/Object/ELF.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/ELF.h?rev=185394&r1=185393&r2=185394&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Object/ELF.h (original)
+++ llvm/trunk/include/llvm/Object/ELF.h Mon Jul 1 18:33:29 2013
@@ -2034,14 +2034,17 @@ StringRef ELFObjectFile<ELFT>::getReloca
LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC_GOT16_HA);
LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC_REL32);
LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC_TLS);
+ LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC_DTPMOD32);
LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC_TPREL16);
LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC_TPREL16_LO);
LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC_TPREL16_HI);
LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC_TPREL16_HA);
+ LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC_TPREL32);
LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC_DTPREL16);
LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC_DTPREL16_LO);
LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC_DTPREL16_HI);
LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC_DTPREL16_HA);
+ LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC_DTPREL32);
LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC_GOT_TLSGD16);
LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC_GOT_TLSGD16_LO);
LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC_GOT_TLSGD16_HI);
@@ -2106,14 +2109,17 @@ StringRef ELFObjectFile<ELFT>::getReloca
LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC64_TOC16_DS);
LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC64_TOC16_LO_DS);
LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC64_TLS);
+ LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC64_DTPMOD64);
LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC64_TPREL16);
LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC64_TPREL16_LO);
LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC64_TPREL16_HI);
LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC64_TPREL16_HA);
+ LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC64_TPREL64);
LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC64_DTPREL16);
LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC64_DTPREL16_LO);
LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC64_DTPREL16_HI);
LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC64_DTPREL16_HA);
+ LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC64_DTPREL64);
LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC64_GOT_TLSGD16);
LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC64_GOT_TLSGD16_LO);
LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC64_GOT_TLSGD16_HI);
Modified: llvm/trunk/include/llvm/Support/ELF.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/ELF.h?rev=185394&r1=185393&r2=185394&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/ELF.h (original)
+++ llvm/trunk/include/llvm/Support/ELF.h Mon Jul 1 18:33:29 2013
@@ -466,14 +466,17 @@ enum {
R_PPC_GOT16_HA = 17,
R_PPC_REL32 = 26,
R_PPC_TLS = 67,
+ R_PPC_DTPMOD32 = 68,
R_PPC_TPREL16 = 69,
R_PPC_TPREL16_LO = 70,
R_PPC_TPREL16_HI = 71,
R_PPC_TPREL16_HA = 72,
+ R_PPC_TPREL32 = 73,
R_PPC_DTPREL16 = 74,
R_PPC_DTPREL16_LO = 75,
R_PPC_DTPREL16_HI = 76,
R_PPC_DTPREL16_HA = 77,
+ R_PPC_DTPREL32 = 78,
R_PPC_GOT_TLSGD16 = 79,
R_PPC_GOT_TLSGD16_LO = 80,
R_PPC_GOT_TLSGD16_HI = 81,
@@ -537,14 +540,17 @@ enum {
R_PPC64_TOC16_DS = 63,
R_PPC64_TOC16_LO_DS = 64,
R_PPC64_TLS = 67,
+ R_PPC64_DTPMOD64 = 68,
R_PPC64_TPREL16 = 69,
R_PPC64_TPREL16_LO = 70,
R_PPC64_TPREL16_HI = 71,
R_PPC64_TPREL16_HA = 72,
+ R_PPC64_TPREL64 = 73,
R_PPC64_DTPREL16 = 74,
R_PPC64_DTPREL16_LO = 75,
R_PPC64_DTPREL16_HI = 76,
R_PPC64_DTPREL16_HA = 77,
+ R_PPC64_DTPREL64 = 78,
R_PPC64_GOT_TLSGD16 = 79,
R_PPC64_GOT_TLSGD16_LO = 80,
R_PPC64_GOT_TLSGD16_HI = 81,
Modified: llvm/trunk/lib/MC/MCELFStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCELFStreamer.cpp?rev=185394&r1=185393&r2=185394&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCELFStreamer.cpp (original)
+++ llvm/trunk/lib/MC/MCELFStreamer.cpp Mon Jul 1 18:33:29 2013
@@ -363,6 +363,7 @@ void MCELFStreamer::fixSymbolsInTLSFixu
case MCSymbolRefExpr::VK_Mips_GOTTPREL:
case MCSymbolRefExpr::VK_Mips_TPREL_HI:
case MCSymbolRefExpr::VK_Mips_TPREL_LO:
+ case MCSymbolRefExpr::VK_PPC_DTPMOD:
case MCSymbolRefExpr::VK_PPC_TPREL:
case MCSymbolRefExpr::VK_PPC_TPREL_LO:
case MCSymbolRefExpr::VK_PPC_TPREL_HI:
Modified: llvm/trunk/lib/MC/MCExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCExpr.cpp?rev=185394&r1=185393&r2=185394&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCExpr.cpp (original)
+++ llvm/trunk/lib/MC/MCExpr.cpp Mon Jul 1 18:33:29 2013
@@ -211,6 +211,7 @@ StringRef MCSymbolRefExpr::getVariantKin
case VK_PPC_TOC_LO: return "toc at l";
case VK_PPC_TOC_HI: return "toc at h";
case VK_PPC_TOC_HA: return "toc at ha";
+ case VK_PPC_DTPMOD: return "dtpmod";
case VK_PPC_TPREL: return "tprel";
case VK_PPC_TPREL_LO: return "tprel at l";
case VK_PPC_TPREL_HI: return "tprel at h";
@@ -342,6 +343,8 @@ MCSymbolRefExpr::getVariantKindForName(S
.Case("toc at ha", VK_PPC_TOC_HA)
.Case("TLS", VK_PPC_TLS)
.Case("tls", VK_PPC_TLS)
+ .Case("DTPMOD", VK_PPC_DTPMOD)
+ .Case("dtpmod", VK_PPC_DTPMOD)
.Case("TPREL", VK_PPC_TPREL)
.Case("tprel", VK_PPC_TPREL)
.Case("TPREL at L", VK_PPC_TPREL_LO)
Modified: llvm/trunk/lib/Target/PowerPC/MCTargetDesc/PPCELFObjectWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/MCTargetDesc/PPCELFObjectWriter.cpp?rev=185394&r1=185393&r2=185394&view=diff
==============================================================================
--- llvm/trunk/lib/Target/PowerPC/MCTargetDesc/PPCELFObjectWriter.cpp (original)
+++ llvm/trunk/lib/Target/PowerPC/MCTargetDesc/PPCELFObjectWriter.cpp Mon Jul 1 18:33:29 2013
@@ -312,6 +312,15 @@ unsigned PPCELFObjectWriter::getRelocTyp
case MCSymbolRefExpr::VK_None:
Type = ELF::R_PPC64_ADDR64;
break;
+ case MCSymbolRefExpr::VK_PPC_DTPMOD:
+ Type = ELF::R_PPC64_DTPMOD64;
+ break;
+ case MCSymbolRefExpr::VK_PPC_TPREL:
+ Type = ELF::R_PPC64_TPREL64;
+ break;
+ case MCSymbolRefExpr::VK_PPC_DTPREL:
+ Type = ELF::R_PPC64_DTPREL64;
+ break;
}
break;
case FK_Data_4:
Modified: llvm/trunk/test/MC/PowerPC/ppc64-fixups.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/PowerPC/ppc64-fixups.s?rev=185394&r1=185393&r2=185394&view=diff
==============================================================================
--- llvm/trunk/test/MC/PowerPC/ppc64-fixups.s (original)
+++ llvm/trunk/test/MC/PowerPC/ppc64-fixups.s Mon Jul 1 18:33:29 2013
@@ -25,8 +25,6 @@
beqa target
-# FIXME: .TOC. at tocbase
-
# CHECK: li 3, target at l # encoding: [0x38,0x60,A,A]
# CHECK-NEXT: # fixup A - offset: 2, value: target at l, kind: fixup_ppc_half16
# CHECK-REL: 0x{{[0-9A-F]*[26AE]}} R_PPC64_ADDR16_LO target 0x0
@@ -393,3 +391,22 @@ base:
# CHECK-REL: 0x{{[0-9A-F]*[26AE]}} R_PPC64_GOT_TLSLD16 target 0x0
addi 3, 3, target at got@tlsld
+
+# Data relocs
+# llvm-mc does not show any "encoding" string for data, so we just check the relocs
+
+# CHECK-REL: .rela.data
+ .data
+
+# CHECK-REL: 0x{{[0-9A-F]*[08]}} R_PPC64_TOC - 0x0
+ .quad .TOC. at tocbase
+
+# CHECK-REL: 0x{{[0-9A-F]*[08]}} R_PPC64_DTPMOD64 target 0x0
+ .quad target at dtpmod
+
+# CHECK-REL: 0x{{[0-9A-F]*[08]}} R_PPC64_TPREL64 target 0x0
+ .quad target at tprel
+
+# CHECK-REL: 0x{{[0-9A-F]*[08]}} R_PPC64_DTPREL64 target 0x0
+ .quad target at dtprel
+
More information about the llvm-commits
mailing list