diff options
author | Daniel Dunbar <daniel@zuster.org> | 2010-03-12 21:00:38 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2010-03-12 21:00:38 +0000 |
commit | 8315a357e48f2eeb4fa929168d3cb65924d9893e (patch) | |
tree | fcc2d8a0f2aeb4905fa6ddf0c605a071c029d816 | |
parent | b87c305fa77650ee581d4a8c65a0757f88002441 (diff) | |
download | external_llvm-8315a357e48f2eeb4fa929168d3cb65924d9893e.zip external_llvm-8315a357e48f2eeb4fa929168d3cb65924d9893e.tar.gz external_llvm-8315a357e48f2eeb4fa929168d3cb65924d9893e.tar.bz2 |
MC: Add MCAssembler::addFixup, which enforces that fixups are added in order.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@98379 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/llvm/MC/MCAssembler.h | 7 | ||||
-rw-r--r-- | lib/MC/MCMachOStreamer.cpp | 10 |
2 files changed, 11 insertions, 6 deletions
diff --git a/include/llvm/MC/MCAssembler.h b/include/llvm/MC/MCAssembler.h index 4ac7ef1..f0efb6c 100644 --- a/include/llvm/MC/MCAssembler.h +++ b/include/llvm/MC/MCAssembler.h @@ -162,6 +162,13 @@ public: /// @name Fixup Access /// @{ + void addFixup(MCAsmFixup Fixup) { + // Enforce invariant that fixups are in offset order. + assert(Fixups.empty() || Fixup.Offset > Fixups.back().Offset && + "Fixups must be added in order!"); + Fixups.push_back(Fixup); + } + std::vector<MCAsmFixup> &getFixups() { return Fixups; } const std::vector<MCAsmFixup> &getFixups() const { return Fixups; } diff --git a/lib/MC/MCMachOStreamer.cpp b/lib/MC/MCMachOStreamer.cpp index 1a6fa41..2d833ba 100644 --- a/lib/MC/MCMachOStreamer.cpp +++ b/lib/MC/MCMachOStreamer.cpp @@ -327,9 +327,8 @@ void MCMachOStreamer::EmitValue(const MCExpr *Value, unsigned Size, for (unsigned i = 0; i != Size; ++i) DF->getContents().push_back(uint8_t(AbsValue >> (i * 8))); } else { - DF->getFixups().push_back(MCAsmFixup(DF->getContents().size(), - *AddValueSymbols(Value), - MCFixup::getKindForSize(Size))); + DF->addFixup(MCAsmFixup(DF->getContents().size(), *AddValueSymbols(Value), + MCFixup::getKindForSize(Size))); DF->getContents().resize(DF->getContents().size() + Size, 0); } } @@ -388,9 +387,8 @@ void MCMachOStreamer::EmitInstruction(const MCInst &Inst) { DF = new MCDataFragment(CurSectionData); for (unsigned i = 0, e = Fixups.size(); i != e; ++i) { MCFixup &F = Fixups[i]; - DF->getFixups().push_back(MCAsmFixup(DF->getContents().size()+F.getOffset(), - *F.getValue(), - F.getKind())); + DF->addFixup(MCAsmFixup(DF->getContents().size()+F.getOffset(), + *F.getValue(), F.getKind())); } DF->getContents().append(Code.begin(), Code.end()); } |