[PowerPC] Support @got modifier

Add VK_... values and relocation types necessary to support
the @got family of modifiers.  Used by the asm parser only.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@184860 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Ulrich Weigand 2013-06-25 16:49:50 +00:00
parent 46fa7cf91a
commit 5de735a962
6 changed files with 85 additions and 0 deletions

View File

@ -178,6 +178,9 @@ public:
VK_PPC_HIGHERA, // symbol@highera
VK_PPC_HIGHEST, // symbol@highest
VK_PPC_HIGHESTA, // symbol@highesta
VK_PPC_GOT_LO, // symbol@got@l
VK_PPC_GOT_HI, // symbol@got@h
VK_PPC_GOT_HA, // symbol@got@ha
VK_PPC_TOCBASE, // symbol@tocbase
VK_PPC_TOC, // symbol@toc
VK_PPC_TOC_LO, // symbol@toc@l

View File

@ -2028,6 +2028,10 @@ StringRef ELFObjectFile<ELFT>::getRelocationTypeName(uint32_t Type) const {
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>::getRelocationTypeName(uint32_t Type) const {
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>::getRelocationTypeName(uint32_t Type) const {
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);

View File

@ -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,

View File

@ -203,6 +203,9 @@ StringRef MCSymbolRefExpr::getVariantKindName(VariantKind Kind) {
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@l";
case VK_PPC_GOT_HI: return "got@h";
case VK_PPC_GOT_HA: return "got@ha";
case VK_PPC_TOCBASE: return "tocbase";
case VK_PPC_TOC: return "toc";
case VK_PPC_TOC_LO: return "toc@l";
@ -321,6 +324,12 @@ MCSymbolRefExpr::getVariantKindForName(StringRef Name) {
.Case("highest", VK_PPC_HIGHEST)
.Case("HIGHESTA", VK_PPC_HIGHESTA)
.Case("highesta", VK_PPC_HIGHESTA)
.Case("GOT@L", VK_PPC_GOT_LO)
.Case("got@l", VK_PPC_GOT_LO)
.Case("GOT@H", VK_PPC_GOT_HI)
.Case("got@h", VK_PPC_GOT_HI)
.Case("GOT@HA", VK_PPC_GOT_HA)
.Case("got@ha", VK_PPC_GOT_HA)
.Case("TOCBASE", VK_PPC_TOCBASE)
.Case("tocbase", VK_PPC_TOCBASE)
.Case("TOC", VK_PPC_TOC)

View File

@ -127,6 +127,18 @@ unsigned PPCELFObjectWriter::getRelocTypeInner(const MCValue &Target,
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::getRelocTypeInner(const MCValue &Target,
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;

View File

@ -163,6 +163,41 @@ base:
# CHECK-REL: 0x{{[0-9A-F]*[26AE]}} R_PPC64_TOC16_LO_DS target 0x0
ld 1, target@toc@l(3)
# CHECK: addi 4, 3, target@GOT # encoding: [0x38,0x83,A,A]
# CHECK-NEXT: # fixup A - offset: 2, value: target@GOT, kind: fixup_ppc_half16
# CHECK-REL: 0x{{[0-9A-F]*[26AE]}} R_PPC64_GOT16 target 0x0
addi 4, 3, target@got
# CHECK: ld 1, target@GOT(2) # encoding: [0xe8,0x22,A,0bAAAAAA00]
# CHECK-NEXT: # fixup A - offset: 2, value: target@GOT, kind: fixup_ppc_half16ds
# CHECK-REL: 0x{{[0-9A-F]*[26AE]}} R_PPC64_GOT16_DS target 0x0
ld 1, target@got(2)
# CHECK: addis 3, 2, target@got@ha # encoding: [0x3c,0x62,A,A]
# CHECK-NEXT: # fixup A - offset: 2, value: target@got@ha, kind: fixup_ppc_half16
# CHECK-REL: 0x{{[0-9A-F]*[26AE]}} R_PPC64_GOT16_HA target 0x0
addis 3, 2, target@got@ha
# CHECK: addi 4, 3, target@got@l # encoding: [0x38,0x83,A,A]
# CHECK-NEXT: # fixup A - offset: 2, value: target@got@l, kind: fixup_ppc_half16
# CHECK-REL: 0x{{[0-9A-F]*[26AE]}} R_PPC64_GOT16_LO target 0x0
addi 4, 3, target@got@l
# CHECK: addis 3, 2, target@got@h # encoding: [0x3c,0x62,A,A]
# CHECK-NEXT: # fixup A - offset: 2, value: target@got@h, kind: fixup_ppc_half16
# CHECK-REL: 0x{{[0-9A-F]*[26AE]}} R_PPC64_GOT16_HI target 0x0
addis 3, 2, target@got@h
# CHECK: lwz 1, target@got@l(3) # encoding: [0x80,0x23,A,A]
# CHECK-NEXT: # fixup A - offset: 2, value: target@got@l, kind: fixup_ppc_half16
# CHECK-REL: 0x{{[0-9A-F]*[26AE]}} R_PPC64_GOT16_LO target 0x0
lwz 1, target@got@l(3)
# CHECK: ld 1, target@got@l(3) # encoding: [0xe8,0x23,A,0bAAAAAA00]
# CHECK-NEXT: # fixup A - offset: 2, value: target@got@l, kind: fixup_ppc_half16ds
# CHECK-REL: 0x{{[0-9A-F]*[26AE]}} R_PPC64_GOT16_LO_DS target 0x0
ld 1, target@got@l(3)
# FIXME: @tls