[llvm] r184860 - [PowerPC] Support @got modifier
Ulrich Weigand
ulrich.weigand at de.ibm.com
Tue Jun 25 09:49:50 PDT 2013
Author: uweigand
Date: Tue Jun 25 11:49:50 2013
New Revision: 184860
URL: http://llvm.org/viewvc/llvm-project?rev=184860&view=rev
Log:
[PowerPC] Support @got modifier
Add VK_... values and relocation types necessary to support
the @got family of modifiers. Used 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/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=184860&r1=184859&r2=184860&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MC/MCExpr.h (original)
+++ llvm/trunk/include/llvm/MC/MCExpr.h Tue Jun 25 11:49:50 2013
@@ -178,6 +178,9 @@ public:
VK_PPC_HIGHERA, // symbol at highera
VK_PPC_HIGHEST, // symbol at highest
VK_PPC_HIGHESTA, // symbol at highesta
+ VK_PPC_GOT_LO, // symbol at got@l
+ VK_PPC_GOT_HI, // symbol at got@h
+ VK_PPC_GOT_HA, // symbol at got@ha
VK_PPC_TOCBASE, // symbol at tocbase
VK_PPC_TOC, // symbol at toc
VK_PPC_TOC_LO, // symbol at toc@l
Modified: llvm/trunk/include/llvm/Object/ELF.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/ELF.h?rev=184860&r1=184859&r2=184860&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Object/ELF.h (original)
+++ llvm/trunk/include/llvm/Object/ELF.h Tue Jun 25 11:49:50 2013
@@ -2028,6 +2028,10 @@ StringRef ELFObjectFile<ELFT>::getReloca
LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC_REL14);
LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC_REL14_BRTAKEN);
LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC_REL14_BRNTAKEN);
+ LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC_GOT16);
+ LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC_GOT16_LO);
+ LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC_GOT16_HI);
+ 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_TPREL16);
LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC_TPREL16_LO);
@@ -2076,6 +2080,10 @@ StringRef ELFObjectFile<ELFT>::getReloca
LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC64_REL14);
LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC64_REL14_BRTAKEN);
LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC64_REL14_BRNTAKEN);
+ LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC64_GOT16);
+ LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC64_GOT16_LO);
+ LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC64_GOT16_HI);
+ LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC64_GOT16_HA);
LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC64_REL32);
LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC64_ADDR64);
LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC64_ADDR16_HIGHER);
@@ -2090,6 +2098,8 @@ StringRef ELFObjectFile<ELFT>::getReloca
LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC64_TOC);
LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC64_ADDR16_DS);
LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC64_ADDR16_LO_DS);
+ LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC64_GOT16_DS);
+ LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC64_GOT16_LO_DS);
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);
Modified: llvm/trunk/include/llvm/Support/ELF.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/ELF.h?rev=184860&r1=184859&r2=184860&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/ELF.h (original)
+++ llvm/trunk/include/llvm/Support/ELF.h Tue Jun 25 11:49:50 2013
@@ -460,6 +460,10 @@ enum {
R_PPC_REL14 = 11,
R_PPC_REL14_BRTAKEN = 12,
R_PPC_REL14_BRNTAKEN = 13,
+ R_PPC_GOT16 = 14,
+ R_PPC_GOT16_LO = 15,
+ R_PPC_GOT16_HI = 16,
+ R_PPC_GOT16_HA = 17,
R_PPC_REL32 = 26,
R_PPC_TPREL16 = 69,
R_PPC_TPREL16_LO = 70,
@@ -507,6 +511,10 @@ enum {
R_PPC64_REL14 = 11,
R_PPC64_REL14_BRTAKEN = 12,
R_PPC64_REL14_BRNTAKEN = 13,
+ R_PPC64_GOT16 = 14,
+ R_PPC64_GOT16_LO = 15,
+ R_PPC64_GOT16_HI = 16,
+ R_PPC64_GOT16_HA = 17,
R_PPC64_REL32 = 26,
R_PPC64_ADDR64 = 38,
R_PPC64_ADDR16_HIGHER = 39,
@@ -521,6 +529,8 @@ enum {
R_PPC64_TOC = 51,
R_PPC64_ADDR16_DS = 56,
R_PPC64_ADDR16_LO_DS = 57,
+ R_PPC64_GOT16_DS = 58,
+ R_PPC64_GOT16_LO_DS = 59,
R_PPC64_TOC16_DS = 63,
R_PPC64_TOC16_LO_DS = 64,
R_PPC64_TLS = 67,
Modified: llvm/trunk/lib/MC/MCExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCExpr.cpp?rev=184860&r1=184859&r2=184860&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCExpr.cpp (original)
+++ llvm/trunk/lib/MC/MCExpr.cpp Tue Jun 25 11:49:50 2013
@@ -203,6 +203,9 @@ StringRef MCSymbolRefExpr::getVariantKin
case VK_PPC_HIGHERA: return "highera";
case VK_PPC_HIGHEST: return "highest";
case VK_PPC_HIGHESTA: return "highesta";
+ case VK_PPC_GOT_LO: return "got at l";
+ case VK_PPC_GOT_HI: return "got at h";
+ case VK_PPC_GOT_HA: return "got at ha";
case VK_PPC_TOCBASE: return "tocbase";
case VK_PPC_TOC: return "toc";
case VK_PPC_TOC_LO: return "toc at l";
@@ -321,6 +324,12 @@ MCSymbolRefExpr::getVariantKindForName(S
.Case("highest", VK_PPC_HIGHEST)
.Case("HIGHESTA", VK_PPC_HIGHESTA)
.Case("highesta", VK_PPC_HIGHESTA)
+ .Case("GOT at L", VK_PPC_GOT_LO)
+ .Case("got at l", VK_PPC_GOT_LO)
+ .Case("GOT at H", VK_PPC_GOT_HI)
+ .Case("got at h", VK_PPC_GOT_HI)
+ .Case("GOT at HA", VK_PPC_GOT_HA)
+ .Case("got at ha", VK_PPC_GOT_HA)
.Case("TOCBASE", VK_PPC_TOCBASE)
.Case("tocbase", VK_PPC_TOCBASE)
.Case("TOC", VK_PPC_TOC)
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=184860&r1=184859&r2=184860&view=diff
==============================================================================
--- llvm/trunk/lib/Target/PowerPC/MCTargetDesc/PPCELFObjectWriter.cpp (original)
+++ llvm/trunk/lib/Target/PowerPC/MCTargetDesc/PPCELFObjectWriter.cpp Tue Jun 25 11:49:50 2013
@@ -127,6 +127,18 @@ unsigned PPCELFObjectWriter::getRelocTyp
case MCSymbolRefExpr::VK_PPC_HIGHESTA:
Type = ELF::R_PPC64_ADDR16_HIGHESTA;
break;
+ case MCSymbolRefExpr::VK_GOT:
+ Type = ELF::R_PPC_GOT16;
+ break;
+ case MCSymbolRefExpr::VK_PPC_GOT_LO:
+ Type = ELF::R_PPC_GOT16_LO;
+ break;
+ case MCSymbolRefExpr::VK_PPC_GOT_HI:
+ Type = ELF::R_PPC_GOT16_HI;
+ break;
+ case MCSymbolRefExpr::VK_PPC_GOT_HA:
+ Type = ELF::R_PPC_GOT16_HA;
+ break;
case MCSymbolRefExpr::VK_PPC_TOC:
Type = ELF::R_PPC64_TOC16;
break;
@@ -234,6 +246,12 @@ unsigned PPCELFObjectWriter::getRelocTyp
case MCSymbolRefExpr::VK_PPC_LO:
Type = ELF::R_PPC64_ADDR16_LO_DS;
break;
+ case MCSymbolRefExpr::VK_GOT:
+ Type = ELF::R_PPC64_GOT16_DS;
+ break;
+ case MCSymbolRefExpr::VK_PPC_GOT_LO:
+ Type = ELF::R_PPC64_GOT16_LO_DS;
+ break;
case MCSymbolRefExpr::VK_PPC_TOC:
Type = ELF::R_PPC64_TOC16_DS;
break;
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=184860&r1=184859&r2=184860&view=diff
==============================================================================
--- llvm/trunk/test/MC/PowerPC/ppc64-fixups.s (original)
+++ llvm/trunk/test/MC/PowerPC/ppc64-fixups.s Tue Jun 25 11:49:50 2013
@@ -163,6 +163,41 @@ base:
# CHECK-REL: 0x{{[0-9A-F]*[26AE]}} R_PPC64_TOC16_LO_DS target 0x0
ld 1, target at toc@l(3)
+# CHECK: addi 4, 3, target at GOT # encoding: [0x38,0x83,A,A]
+# CHECK-NEXT: # fixup A - offset: 2, value: target at GOT, kind: fixup_ppc_half16
+# CHECK-REL: 0x{{[0-9A-F]*[26AE]}} R_PPC64_GOT16 target 0x0
+ addi 4, 3, target at got
+
+# CHECK: ld 1, target at GOT(2) # encoding: [0xe8,0x22,A,0bAAAAAA00]
+# CHECK-NEXT: # fixup A - offset: 2, value: target at GOT, kind: fixup_ppc_half16ds
+# CHECK-REL: 0x{{[0-9A-F]*[26AE]}} R_PPC64_GOT16_DS target 0x0
+ ld 1, target at got(2)
+
+# CHECK: addis 3, 2, target at got@ha # encoding: [0x3c,0x62,A,A]
+# CHECK-NEXT: # fixup A - offset: 2, value: target at got@ha, kind: fixup_ppc_half16
+# CHECK-REL: 0x{{[0-9A-F]*[26AE]}} R_PPC64_GOT16_HA target 0x0
+ addis 3, 2, target at got@ha
+
+# CHECK: addi 4, 3, target at got@l # encoding: [0x38,0x83,A,A]
+# CHECK-NEXT: # fixup A - offset: 2, value: target at got@l, kind: fixup_ppc_half16
+# CHECK-REL: 0x{{[0-9A-F]*[26AE]}} R_PPC64_GOT16_LO target 0x0
+ addi 4, 3, target at got@l
+
+# CHECK: addis 3, 2, target at got@h # encoding: [0x3c,0x62,A,A]
+# CHECK-NEXT: # fixup A - offset: 2, value: target at got@h, kind: fixup_ppc_half16
+# CHECK-REL: 0x{{[0-9A-F]*[26AE]}} R_PPC64_GOT16_HI target 0x0
+ addis 3, 2, target at got@h
+
+# CHECK: lwz 1, target at got@l(3) # encoding: [0x80,0x23,A,A]
+# CHECK-NEXT: # fixup A - offset: 2, value: target at got@l, kind: fixup_ppc_half16
+# CHECK-REL: 0x{{[0-9A-F]*[26AE]}} R_PPC64_GOT16_LO target 0x0
+ lwz 1, target at got@l(3)
+
+# CHECK: ld 1, target at got@l(3) # encoding: [0xe8,0x23,A,0bAAAAAA00]
+# CHECK-NEXT: # fixup A - offset: 2, value: target at got@l, kind: fixup_ppc_half16ds
+# CHECK-REL: 0x{{[0-9A-F]*[26AE]}} R_PPC64_GOT16_LO_DS target 0x0
+ ld 1, target at got@l(3)
+
# FIXME: @tls
More information about the llvm-commits
mailing list