summaryrefslogtreecommitdiffstats
path: root/llvm/lib/MC/MCObjectStreamer.cpp
diff options
context:
space:
mode:
authorDaniel Sanders <daniel.sanders@imgtec.com>2015-11-12 13:33:00 +0000
committerDaniel Sanders <daniel.sanders@imgtec.com>2015-11-12 13:33:00 +0000
commit9f6ad4974012c5223931a0172d5d6b51753dd15f (patch)
treee10ec303cbdd9ade93e3fbd8ecbbf8dc5a0febfb /llvm/lib/MC/MCObjectStreamer.cpp
parente342469c0ad1141e50bdc6b8a864a589663c6297 (diff)
downloadbcm5719-llvm-9f6ad4974012c5223931a0172d5d6b51753dd15f.tar.gz
bcm5719-llvm-9f6ad4974012c5223931a0172d5d6b51753dd15f.zip
Implement .reloc (constant offset only) with support for R_MIPS_NONE and R_MIPS_32.
Summary: Support for R_MIPS_NONE allows us to parse MIPS16's usage of .reloc. R_MIPS_32 was included to be able to better test the directive. Targets can add their relocations by overriding MCAsmBackend::getFixupKind(). Subscribers: grosbach, rafael, majnemer, dsanders, llvm-commits Differential Revision: http://reviews.llvm.org/D13659 llvm-svn: 252888
Diffstat (limited to 'llvm/lib/MC/MCObjectStreamer.cpp')
-rw-r--r--llvm/lib/MC/MCObjectStreamer.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/llvm/lib/MC/MCObjectStreamer.cpp b/llvm/lib/MC/MCObjectStreamer.cpp
index c47e2162b63..d0a7dafa15b 100644
--- a/llvm/lib/MC/MCObjectStreamer.cpp
+++ b/llvm/lib/MC/MCObjectStreamer.cpp
@@ -416,6 +416,26 @@ void MCObjectStreamer::EmitGPRel64Value(const MCExpr *Value) {
DF->getContents().resize(DF->getContents().size() + 8, 0);
}
+bool MCObjectStreamer::EmitRelocDirective(const MCExpr &Offset, StringRef Name,
+ const MCExpr *Expr, SMLoc Loc) {
+ int64_t OffsetValue;
+ if (!Offset.evaluateAsAbsolute(OffsetValue))
+ llvm_unreachable("Offset is not absolute");
+
+ MCDataFragment *DF = getOrCreateDataFragment();
+ flushPendingLabels(DF, DF->getContents().size());
+
+ MCFixupKind Kind;
+ if (!Assembler->getBackend().getFixupKind(Name, Kind))
+ return true;
+
+ if (Expr == nullptr)
+ Expr =
+ MCSymbolRefExpr::create(getContext().createTempSymbol(), getContext());
+ DF->getFixups().push_back(MCFixup::create(OffsetValue, Expr, Kind, Loc));
+ return false;
+}
+
void MCObjectStreamer::EmitFill(uint64_t NumBytes, uint8_t FillValue) {
const MCSection *Sec = getCurrentSection().first;
assert(Sec && "need a section");
OpenPOWER on IntegriCloud