Index: lib/Target/Mips/MCTargetDesc/MipsAsmBackend.cpp |
diff --git a/lib/Target/Mips/MCTargetDesc/MipsAsmBackend.cpp b/lib/Target/Mips/MCTargetDesc/MipsAsmBackend.cpp |
index 50f0893fce7e2defdde30787b81c77bc3f361ea3..f06ff73edf901b8456514ec0edff8ab5e3ae3a87 100644 |
--- a/lib/Target/Mips/MCTargetDesc/MipsAsmBackend.cpp |
+++ b/lib/Target/Mips/MCTargetDesc/MipsAsmBackend.cpp |
@@ -77,6 +77,21 @@ static unsigned adjustFixupValue(unsigned Kind, uint64_t Value) { |
// Get the 4th 16-bits. |
Value = ((Value + 0x800080008000LL) >> 48) & 0xffff; |
break; |
+ // @LOCALMOD-START |
+ case Mips::fixup_Mips_NACL_LONG_BRANCH_HI16: |
+ // Resolve LUi part of the LUi/ADDiu long branch offset calculation. |
+ // The Value is the offset of the target basic block from the LUi |
+ // instruction. Since we need offset from the next instruction (ADDiu), |
+ // we modify if by -4. Get the high 16-bits. Since the immediate from the |
+ // ADDiu is treated as signed, add 1 if bit 15 is 1. |
+ Value = ((Value - 4 + 0x8000) >> 16) & 0xffff; |
+ break; |
+ case Mips::fixup_Mips_NACL_LONG_BRANCH_LO16: |
+ // Resolve ADDiu part of the LUi/ADDiu long branch offset calculation. |
+ // Get the low 16-bits. |
+ Value = Value & 0xffff; |
+ break; |
+ // @LOCALMOD-END |
} |
return Value; |
@@ -98,6 +113,23 @@ public: |
MCELFObjectTargetWriter::getOSABI(OSType), IsLittle, Is64Bit); |
} |
+ /// processFixupValue - Target hook to process the literal value of a fixup |
+ /// if necessary. |
+ void processFixupValue(const MCAssembler &Asm, const MCAsmLayout &Layout, |
+ const MCFixup &Fixup, const MCFragment *DF, |
+ MCValue &Target, uint64_t &Value, |
+ bool &IsResolved) { |
+ // @LOCALMOD-START |
Mark Seaborn
2013/10/17 19:00:11
This whole function should be inside LOCALMOD comm
petarj
2013/10/22 23:10:27
Done.
|
+ if (OSType == Triple::NaCl) { |
+ if ((unsigned)Fixup.getKind() == Mips::fixup_Mips_NACL_LONG_BRANCH_HI16 |
+ || ((unsigned)Fixup.getKind() |
+ == Mips::fixup_Mips_NACL_LONG_BRANCH_LO16)) |
+ // We don't need to emit relocation for long branch fixup. |
+ IsResolved = true; |
Mark Seaborn
2013/10/17 19:00:11
Nit: Put {} brackets around this block since the c
petarj
2013/10/22 23:10:27
Done.
|
+ } |
+ // @LOCALMOD-END |
+ } |
+ |
/// ApplyFixup - Apply the \p Value for given \p Fixup into the provided |
/// data fragment, at the offset specified by the fixup and following the |
/// fixup kind as appropriate. |
@@ -189,7 +221,13 @@ public: |
{ "fixup_Mips_GOT_HI16", 0, 16, 0 }, |
{ "fixup_Mips_GOT_LO16", 0, 16, 0 }, |
{ "fixup_Mips_CALL_HI16", 0, 16, 0 }, |
- { "fixup_Mips_CALL_LO16", 0, 16, 0 } |
+ { "fixup_Mips_CALL_LO16", 0, 16, 0 }, |
+ // @LOCALMOD-START |
+ { "fixup_Mips_NACL_LONG_BRANCH_HI16", 0, 16, |
+ MCFixupKindInfo::FKF_IsPCRel }, |
+ { "fixup_Mips_NACL_LONG_BRANCH_LO16", 0, 16, |
+ MCFixupKindInfo::FKF_IsPCRel } |
+ // @LOCALMOD-END |
}; |
if (Kind < FirstTargetFixupKind) |