Support for microMIPS TLS relocations.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@197685 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Zoran Jovanovic 2013-12-19 16:02:32 +00:00
parent d4cf97ba51
commit 44dc232eae
7 changed files with 34 additions and 2 deletions

View File

@ -890,6 +890,8 @@ enum {
R_MICROMIPS_GOT_DISP = 145,
R_MICROMIPS_GOT_PAGE = 146,
R_MICROMIPS_GOT_OFST = 147,
R_MICROMIPS_TLS_GD = 162,
R_MICROMIPS_TLS_LDM = 163,
R_MICROMIPS_TLS_DTPREL_HI16 = 164,
R_MICROMIPS_TLS_DTPREL_LO16 = 165,
R_MICROMIPS_TLS_TPREL_HI16 = 169,

View File

@ -170,6 +170,8 @@ StringRef getELFRelocationTypeName(uint32_t Machine, uint32_t Type) {
LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_MICROMIPS_GOT_DISP);
LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_MICROMIPS_GOT_PAGE);
LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_MICROMIPS_GOT_OFST);
LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_MICROMIPS_TLS_GD);
LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_MICROMIPS_TLS_LDM);
LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_MICROMIPS_TLS_DTPREL_HI16);
LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_MICROMIPS_TLS_DTPREL_LO16);
LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_MICROMIPS_TLS_TPREL_HI16);

View File

@ -222,6 +222,8 @@ public:
{ "fixup_MICROMIPS_GOT_DISP", 0, 16, 0 },
{ "fixup_MICROMIPS_GOT_PAGE", 0, 16, 0 },
{ "fixup_MICROMIPS_GOT_OFST", 0, 16, 0 },
{ "fixup_MICROMIPS_TLS_GD", 0, 16, 0 },
{ "fixup_MICROMIPS_TLS_LDM", 0, 16, 0 },
{ "fixup_MICROMIPS_TLS_DTPREL_HI16", 0, 16, 0 },
{ "fixup_MICROMIPS_TLS_DTPREL_LO16", 0, 16, 0 },
{ "fixup_MICROMIPS_TLS_TPREL_HI16", 0, 16, 0 },

View File

@ -210,6 +210,12 @@ unsigned MipsELFObjectWriter::GetRelocType(const MCValue &Target,
case Mips::fixup_MICROMIPS_GOT_OFST:
Type = ELF::R_MICROMIPS_GOT_OFST;
break;
case Mips::fixup_MICROMIPS_TLS_GD:
Type = ELF::R_MICROMIPS_TLS_GD;
break;
case Mips::fixup_MICROMIPS_TLS_LDM:
Type = ELF::R_MICROMIPS_TLS_LDM;
break;
case Mips::fixup_MICROMIPS_TLS_DTPREL_HI16:
Type = ELF::R_MICROMIPS_TLS_DTPREL_HI16;
break;

View File

@ -155,6 +155,12 @@ namespace Mips {
// resulting in - R_MICROMIPS_GOT_OFST
fixup_MICROMIPS_GOT_OFST,
// resulting in - R_MICROMIPS_TLS_GD
fixup_MICROMIPS_TLS_GD,
// resulting in - R_MICROMIPS_TLS_LDM
fixup_MICROMIPS_TLS_LDM,
// resulting in - R_MICROMIPS_TLS_DTPREL_HI16
fixup_MICROMIPS_TLS_DTPREL_HI16,

View File

@ -413,10 +413,12 @@ getExprOpValue(const MCExpr *Expr,SmallVectorImpl<MCFixup> &Fixups) const {
: Mips::fixup_Mips_LO16;
break;
case MCSymbolRefExpr::VK_Mips_TLSGD:
FixupKind = Mips::fixup_Mips_TLSGD;
FixupKind = IsMicroMips ? Mips::fixup_MICROMIPS_TLS_GD
: Mips::fixup_Mips_TLSGD;
break;
case MCSymbolRefExpr::VK_Mips_TLSLDM:
FixupKind = Mips::fixup_Mips_TLSLDM;
FixupKind = IsMicroMips ? Mips::fixup_MICROMIPS_TLS_LDM
: Mips::fixup_Mips_TLSLDM;
break;
case MCSymbolRefExpr::VK_Mips_DTPREL_HI:
FixupKind = IsMicroMips ? Mips::fixup_MICROMIPS_TLS_DTPREL_HI16

View File

@ -67,6 +67,14 @@
# CHECK-FIXUP: # fixup A - offset: 0,
# CHECK-FIXUP: value: _gp_disp@TPREL_LO,
# CHECK-FIXUP: kind: fixup_MICROMIPS_TLS_TPREL_LO16
# CHECK-FIXUP: addiu $4, $gp, %tlsgd(a)
# CHECK-FIXUP: # encoding: [0x9c'A',0x30'A',0x00,0x00]
# CHECK-FIXUP: # fixup A - offset: 0,
# CHECK-FIXUP: value: a@TLSGD, kind: fixup_MICROMIPS_TLS_GD
# CHECK-FIXUP: addiu $4, $gp, %tlsldm(f.i)
# CHECK-FIXUP: # encoding: [0x9c'A',0x30'A',0x00,0x00]
# CHECK-FIXUP: # fixup A - offset: 0,
# CHECK-FIXUP: value: f.i@TLSLDM, kind: fixup_MICROMIPS_TLS_LDM
#------------------------------------------------------------------------------
# Check that the appropriate relocations were created.
#------------------------------------------------------------------------------
@ -83,6 +91,8 @@
# CHECK-ELF: 0x{{[0-9,A-F]+}} R_MICROMIPS_GOT_OFST
# CHECK-ELF: 0x{{[0-9,A-F]+}} R_MICROMIPS_TLS_TPREL_HI16
# CHECK-ELF: 0x{{[0-9,A-F]+}} R_MICROMIPS_TLS_TPREL_LO16
# CHECK-ELF: 0x{{[0-9,A-F]+}} R_MICROMIPS_TLS_GD
# CHECK-ELF: 0x{{[0-9,A-F]+}} R_MICROMIPS_TLS_LDM
# CHECK-ELF: ]
lui $2, %hi(_gp_disp)
@ -97,3 +107,5 @@
lw $6, %got_ofst(loop_4)($5)
lui $2, %tprel_hi(_gp_disp)
addiu $2, $2, %tprel_lo(_gp_disp)
addiu $4, $gp, %tlsgd(a)
addiu $4, $gp, %tlsldm(f.i)