Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(440)

Unified Diff: lib/Target/Mips/MCTargetDesc/MipsAsmBackend.cpp

Issue 27690005: [MIPS] Modify LongBranch expansion to work with sandboxing (Closed) Base URL: http://git.chromium.org/native_client/pnacl-llvm.git@master
Patch Set: Update. Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..899c378ee603f467f94eb93d3ce9b6399cda2fd8 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,24 @@ public:
MCELFObjectTargetWriter::getOSABI(OSType), IsLittle, Is64Bit);
}
+ // @LOCALMOD-START
+ /// 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) {
+ if (OSType == Triple::NaCl) {
Mark Seaborn 2013/10/24 23:38:43 Isn't this check unnecessary? Checking getKind()
petarj 2013/11/21 18:23:42 Done.
+ 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;
+ }
+ }
+ }
+ // @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 +222,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)

Powered by Google App Engine
This is Rietveld 408576698